Skip to content

Commit 22d67a0

Browse files
oleremNipaLocal
authored andcommitted
net: usb: lan78xx: annotate checksum assignment to silence sparse warnings
sparse warns about suspicious type casts in checksum assignment: drivers/net/usb/lan78xx.c:3865:29: warning: cast to restricted __be16 drivers/net/usb/lan78xx.c:3865:27: warning: incorrect type in assignment (different base types) expected restricted __wsum [usertype] csum got unsigned short [usertype] Use __force to annotate the casts from u16 to __be16 to __wsum. This makes the type conversion explicit and silences the warnings. The code is otherwise correct; this change only clarifies intent. Signed-off-by: Oleksij Rempel <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 9d09f90 commit 22d67a0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/net/usb/lan78xx.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3819,7 +3819,10 @@ static void lan78xx_rx_csum_offload(struct lan78xx_net *dev,
38193819
!(dev->net->features & NETIF_F_HW_VLAN_CTAG_RX))) {
38203820
skb->ip_summed = CHECKSUM_NONE;
38213821
} else {
3822-
skb->csum = ntohs((u16)(rx_cmd_b >> RX_CMD_B_CSUM_SHIFT_));
3822+
__be16 csum_raw;
3823+
3824+
csum_raw = (__force __be16)(rx_cmd_b >> RX_CMD_B_CSUM_SHIFT_);
3825+
skb->csum = (__force __wsum)ntohs(csum_raw);
38233826
skb->ip_summed = CHECKSUM_COMPLETE;
38243827
}
38253828
}

0 commit comments

Comments
 (0)