* [PATCH 11/14] IB/uverbs: fix gcc-7 type warning
[not found] <20170714092540.1217397-1-arnd@arndb.de>
@ 2017-07-14 9:31 ` Arnd Bergmann
2017-07-14 9:46 ` Leon Romanovsky
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2017-07-14 9:31 UTC (permalink / raw)
To: linux-kernel, Doug Ledford, Sean Hefty, Hal Rosenstock
Cc: Leon Romanovsky, Arnd Bergmann, linux-rdma, Greg Kroah-Hartman,
Yishai Hadas, Matan Barak, dri-devel, linux-ide, Tejun Heo, akpm,
Linus Torvalds, Guenter Roeck, linux-media
When using ccache, we get a harmless warning about the fact that
we use the result of a multiplication as a condition:
drivers/infiniband/core/uverbs_main.c: In function 'ib_uverbs_write':
drivers/infiniband/core/uverbs_main.c:787:40: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
drivers/infiniband/core/uverbs_main.c:787:117: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
drivers/infiniband/core/uverbs_main.c:790:50: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
drivers/infiniband/core/uverbs_main.c:790:151: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
This changes the macro to explicitly check the number for a positive
length, which avoids the warning.
Fixes: a96e4e2ffe43 ("IB/uverbs: New macro to set pointers to NULL if length is 0 in INIT_UDATA()")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/infiniband/core/uverbs.h | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
index 64d494a64daf..364d7de05721 100644
--- a/drivers/infiniband/core/uverbs.h
+++ b/drivers/infiniband/core/uverbs.h
@@ -55,12 +55,14 @@
(udata)->outlen = (olen); \
} while (0)
-#define INIT_UDATA_BUF_OR_NULL(udata, ibuf, obuf, ilen, olen) \
- do { \
- (udata)->inbuf = (ilen) ? (const void __user *) (ibuf) : NULL; \
- (udata)->outbuf = (olen) ? (void __user *) (obuf) : NULL; \
- (udata)->inlen = (ilen); \
- (udata)->outlen = (olen); \
+#define INIT_UDATA_BUF_OR_NULL(udata, ibuf, obuf, ilen, olen) \
+ do { \
+ (udata)->inbuf = (ilen) > 0 ? \
+ (const void __user *) (ibuf) : NULL; \
+ (udata)->outbuf = (olen) > 0 ? \
+ (void __user *) (obuf) : NULL; \
+ (udata)->inlen = (ilen); \
+ (udata)->outlen = (olen); \
} while (0)
/*
--
2.9.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 11/14] IB/uverbs: fix gcc-7 type warning
2017-07-14 9:31 ` [PATCH 11/14] IB/uverbs: fix gcc-7 type warning Arnd Bergmann
@ 2017-07-14 9:46 ` Leon Romanovsky
0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2017-07-14 9:46 UTC (permalink / raw)
To: Arnd Bergmann
Cc: linux-kernel, Doug Ledford, Sean Hefty, Hal Rosenstock,
Greg Kroah-Hartman, Linus Torvalds, Tejun Heo, Guenter Roeck,
linux-ide, linux-media, akpm, dri-devel, Matan Barak,
Yishai Hadas, linux-rdma
[-- Attachment #1: Type: text/plain, Size: 1217 bytes --]
On Fri, Jul 14, 2017 at 11:31:04AM +0200, Arnd Bergmann wrote:
> When using ccache, we get a harmless warning about the fact that
> we use the result of a multiplication as a condition:
>
> drivers/infiniband/core/uverbs_main.c: In function 'ib_uverbs_write':
> drivers/infiniband/core/uverbs_main.c:787:40: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
> drivers/infiniband/core/uverbs_main.c:787:117: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
> drivers/infiniband/core/uverbs_main.c:790:50: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
> drivers/infiniband/core/uverbs_main.c:790:151: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
>
> This changes the macro to explicitly check the number for a positive
> length, which avoids the warning.
>
> Fixes: a96e4e2ffe43 ("IB/uverbs: New macro to set pointers to NULL if length is 0 in INIT_UDATA()")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/infiniband/core/uverbs.h | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-07-14 9:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20170714092540.1217397-1-arnd@arndb.de>
2017-07-14 9:31 ` [PATCH 11/14] IB/uverbs: fix gcc-7 type warning Arnd Bergmann
2017-07-14 9:46 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox