Re: [PATCH] dpaa_eth: Fix comparing pointer to 0
From: Markus Elfring
Date: Mon Apr 27 2020 - 07:27:07 EST
> 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