public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [RESEND] IB/uverbs: fix gcc-7 type warning
@ 2017-09-06 13:45 Arnd Bergmann
       [not found] ` <20170906134558.3279199-1-arnd-r2nGTMty4D4@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2017-09-06 13:45 UTC (permalink / raw)
  To: Doug Ledford, Sean Hefty, Hal Rosenstock
  Cc: Arnd Bergmann, Matan Barak, Yishai Hadas, Leon Romanovsky,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

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()")
Reviewed-by: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
---
Originally submitted on July 14, but this patch is still pending.
I modified the change text this time, as the first version incorrectly
stated that it only happens with ccache.
---
 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 37c8903e7fd0..986a8a66ebbe 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

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] [RESEND] IB/uverbs: fix gcc-7 type warning
       [not found] ` <20170906134558.3279199-1-arnd-r2nGTMty4D4@public.gmane.org>
@ 2017-09-06 13:58   ` Christoph Hellwig
       [not found]     ` <20170906135812.GA1213-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2017-09-06 13:58 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, Matan Barak,
	Yishai Hadas, Leon Romanovsky, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Wed, Sep 06, 2017 at 03:45:31PM +0200, Arnd Bergmann wrote:
> We get a harmless warning about the fact that we use the result of a
> multiplication as a condition:

Please just turn the thing into a function while you're at it.
I'm not even sure it needs to be inline..
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [RESEND] IB/uverbs: fix gcc-7 type warning
       [not found]     ` <20170906135812.GA1213-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
@ 2017-09-06 20:43       ` Arnd Bergmann
  0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2017-09-06 20:43 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, Matan Barak,
	Yishai Hadas, Leon Romanovsky, linux-rdma,
	Linux Kernel Mailing List

On Wed, Sep 6, 2017 at 3:58 PM, Christoph Hellwig <hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org> wrote:
> On Wed, Sep 06, 2017 at 03:45:31PM +0200, Arnd Bergmann wrote:
>> We get a harmless warning about the fact that we use the result of a
>> multiplication as a condition:
>
> Please just turn the thing into a function while you're at it.
> I'm not even sure it needs to be inline..

Ok, the patch gets quite big once I also modify INIT_UDATA the same way,
but it seems like a good cleanup anyway. INIT_UDATA (renamed to
ib_uverbs_init_udata()) should definitely remain inline, so I'm leaving
both that way.

        Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-06 20:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-06 13:45 [PATCH] [RESEND] IB/uverbs: fix gcc-7 type warning Arnd Bergmann
     [not found] ` <20170906134558.3279199-1-arnd-r2nGTMty4D4@public.gmane.org>
2017-09-06 13:58   ` Christoph Hellwig
     [not found]     ` <20170906135812.GA1213-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2017-09-06 20:43       ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox