net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver
Hello Łukasz Stelmach,
The patch a97c69ba4f30: "net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver" from Oct 20, 2021, leads to the following Smatch static checker warning:
drivers/net/ethernet/asix/ax88796c_main.c:926 ax88796c_set_features() warn: duplicate check 'changed & ((1 << (40)) | (1 << (3)))' (previous on line 921)
drivers/net/ethernet/asix/ax88796c_main.c
915 static int
916 ax88796c_set_features(struct net_device *ndev, netdev_features_t features)
917 {
918 struct ax88796c_device *ax_local = to_ax88796c_device(ndev);
919 netdev_features_t changed = features ^ ndev->features;
920
921 if (!(changed & (NETIF_F_RXCSUM | NETIF_F_HW_CSUM)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
922 return 0;
923
924 ndev->features = features;
925 --> 926 if (changed & (NETIF_F_RXCSUM | NETIF_F_HW_CSUM))
We know this condition is true. Was something else intended?
927 ax88796c_set_csums(ax_local);
928
929 return 0;
930 }regards,
dan carpenter
Quoted 23 lines · when Dan Carpenter
Hello Łukasz Stelmach,
The patch
a97c69ba4f30: "net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver" from Oct 20, 2021, leads to the following Smatch static checker warning:drivers/net/ethernet/asix/ax88796c_main.c:926 ax88796c_set_features() warn: duplicate check 'changed & ((1 << (40)) | (1 << (3)))' (previous on line 921)
drivers/net/ethernet/asix/ax88796c_main.c915 static int 916 ax88796c_set_features(struct net_device *ndev, netdev_features_t features) 917 { 918 struct ax88796c_device *ax_local = to_ax88796c_device(ndev); 919 netdev_features_t changed = features ^ ndev->features; 920 921 if (!(changed & (NETIF_F_RXCSUM | NETIF_F_HW_CSUM))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 922 return 0; 923 924 ndev->features = features; 925
Quoted 4 lines
--> 926 if (changed & (
NETIF_F_RXCSUM|NETIF_F_HW_CSUM))We know this condition is true. Was something else intended?
To have a readable template to add more ifs below with other features. In such case the if at line 921 would check for all supported features and this and following ifs would act upon different flags.
Quoted 9 lines
927 ax88796c_set_csums(ax_local); 928 929 return 0; 930 }regards,
dan carpenter
Signature · 3 lines
Łukasz Stelmach Samsung R&D Institute Poland Samsung Electronics