2018-08-17 13:32:15

by zhong jiang

[permalink] [raw]
Subject: [PATCH 0/2] ethernet: Use NULL to compare with pointer-typed value rather than 0


zhong jiang (2):
ethernet: declance: Use NULL to compare with pointer-typed value
rather than 0
ethernet: lpc_eth: Use NULL to compare with pointer-typed value
rather than 0

drivers/net/ethernet/amd/declance.c | 2 +-
drivers/net/ethernet/nxp/lpc_eth.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

--
1.7.12.4



2018-08-17 13:32:27

by zhong jiang

[permalink] [raw]
Subject: [PATCH 2/2] ethernet: lpc_eth: Use NULL to compare with pointer-typed value rather than 0

We should use NULL to compare with pointer-typed value rather than 0.
The issue is detected with the help of Coccinelle.
---
drivers/net/ethernet/nxp/lpc_eth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
index 08381ef..04d9e62 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -1350,7 +1350,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
"IRAM not big enough for net buffers, using SDRAM instead.\n");
}

- if (pldat->dma_buff_base_v == 0) {
+ if (pldat->dma_buff_base_v == NULL) {
ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
if (ret)
goto err_out_free_irq;
--
1.7.12.4


2018-08-17 13:33:18

by zhong jiang

[permalink] [raw]
Subject: [PATCH 1/2] ethernet: declance: Use NULL to compare with pointer-typed value rather than 0

We should use NULL to compare with pointer-typed value rather than
0. The issue is detected with the help of Coccinelle.
---
drivers/net/ethernet/amd/declance.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/amd/declance.c b/drivers/net/ethernet/amd/declance.c
index 116997a..6e035df 100644
--- a/drivers/net/ethernet/amd/declance.c
+++ b/drivers/net/ethernet/amd/declance.c
@@ -607,7 +607,7 @@ static int lance_rx(struct net_device *dev)
len = (*rds_ptr(rd, mblength, lp->type) & 0xfff) - 4;
skb = netdev_alloc_skb(dev, len + 2);

- if (skb == 0) {
+ if (skb == NULL) {
dev->stats.rx_dropped++;
*rds_ptr(rd, mblength, lp->type) = 0;
*rds_ptr(rd, rmd1, lp->type) =
--
1.7.12.4


2018-08-17 15:30:23

by Vladimir Zapolskiy

[permalink] [raw]
Subject: Re: [PATCH 2/2] ethernet: lpc_eth: Use NULL to compare with pointer-typed value rather than 0

Hi zhong jiang,

On 08/17/2018 04:18 PM, zhong jiang wrote:
> We should use NULL to compare with pointer-typed value rather than 0.
> The issue is detected with the help of Coccinelle.
> ---
> drivers/net/ethernet/nxp/lpc_eth.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
> index 08381ef..04d9e62 100644
> --- a/drivers/net/ethernet/nxp/lpc_eth.c
> +++ b/drivers/net/ethernet/nxp/lpc_eth.c
> @@ -1350,7 +1350,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
> "IRAM not big enough for net buffers, using SDRAM instead.\n");
> }
>
> - if (pldat->dma_buff_base_v == 0) {
> + if (pldat->dma_buff_base_v == NULL) {

That's a valid finding, but please use a common 0 and NULL comparison in form of

if (!pldat->dma_buff_base_v)

To the change above please feel free to add my

Acked-by: Vladimir Zapolskiy <[email protected]>

> ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> if (ret)
> goto err_out_free_irq;
>


2018-08-18 06:01:00

by zhong jiang

[permalink] [raw]
Subject: Re: [PATCH 2/2] ethernet: lpc_eth: Use NULL to compare with pointer-typed value rather than 0

On 2018/8/17 23:29, Vladimir Zapolskiy wrote:
> Hi zhong jiang,
>
> On 08/17/2018 04:18 PM, zhong jiang wrote:
>> We should use NULL to compare with pointer-typed value rather than 0.
>> The issue is detected with the help of Coccinelle.
>> ---
>> drivers/net/ethernet/nxp/lpc_eth.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
>> index 08381ef..04d9e62 100644
>> --- a/drivers/net/ethernet/nxp/lpc_eth.c
>> +++ b/drivers/net/ethernet/nxp/lpc_eth.c
>> @@ -1350,7 +1350,7 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
>> "IRAM not big enough for net buffers, using SDRAM instead.\n");
>> }
>>
>> - if (pldat->dma_buff_base_v == 0) {
>> + if (pldat->dma_buff_base_v == NULL) {
> That's a valid finding, but please use a common 0 and NULL comparison in form of
>
> if (!pldat->dma_buff_base_v)
>
> To the change above please feel free to add my
>
> Acked-by: Vladimir Zapolskiy <[email protected]>
Thanks, Will do in v2
>> ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
>> if (ret)
>> goto err_out_free_irq;
>>
>
> .
>