From patchwork Wed Jul 19 19:23:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 108313 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp1199347obm; Wed, 19 Jul 2017 12:24:12 -0700 (PDT) X-Received: by 10.99.110.67 with SMTP id j64mr1094477pgc.341.1500492252635; Wed, 19 Jul 2017 12:24:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500492252; cv=none; d=google.com; s=arc-20160816; b=x7CjtQQp8APv06idgspypZBepJM+/rj5gNj0Ao7ry1KoffA+KL3WaMMr8oY9gU82De 92opvaxfWd/fElXKJKRQgoXhbOQKQq5Ep7CMtliiqFrXYUHlTagqA5HNimnfzWz5jCRH 0quDFjddgZ2sFoaDOgIkeemY/6ssvQSsbIUMNXXkKOrRHbchlk/iUE6KbJ3cZ9YCsb/O qmdejdErt1eYDip6FYpdjmST41Pap/kH4/eN38ilCjUWvsygTqaPl6FKyFVmiKm/CsMj AE3lSxhc2nwFCXIqDfshSd0uHPtN2uLXU2tCuK0JthR/ynImMZb7qBBAuR7qBOObdPYh 4IrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=PVvyqoCgOdL/44Z8U/VHreFk9ecCvmnrsYGYjgU/gjw=; b=UX/qwEK/B9MX8g2yDDNarXc85BJTGlW6gkImN8X4j9m1MU4PhOLa4kpJYHpadB2Ux6 pQLxrwj77PJaZv8F4crupV9b4ORzn7cJmC4yslXmP5V+lGc6EQRO1yqU9jtawSkk8NFX iuKJtquftNr+P3Kij3x4SALSPjqZ9I88ZgU2zBXvTW8WM11ffPNxFYA76Aq4t6Fb+aPg aTy2Lc7JGsGlpCwY5pRJttlZUH8Po515IkgqwMyAfEnY+W0ALlJfUn7fwnLgcFsuyxtA eX5MLpJ/LENaXwRw2a9Row2BUm3nRPS0/QwMb5Hp0SLivGQSbdFi3Csdd6HNSWIuRW1T uhFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 126si436418pff.594.2017.07.19.12.24.12; Wed, 19 Jul 2017 12:24:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933040AbdGSTYK (ORCPT + 25 others); Wed, 19 Jul 2017 15:24:10 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:57234 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932714AbdGSTYH (ORCPT ); Wed, 19 Jul 2017 15:24:07 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0Lw10f-1dhQWW0Amr-017q96; Wed, 19 Jul 2017 21:23:41 +0200 From: Arnd Bergmann To: Mauro Carvalho Chehab Cc: Dan Carpenter , Arnd Bergmann , Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] [media] fix warning on v4l2_subdev_call() result interpreted as bool Date: Wed, 19 Jul 2017 21:23:27 +0200 Message-Id: <20170719192338.2671881-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:IqgcFS7XCeR0AtjnZJjhU66QMGwP+ieF2YxdCPPjQLkftAcw1Vz RBowYFLtbNt92jbnYaPSOyxttwTQJCEV5QWDJzTfHHzevhikvlTXaVXVumqoevzfmbpcXr7 yQru6qcwxQf4J8fCTSPCTEOaT6Q8xQcuBqCIa/zZpmKtvVXq2yzaX1DO7diUZRpjn0wHnui bRW5Hjnzjt8JVeUelxF4w== X-UI-Out-Filterresults: notjunk:1; V01:K0:F/EclRyEYXY=:jJlL/3DnCNpg2ZPR8SW/Ce XClbS6f5dr0ZUXkVT8WzEaQKuZ+uB40Gb4k0+cmoMmDu34K5yEbCKdpOHinrICNGM8UeLT27N CbwhLZQBQlEIfatPDBdIvxAbrRB/VvQsSzIuA8jVB1i1FWEuAR6ELYHX2P6sDO9fCA4diHCIV xEeybolLbZaisoHt/jSRTVffhf+Hv0UjyGzFhM/qeZVfX8QKvW9YFxK90DEbV4WsGbDKHK3jv ObdGc/hLrrWH465ruCRnvT3Co4F2Il0xnttoxzGi8fWGD7s/YzWhFlOSiSpRj7W0bbZzQMng4 LrGO2q55UgVU5EkhDYOoImJXcnHVzYUZmt18YzI5W3+O9egtur4D7917oF4zdlSVw8vI21YS3 Bp41Ng3zHPL9mcIHnWkevLc7FiJkx8SDbewvk/Hz5wc2S+yMT0YeqkBH/AbuobHKrDizzbZy2 z4Xh8/S2C2S9Ts1zMp0C4/0ae4FS7RJaSy2YpC1iSVRZLN+yBlgPN0PhCLhrwWgcIyl9IVyic FMoAglRLkeoCp2ROdio0G28XEoDbHn69QfycqbmPupkzA+ktZw/2bEeTJQqVpGInx8QJkKWan 6y89s8JZektlfQRJnaG/tcDND18st/G4SLByxyi2ZAxkY0DYWYYc01uU8+5P1PtHVONcQbl7A 5GPbyC8UY+nKhHS6kUSJub+WHxxdgicYFidH4SHtcr0+v8IWgKNgMk5NXWYxpcIxvLxWO6g/U BThAvKhQ7iLJwhEuz4P2nK82xz2VLQij+opVtA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org v4l2_subdev_call is a macro returning whatever the callback return type is, usually 'int'. With gcc-7 and ccache, this can lead to many wanings like: media/platform/pxa_camera.c: In function 'pxa_mbus_build_fmts_xlate': media/platform/pxa_camera.c:766:27: error: ?: using integer constants in boolean context [-Werror=int-in-bool-context] while (!v4l2_subdev_call(subdev, pad, enum_mbus_code, NULL, &code)) { media/atomisp/pci/atomisp2/atomisp_cmd.c: In function 'atomisp_s_ae_window': media/atomisp/pci/atomisp2/atomisp_cmd.c:6414:52: error: ?: using integer constants in boolean context [-Werror=int-in-bool-context] if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera, The problem here is that after preprocessing, we the compiler sees a variation of if (a ? 0 : 2) that it thinks is suspicious. This replaces the ?: operator with an different expression that does the same thing in a more easily readable way that cannot tigger the warning Link: https://lkml.org/lkml/2017/7/14/156 Signed-off-by: Arnd Bergmann --- v2: replace large patch touching all the users with a simpler change to the macro itself. --- include/media/v4l2-subdev.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.9.0 diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 0f92ebd2d710..e83872078376 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -982,8 +982,16 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, * Example: err = v4l2_subdev_call(sd, video, s_std, norm); */ #define v4l2_subdev_call(sd, o, f, args...) \ - (!(sd) ? -ENODEV : (((sd)->ops->o && (sd)->ops->o->f) ? \ - (sd)->ops->o->f((sd), ##args) : -ENOIOCTLCMD)) + ({ \ + int __result; \ + if (!(sd)) \ + __result = -ENODEV; \ + else if (!((sd)->ops->o && (sd)->ops->o->f)) \ + __result = -ENOIOCTLCMD; \ + else \ + __result = (sd)->ops->o->f((sd), ##args); \ + __result; \ + }) #define v4l2_subdev_has_op(sd, o, f) \ ((sd)->ops->o && (sd)->ops->o->f)