macintosh: Fix warning comparing pointer to 0

Message ID c31207c.c3.1844d85a6aa.Coremail.wangkailong@jari.cn
State New
Headers
Series macintosh: Fix warning comparing pointer to 0 |

Commit Message

KaiLong Wang Nov. 6, 2022, 3:18 p.m. UTC
  Fix the following coccicheck warning:

drivers/macintosh/macio-adb.c:103:13-14: WARNING comparing pointer to 0.

Signed-off-by: KaiLong Wang <wangkailong@jari.cn>
---
 drivers/macintosh/macio-adb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Christophe JAILLET Nov. 6, 2022, 4:08 p.m. UTC | #1
Le 06/11/2022 à 16:18, wangkailong@jari.cn a écrit :
> Fix the following coccicheck warning:
> 
> drivers/macintosh/macio-adb.c:103:13-14: WARNING comparing pointer to 0.
> 
> Signed-off-by: KaiLong Wang <wangkailong@jari.cn>
> ---
>   drivers/macintosh/macio-adb.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/macintosh/macio-adb.c b/drivers/macintosh/macio-adb.c
> index 9b63bd2551c6..1c1c375a817d 100644
> --- a/drivers/macintosh/macio-adb.c
> +++ b/drivers/macintosh/macio-adb.c
> @@ -100,7 +100,7 @@ int macio_init(void)
>   	unsigned int irq;
>   
>   	adbs = of_find_compatible_node(NULL, "adb", "chrp,adb0");
> -	if (adbs == 0)
> +	if (adbs)

Hi
no, this should be "if (!adbs)"

CJ

>   		return -ENXIO;
>   
>   	if (of_address_to_resource(adbs, 0, &r)) {
  
Christophe Leroy Nov. 6, 2022, 5:13 p.m. UTC | #2
Le 06/11/2022 à 17:08, Christophe JAILLET a écrit :
> Le 06/11/2022 à 16:18, wangkailong@jari.cn a écrit :
>> Fix the following coccicheck warning:
>>
>> drivers/macintosh/macio-adb.c:103:13-14: WARNING comparing pointer to 0.
>>
>> Signed-off-by: KaiLong Wang <wangkailong@jari.cn>

We already have such patches awaiting for application, see 
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?submitter=83647

Please check patchwork before submitting such fixes as they may already 
exist.

Thanks
Christophe


>> ---
>>   drivers/macintosh/macio-adb.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/macintosh/macio-adb.c 
>> b/drivers/macintosh/macio-adb.c
>> index 9b63bd2551c6..1c1c375a817d 100644
>> --- a/drivers/macintosh/macio-adb.c
>> +++ b/drivers/macintosh/macio-adb.c
>> @@ -100,7 +100,7 @@ int macio_init(void)
>>       unsigned int irq;
>>       adbs = of_find_compatible_node(NULL, "adb", "chrp,adb0");
>> -    if (adbs == 0)
>> +    if (adbs)
> 
> Hi
> no, this should be "if (!adbs)"
> 
> CJ
> 
>>           return -ENXIO;
>>       if (of_address_to_resource(adbs, 0, &r)) {
>
  

Patch

diff --git a/drivers/macintosh/macio-adb.c b/drivers/macintosh/macio-adb.c
index 9b63bd2551c6..1c1c375a817d 100644
--- a/drivers/macintosh/macio-adb.c
+++ b/drivers/macintosh/macio-adb.c
@@ -100,7 +100,7 @@  int macio_init(void)
 	unsigned int irq;
 
 	adbs = of_find_compatible_node(NULL, "adb", "chrp,adb0");
-	if (adbs == 0)
+	if (adbs)
 		return -ENXIO;
 
 	if (of_address_to_resource(adbs, 0, &r)) {