mptlan.c: fixed UNNECESSARY_CASTS warning
PATCH 1/1 mptlan.c: fixed UNNECESSARY_CASTS warning
multiple UNNECESSARY_CASTS warnings fixed from mptlan.c
It is not good practice to cast alloc function as it may hide the bugs.
--- drivers/message/fusion/mptlan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/message/fusion/mptlan.c +3 -3
@@ -860,7 +860,7 @@ mpt_lan_receive_post_turbo(struct net_device *dev, u32 tmsg)if (len <MPT_LAN_RX_COPYBREAK ) { old_skb = skb; - skb = (struct sk_buff *)dev_alloc_skb (len); + skb =dev_alloc_skb (len);if (!skb) { printk (KERN_ERR MYNAM ": %s/%s: ERROR - Can't allocate skb! (%s@%d)\n", IOC_AND_NETDEV_NAMES_s_s(dev),
@@ -1006,7 +1006,7 @@ mpt_lan_receive_post_reply(struct net_device *dev,// "for single packet, concatenating...\n", // IOC_AND_NETDEV_NAMES_s_s(dev))); - skb = (struct sk_buff *)dev_alloc_skb (len); + skb =dev_alloc_skb (len);if (!skb) { printk (KERN_ERR MYNAM ": %s/%s: ERROR - Can't allocate skb! (%s@%d)\n", IOC_AND_NETDEV_NAMES_s_s(dev),
@@ -1048,7 +1048,7 @@ mpt_lan_receive_post_reply(struct net_device *dev, old_skb = skb; - skb = (struct sk_buff *)dev_alloc_skb (len); + skb =dev_alloc_skb (len);if (!skb) { printk (KERN_ERR MYNAM ": %s/%s: ERROR - Can't allocate skb! (%s@%d)\n", IOC_AND_NETDEV_NAMES_s_s(dev),
Signature · 6 lines
2.30.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 4 lines · Vinesh Raut
multiple
UNNECESSARY_CASTSwarnings fixed frommptlan.c
It is not good practice to cast alloc function as it may hide the bugs.
So what is casted here? from which type to which type?
Explain which type of bug here specifically would be hidden.
If you do that, it is much more comprehensible and clearer why this deserves to be addressed (or not).
Lukas
Quoted 38 lines
Suggested-by Lukas Bulwahn <[email protected]>Signed-off-by Vinesh Raut <[email protected]>--- drivers/message/fusion/mptlan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/message/fusion/mptlan.c +3
-4@@ -860,7 +860,7 @@ mpt_lan_receive_post_turbo(struct net_device *dev, u32 tmsg)if (len <MPT_LAN_RX_COPYBREAK ) { old_skb = skb; - skb = (struct sk_buff *)dev_alloc_skb (len); + skb =dev_alloc_skb (len);if (!skb) { printk (KERN_ERR MYNAM ": %s/%s: ERROR - Can't allocate skb! (%s@%d)\n", IOC_AND_NETDEV_NAMES_s_s(dev),@@ -1006,7 +1006,7 @@ mpt_lan_receive_post_reply(struct net_device *dev,// "for single packet, concatenating...\n", // IOC_AND_NETDEV_NAMES_s_s(dev))); - skb = (struct sk_buff *)dev_alloc_skb (len); + skb =dev_alloc_skb (len);if (!skb) { printk (KERN_ERR MYNAM ": %s/%s: ERROR - Can't allocate skb! (%s@%d)\n", IOC_AND_NETDEV_NAMES_s_s(dev),@@ -1048,7 +1048,7 @@ mpt_lan_receive_post_reply(struct net_device *dev, old_skb = skb; - skb = (struct sk_buff *)dev_alloc_skb (len); + skb =dev_alloc_skb (len);if (!skb) { printk (KERN_ERR MYNAM ": %s/%s: ERROR - Can't allocate skb! (%s@%d)\n", IOC_AND_NETDEV_NAMES_s_s(dev), --
Quoted 2 lines
2.30.2
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 6 lines · Lukas Bulwahn
Quoted 2 lines · Vinesh Raut
multiple
UNNECESSARY_CASTSwarnings fixed frommptlan.cSo what is casted here? from which type to which type?
From void pointer to struct sk_buff pointer.
Quoted 1 line
Explain which type of bug here specifically would be hidden.
If a pointer is cast (wrongly), bugs like memory corruption, segmentation faults can occur.
Also, It can affect functionality of the program.
Quoted 2 lines
If you do that, it is much more comprehensible and clearer why this deserves to be addressed (or not).
First , it is redundant. It will be difficult to debug. May hide Bugs if any due to
(wrongly) explicit casting
Regards,
-Vinesh Raut
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees