diff mbox series

[-next] drivers: net: declance: fix comparing pointer to 0

Message ID 20200121013553.15252-1-chenzhou10@huawei.com
State Superseded
Delegated to: David Miller
Headers show
Series [-next] drivers: net: declance: fix comparing pointer to 0 | expand

Commit Message

chenzhou Jan. 21, 2020, 1:35 a.m. UTC
Fixes coccicheck warning:

./drivers/net/ethernet/amd/declance.c:611:14-15:
	WARNING comparing pointer to 0

Compare pointer-typed values to NULL rather than 0.

Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
---
 drivers/net/ethernet/amd/declance.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sergei Shtylyov Jan. 21, 2020, 8:39 a.m. UTC | #1
Hello!

On 21.01.2020 4:35, Chen Zhou wrote:

> Fixes coccicheck warning:
> 
> ./drivers/net/ethernet/amd/declance.c:611:14-15:
> 	WARNING comparing pointer to 0
> 
> Compare pointer-typed values to NULL rather than 0.

    I don't see NULL in the patch -- you used ! instead.

> Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
> ---
>   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 6592a2d..7282ce5 100644
> --- a/drivers/net/ethernet/amd/declance.c
> +++ b/drivers/net/ethernet/amd/declance.c
> @@ -608,7 +608,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) {
>   				dev->stats.rx_dropped++;
>   				*rds_ptr(rd, mblength, lp->type) = 0;
>   				*rds_ptr(rd, rmd1, lp->type) =

MBR, Sergei
chenzhou Jan. 21, 2020, 8:54 a.m. UTC | #2
Hi Sergei,

On 2020/1/21 16:39, Sergei Shtylyov wrote:
> Hello!
> 
> On 21.01.2020 4:35, Chen Zhou wrote:
> 
>> Fixes coccicheck warning:
>>
>> ./drivers/net/ethernet/amd/declance.c:611:14-15:
>>     WARNING comparing pointer to 0
>>
>> Compare pointer-typed values to NULL rather than 0.
> 
>    I don't see NULL in the patch -- you used ! instead.

Yeah, i used ! here.

Thanks,
Chen Zhou

> 
>> Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
>> ---
>>   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 6592a2d..7282ce5 100644
>> --- a/drivers/net/ethernet/amd/declance.c
>> +++ b/drivers/net/ethernet/amd/declance.c
>> @@ -608,7 +608,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) {
>>                   dev->stats.rx_dropped++;
>>                   *rds_ptr(rd, mblength, lp->type) = 0;
>>                   *rds_ptr(rd, rmd1, lp->type) =
> 
> MBR, Sergei
> 
>
Sergei Shtylyov Jan. 21, 2020, 9:01 a.m. UTC | #3
On 21.01.2020 11:54, Chen Zhou wrote:

>>> Fixes coccicheck warning:
>>>
>>> ./drivers/net/ethernet/amd/declance.c:611:14-15:
>>>      WARNING comparing pointer to 0
>>>
>>> Compare pointer-typed values to NULL rather than 0.
>>
>>     I don't see NULL in the patch -- you used ! instead.
> 
> Yeah, i used ! here.

    Make the patch description match the diff, please.

> Thanks,
> Chen Zhou

MBR, Sergei
chenzhou Jan. 21, 2020, 9:18 a.m. UTC | #4
On 2020/1/21 17:01, Sergei Shtylyov wrote:
> On 21.01.2020 11:54, Chen Zhou wrote:
> 
>>>> Fixes coccicheck warning:
>>>>
>>>> ./drivers/net/ethernet/amd/declance.c:611:14-15:
>>>>      WARNING comparing pointer to 0
>>>>
>>>> Compare pointer-typed values to NULL rather than 0.
>>>
>>>     I don't see NULL in the patch -- you used ! instead.
>>
>> Yeah, i used ! here.
> 
>    Make the patch description match the diff, please.

ok, i will fix this in next version.

Thanks,
Chen Zhou

> 
>> Thanks,
>> Chen Zhou
> 
> MBR, Sergei
> 
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/amd/declance.c b/drivers/net/ethernet/amd/declance.c
index 6592a2d..7282ce5 100644
--- a/drivers/net/ethernet/amd/declance.c
+++ b/drivers/net/ethernet/amd/declance.c
@@ -608,7 +608,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) {
 				dev->stats.rx_dropped++;
 				*rds_ptr(rd, mblength, lp->type) = 0;
 				*rds_ptr(rd, rmd1, lp->type) =