All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mptlan.c: fixed UNNECESSARY_CASTS warning
@ 2021-08-05 11:12 Vinesh Raut
  2021-08-20 10:00 ` Lukas Bulwahn
  0 siblings, 1 reply; 3+ messages in thread
From: Vinesh Raut @ 2021-08-05 11:12 UTC (permalink / raw)
  To: lukas.bulwahn; +Cc: dwaipayanray1, linux-kernel-mentees

multiple UNNECESSARY_CASTS warnings fixed from mptlan.c
It is not good practice to cast alloc function as it may hide the bugs.

Suggested-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Vinesh Raut <vineshraut2017@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

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mptlan.c: fixed UNNECESSARY_CASTS warning
  2021-08-05 11:12 [PATCH] mptlan.c: fixed UNNECESSARY_CASTS warning Vinesh Raut
@ 2021-08-20 10:00 ` Lukas Bulwahn
  2021-08-21 17:33   ` Vinesh Vilas Raut
  0 siblings, 1 reply; 3+ messages in thread
From: Lukas Bulwahn @ 2021-08-20 10:00 UTC (permalink / raw)
  To: Vinesh Raut; +Cc: Dwaipayan Ray, linux-kernel-mentees

On Thu, Aug 5, 2021 at 1:12 PM Vinesh Raut <vineshraut2017@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@gmail.com>
> Signed-off-by: Vinesh Raut <vineshraut2017@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
>
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mptlan.c: fixed UNNECESSARY_CASTS warning
  2021-08-20 10:00 ` Lukas Bulwahn
@ 2021-08-21 17:33   ` Vinesh Vilas Raut
  0 siblings, 0 replies; 3+ messages in thread
From: Vinesh Vilas Raut @ 2021-08-21 17:33 UTC (permalink / raw)
  To: Lukas Bulwahn; +Cc: Dwaipayan Ray, linux-kernel-mentees

On Fri, Aug 20, 2021 at 3:30 PM Lukas Bulwahn <lukas.bulwahn@gmail.com> wrote:
>
> On Thu, Aug 5, 2021 at 1:12 PM Vinesh Raut <vineshraut2017@gmail.com> wrote:
> >
> > multiple UNNECESSARY_CASTS warnings fixed from mptlan.c

> So what is casted here? from which type to which type?
From void pointer to struct sk_buff  pointer.

> 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.

> 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
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-21 17:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-05 11:12 [PATCH] mptlan.c: fixed UNNECESSARY_CASTS warning Vinesh Raut
2021-08-20 10:00 ` Lukas Bulwahn
2021-08-21 17:33   ` Vinesh Vilas Raut

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.