linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dpaa_eth: Fix comparing pointer to 0
@ 2020-04-27 10:32 Aishwarya Ramakrishnan
  2020-05-01  3:26 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Aishwarya Ramakrishnan @ 2020-04-27 10:32 UTC (permalink / raw)
  To: Madalin Bucur, David S. Miller, netdev, linux-kernel; +Cc: aishwaryarj100

Fixes coccicheck warning:
./drivers/net/ethernet/freescale/dpaa/dpaa_eth.c:2110:30-31:
WARNING comparing pointer to 0

Avoid pointer type value compared to 0.

Signed-off-by: Aishwarya Ramakrishnan <aishwaryarj100@gmail.com>
---
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index 2cd1f8efdfa3..c4416a5f8816 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -2107,7 +2107,7 @@ static int dpaa_a050385_wa(struct net_device *net_dev, struct sk_buff **s)
 
 	/* Workaround for DPAA_A050385 requires data start to be aligned */
 	start = PTR_ALIGN(new_skb->data, DPAA_A050385_ALIGN);
-	if (start - new_skb->data != 0)
+	if (start - new_skb->data)
 		skb_reserve(new_skb, start - new_skb->data);
 
 	skb_put(new_skb, skb->len);
-- 
2.17.1


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

* Re: [PATCH] dpaa_eth: Fix comparing pointer to 0
  2020-04-27 10:32 [PATCH] dpaa_eth: Fix comparing pointer to 0 Aishwarya Ramakrishnan
@ 2020-05-01  3:26 ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2020-05-01  3:26 UTC (permalink / raw)
  To: aishwaryarj100; +Cc: madalin.bucur, netdev, linux-kernel

From: Aishwarya Ramakrishnan <aishwaryarj100@gmail.com>
Date: Mon, 27 Apr 2020 16:02:30 +0530

> Fixes coccicheck warning:
> ./drivers/net/ethernet/freescale/dpaa/dpaa_eth.c:2110:30-31:
> WARNING comparing pointer to 0
> 
> Avoid pointer type value compared to 0.
> 
> Signed-off-by: Aishwarya Ramakrishnan <aishwaryarj100@gmail.com>

Applied, thanks.

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

* Re: [PATCH] dpaa_eth: Fix comparing pointer to 0
@ 2020-04-27 11:26 Markus Elfring
  0 siblings, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2020-04-27 11:26 UTC (permalink / raw)
  To: Aishwarya Ramakrishnan, netdev, Coccinelle
  Cc: linux-kernel, David S. Miller, Madalin Bucur

> Fixes coccicheck warning:
> ./drivers/net/ethernet/freescale/dpaa/dpaa_eth.c:2110:30-31:
> WARNING comparing pointer to 0

Such information is actually provided by a known script for
the semantic patch language.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/scripts/coccinelle/null/badzero.cocci


> Avoid pointer type value compared to 0.

But I suggest to reconsider corresponding software development consequences
also around mentioned implementation details.


…
> +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
> @@ -2107,7 +2107,7 @@ static int dpaa_a050385_wa(struct net_device *net_dev, struct sk_buff **s)
>  	start = PTR_ALIGN(new_skb->data, DPAA_A050385_ALIGN);
> -	if (start - new_skb->data != 0)
> +	if (start - new_skb->data)
>  		skb_reserve(new_skb, start - new_skb->data);
…


I interpret the source code in the way that a subtraction is performed
with two pointers. I would expect that such a pointer difference
has got an integral data type.
Will this view trigger any further software evolution?

Regards,
Markus

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

end of thread, other threads:[~2020-05-01  3:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-27 10:32 [PATCH] dpaa_eth: Fix comparing pointer to 0 Aishwarya Ramakrishnan
2020-05-01  3:26 ` David Miller
2020-04-27 11:26 Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).