From patchwork Wed Sep 6 13:45:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9940775 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 70E8C6038C for ; Wed, 6 Sep 2017 13:46:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55E6728BD5 for ; Wed, 6 Sep 2017 13:46:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A7F328BF0; Wed, 6 Sep 2017 13:46:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBF9028BD5 for ; Wed, 6 Sep 2017 13:46:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932180AbdIFNqZ (ORCPT ); Wed, 6 Sep 2017 09:46:25 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:64403 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932115AbdIFNqY (ORCPT ); Wed, 6 Sep 2017 09:46:24 -0400 Received: from wuerfel.lan ([95.208.190.237]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0MKyv2-1dpaeW3BvU-0007t4; Wed, 06 Sep 2017 15:46:00 +0200 From: Arnd Bergmann To: Doug Ledford , Sean Hefty , Hal Rosenstock Cc: Arnd Bergmann , Matan Barak , Yishai Hadas , Leon Romanovsky , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [RESEND] IB/uverbs: fix gcc-7 type warning Date: Wed, 6 Sep 2017 15:45:31 +0200 Message-Id: <20170906134558.3279199-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:3iiogugOjtfEJ2MZBpVqoDamXR+iyGuQgPuaX7AK6cUWFYN1esg orDNVXKV39gRLwD4dVcI9Cj8ZmE0bbJUE0aS3NWn3JZ4GtZnvnXL+NTdjS7F1+lCnSoI4Iv ia3uoLsN/OuVXsVypGN8YWYfuq1O85xeZb6Pw/71bdTONwL9BNXLOBMvGvNpU3fTxStPq8T yBRoF/c6OXgYPsBsEMGYA== X-UI-Out-Filterresults: notjunk:1; V01:K0:a+fXtguPk3A=:WF3liYWuuLC5OkAcbC6yCF lo1hP0Q0DCTfmpl9ia8YjU2+s4o8OTcMtFToplAX9wofNOLi7yXn5qS7i82fDdidaeuEzzL4D 6G+qVDzBZDCsOtOqsy7jOTj5SvturauyvcwWhY/lMjb8VnHhF2edRL30Cro8NACuEJ50a4zPE 35arhTab1sT2gJygohBplocPrfa+Wh2yqmC8YXMIsyBSjo61YPOyckxt3lAV+wSqYxPvqb3cg YeRk9wigX3woUH+Gkxl5fPLERrV11eks6sjL0WjEfpc1tt3Y55LSgaTZfdM1oLfk3nghOgjsf svbMD6AUtPT3ssP1YZmtaoneEvzIQu5wpWtMRyp/L0W9zJ6ohzsK68QXJYjEp/lYGTavEBU7D enDGUEjGZOxubxUj1Rv+ZvXbA+t2dW/I8fnhwvlJw8c3sTvNqFKGpx3mozY7SSSOLAMcbCjwn Px5ffaBwNoagk+0x935wgJFsa0RF2EhrRwMkqP6mUEZ7HYaPftp8wdwPFZEWTuRQG3TieNJar Rw2H0cBaK0AHtWwjC9ModJc6S9/obdl7QYFJtUA03pt9aF+hjBBP5PDVyqsa0a08QZtGns44c sk2r2ITFk9G8DsbQrvVHZW7OpEhlB+z3w2b92ryLp98XLBy1pJCDpV+P18J2YuuCbiSK9EZJg G4UB5YWFF4GnYrIKR78LrynEHEUF/UFO80zzAU7UiKdtO8lolYWAnnGwTEq994AbGU1p+CFq0 riC7GlD3AU0YPKSqvV9pL51D/QGBZsNGjQkmCQ== Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Arnd Bergmann --- 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) /*