* [PATCH] XArray tests: Compare pointers to NULL instead of 0
@ 2024-05-24 7:16 Jiapeng Chong
2024-05-24 20:07 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2024-05-24 7:16 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Jiapeng Chong, Abaci Robot
Avoid pointer type value compared with 0 to make code clear.
./lib/test_xarray.c:973:52-53: WARNING comparing pointer to 0
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9169
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
lib/test_xarray.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/test_xarray.c b/lib/test_xarray.c
index ab9cc42a0d74..a281436267ce 100644
--- 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);
--
2.20.1.7.g153144c
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] XArray tests: Compare pointers to NULL instead of 0
2024-05-24 7:16 [PATCH] XArray tests: Compare pointers to NULL instead of 0 Jiapeng Chong
@ 2024-05-24 20:07 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2024-05-24 20:07 UTC (permalink / raw)
To: Jiapeng Chong; +Cc: linux-kernel, Abaci Robot
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-24 20:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox