Thread (3 messages) flat view 3 messages, 2 authors, 2021-08-21

Re: [PATCH] mptlan.c: fixed UNNECESSARY_CASTS warning

From: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Date: 2021-08-20 10:00:53

On Thu, Aug 5, 2021 at 1:12 PM Vinesh Raut [off-list ref] wrote:
multiple UNNECESSARY_CASTS warnings fixed from mptlan.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 hunk ↗ jump to hunk
Suggested-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Vinesh Raut <redacted>
---
 drivers/message/fusion/mptlan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c
index 3261cac762de..f45e7a25e7c3 100644
--- a/drivers/message/fusion/mptlan.c
+++ b/drivers/message/fusion/mptlan.c
@@ -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),
--
2.30.2
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help