From: Andrew Morton <akpm@linux-foundation.org>
To: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Cc: linux-kernel@vger.kernel.org, Abaci Robot <abaci@linux.alibaba.com>
Subject: Re: [PATCH] XArray tests: Compare pointers to NULL instead of 0
Date: Fri, 24 May 2024 13:07:48 -0700 [thread overview]
Message-ID: <20240524130748.cdac446bb90f75fee5ffe47f@linux-foundation.org> (raw)
In-Reply-To: <20240524071655.31386-1-jiapeng.chong@linux.alibaba.com>
On Fri, 24 May 2024 15:16:55 +0800 Jiapeng Chong <jiapeng.chong@linux.alibaba.com> wrote:
> Avoid pointer type value compared with 0 to make code clear.
>
> ./lib/test_xarray.c:973:52-53: WARNING comparing pointer to 0
>
> ...
>
> --- a/lib/test_xarray.c
> +++ b/lib/test_xarray.c
> @@ -975,7 +975,7 @@ static noinline void check_xa_alloc_1(struct xarray *xa, unsigned int base)
>
> XA_BUG_ON(xa, xa_alloc(xa, &id, xa_mk_index(10), XA_LIMIT(10, 5),
> GFP_KERNEL) != -EBUSY);
> - XA_BUG_ON(xa, xa_store_index(xa, 3, GFP_KERNEL) != 0);
> + XA_BUG_ON(xa, NULL != xa_store_index(xa, 3, GFP_KERNEL));
> XA_BUG_ON(xa, xa_alloc(xa, &id, xa_mk_index(10), XA_LIMIT(10, 5),
> GFP_KERNEL) != -EBUSY);
> xa_erase_index(xa, 3);
Thanks, but we avoid the (0 != expression) trick in the kernel.
And as far as I understand, it's used to prevent people from
accidentally using = where they meant == so isn't applicable to !=
anyway.
prev parent reply other threads:[~2024-05-24 20:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-24 7:16 [PATCH] XArray tests: Compare pointers to NULL instead of 0 Jiapeng Chong
2024-05-24 20:07 ` Andrew Morton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240524130748.cdac446bb90f75fee5ffe47f@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=abaci@linux.alibaba.com \
--cc=jiapeng.chong@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox