[PATCH] mptlan.c: fixed UNNECESSARY_CASTS warning

Lukas Bulwahn lukas.bulwahn at gmail.com
Fri Aug 20 10:00:43 UTC 2021


On Thu, Aug 5, 2021 at 1:12 PM Vinesh Raut <vineshraut2017 at gmail.com> 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
> Suggested-by: Lukas Bulwahn <lukas.bulwahn at gmail.com>
> Signed-off-by: Vinesh Raut <vineshraut2017 at gmail.com>
> ---
>  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
>


More information about the Linux-kernel-mentees mailing list