diff mbox series

macintosh/adb: Fix warning comparing pointer to 0

Message ID 2ef267c.c4.1844d8ef2d8.Coremail.wangkailong@jari.cn (mailing list archive)
State Rejected, archived
Headers show
Series macintosh/adb: Fix warning comparing pointer to 0 | expand

Checks

Context Check Description
snowpatch_ozlabs/github-powerpc_sparse success Successfully ran 4 jobs.
snowpatch_ozlabs/github-powerpc_clang success Successfully ran 6 jobs.
snowpatch_ozlabs/github-powerpc_kernel_qemu fail boot (g5_defconfig, g5, qemu-system-ppc64 openbios-ppc, ppc64-rootfs.cpio.gz, korg-5.5.0, fedora-34) failed at step Run qemu-g5 with fedora-34 build kernel.

Commit Message

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

drivers/macintosh/adb.c:676:14-15: WARNING comparing pointer to 0.

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

Comments

Christophe JAILLET Nov. 6, 2022, 4:12 p.m. UTC | #1
Le 06/11/2022 à 16:28, wangkailong@jari.cn a écrit :
> Fix the following coccicheck warning:
> 
> drivers/macintosh/adb.c:676:14-15: WARNING comparing pointer to 0.
> 
> Signed-off-by: KaiLong Wang <wangkailong@jari.cn>
> ---
>   drivers/macintosh/adb.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
> index 1bbb9ca08d40..076253599bd4 100644
> --- a/drivers/macintosh/adb.c
> +++ b/drivers/macintosh/adb.c
> @@ -673,7 +673,7 @@ static int adb_open(struct inode *inode, struct file *file)
>   		goto out;
>   	}
>   	state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL);
> -	if (state == 0) {
> +	if (state) {

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

CJ

>   		ret = -ENOMEM;
>   		goto out;
>   	}
Christophe Leroy Nov. 6, 2022, 5:13 p.m. UTC | #2
Le 06/11/2022 à 17:12, Christophe JAILLET a écrit :
> Le 06/11/2022 à 16:28, wangkailong@jari.cn a écrit :
>> Fix the following coccicheck warning:
>>
>> drivers/macintosh/adb.c:676:14-15: 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/adb.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
>> index 1bbb9ca08d40..076253599bd4 100644
>> --- a/drivers/macintosh/adb.c
>> +++ b/drivers/macintosh/adb.c
>> @@ -673,7 +673,7 @@ static int adb_open(struct inode *inode, struct 
>> file *file)
>>           goto out;
>>       }
>>       state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL);
>> -    if (state == 0) {
>> +    if (state) {
> 
> Hi
> no, this should be "if (!state)"
> 
> CJ
> 
>>           ret = -ENOMEM;
>>           goto out;
>>       }
>
diff mbox series

Patch

diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index 1bbb9ca08d40..076253599bd4 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -673,7 +673,7 @@  static int adb_open(struct inode *inode, struct file *file)
 		goto out;
 	}
 	state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL);
-	if (state == 0) {
+	if (state) {
 		ret = -ENOMEM;
 		goto out;
 	}