From patchwork Wed Mar 29 21:12:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9652609 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 8B6D2602C8 for ; Wed, 29 Mar 2017 21:13:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E1322855D for ; Wed, 29 Mar 2017 21:13:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7101928564; Wed, 29 Mar 2017 21:13:26 +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.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable 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 2089A2855D for ; Wed, 29 Mar 2017 21:13:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932906AbdC2VNP (ORCPT ); Wed, 29 Mar 2017 17:13:15 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:57246 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932715AbdC2VNN (ORCPT ); Wed, 29 Mar 2017 17:13:13 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.129]) with ESMTPA (Nemesis) id 0Lbf3v-1cRfj13zid-00lA2J; Wed, 29 Mar 2017 23:12:57 +0200 From: Arnd Bergmann To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Alan Cox Cc: Arnd Bergmann , Varsha Rao , Colin Ian King , =?UTF-8?q?J=C3=A9r=C3=A9my=20Lefaure?= , sayli karnik , linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] staging: atomisp: avoid false-positive maybe-uninitialized warning Date: Wed, 29 Mar 2017 23:12:21 +0200 Message-Id: <20170329211248.2617903-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:0haFMF2zBFGQOZcwUDhCq95PCkm/RbHW777FDnvtJRKeyuqZ9+o w7em3v4YbaasnRdcaPyTqJtvocqleTBg5XDGxtELwJgPArNy31jbr9EZNhD0KFve+7mFIGS UBKJKam6QHwVHg7IRv9CZczxvylwyipYMnLSjoIvaEMewUFy5zMBSwpiDrJZd5sOTE/0bme TuG0NoGHZuDdWTMGjBIoA== X-UI-Out-Filterresults: notjunk:1; V01:K0:z9v9KJNlAt4=:YkO6XcnPK8WS6JJYzZx/ST CVCVgTp61Vdyzia3DXgVbLH8wWXkpHiE8DZFD/iEVMkNABD+ao4RT5LuM77i5EnHIJlUgK37+ rbxpg2a7zBi58Fp5QQVNDALo5li/NhGRpb0buAOi42N5SV+VaDEPfF9Pfu2Yi7IRk1vm6Y+EN T3uS5M8lvDO6FEN//sFmepCITaFjup9/M7s1B0ZahH1YQIXGrHlKMZOpXiUHi72SRJ42vEraF mR/va8kAN4Aor6jvsA1EOQCFEZfUPVSN9n65CU4mX/i7vsUU6/oHdIJoUgMXDjUYlyTcumJWI qmYUHgvGAQW174zCOBW328vfKVel39FDqXpn53bK//1m/wcMg25RzSq0dgMrTOoYxqLYC8Fad xv9mNuy4zRfPGNovI4U5msFDeDHlc7h2iB2o2eS8jd4SF2FNacXgC8qghYHvxTda+bvppcGwF FkFqRK0bE7q2S/OqldkOs/8kTnm9IYeYVRYRmr7jV5TRqk0LISVyxtxN7wD7KCQpAwIYchZ/x 7yuil791kREjXwBTABjGBtE0j2v3h6cBtzmYRVGyRFCMAOuIf9/rJruL8kLS2tQacMoTt1Jlh 6eDdzZmWyftPq8NCpL96LMqq4dzs00SbPfeYlu4eLbqu1J0FpQNDJRrKUcx/czvgzHD6mmaq8 M8X/fNjEjOmKmT9O7a4Nydsi1xTU6ZZxMv+E2A0LbdroS/ZpIEUnIkqc3n7VCR1Fv1XQ= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In combination with CONFIG_PROFILE_ANNOTATED_BRANCHES=y, the unlikely() inside of the WARN() macro becomes too complex for gcc to see that we don't use the output arguments of mt9m114_to_res() are used correctly: drivers/staging/media/atomisp/i2c/mt9m114.c: In function 'mt9m114_get_fmt': drivers/staging/media/atomisp/i2c/mt9m114.c:817:13: error: 'height' may be used uninitialized in this function [-Werror=maybe-uninitialized] int width, height; ^~~~~~ drivers/staging/media/atomisp/i2c/mt9m114.c: In function 'mt9m114_s_exposure_selection': drivers/staging/media/atomisp/i2c/mt9m114.c:1179:13: error: 'height' may be used uninitialized in this function [-Werror=maybe-uninitialized] Without WARN_ON(), there is no problem, so by simply replacing it with v4l2_err(), the warnings go away. The WARN() output is also not needed here, as we'd probably catch the problem before even getting here, and other checks for the same condition already use v4l2_err. Signed-off-by: Arnd Bergmann --- v2: fix new build regression found by 0day kbuild bot --- drivers/staging/media/atomisp/i2c/mt9m114.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/mt9m114.c b/drivers/staging/media/atomisp/i2c/mt9m114.c index c4f4c888a59a..ced175c268d1 100644 --- a/drivers/staging/media/atomisp/i2c/mt9m114.c +++ b/drivers/staging/media/atomisp/i2c/mt9m114.c @@ -689,12 +689,13 @@ static struct mt9m114_res_struct *mt9m114_to_res(u32 w, u32 h) return &mt9m114_res[index]; } -static int mt9m114_res2size(unsigned int res, int *h_size, int *v_size) +static int mt9m114_res2size(struct v4l2_subdev *sd, int *h_size, int *v_size) { + struct mt9m114_device *dev = to_mt9m114_sensor(sd); unsigned short hsize; unsigned short vsize; - switch (res) { + switch (dev->res) { case MT9M114_RES_736P: hsize = MT9M114_RES_736P_SIZE_H; vsize = MT9M114_RES_736P_SIZE_V; @@ -708,7 +709,8 @@ static int mt9m114_res2size(unsigned int res, int *h_size, int *v_size) vsize = MT9M114_RES_960P_SIZE_V; break; default: - WARN(1, "%s: Resolution 0x%08x unknown\n", __func__, res); + v4l2_err(sd, "%s: Resolution 0x%08x unknown\n", __func__, + dev->res); return -EINVAL; } @@ -812,15 +814,14 @@ static int mt9m114_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *format) { - struct v4l2_mbus_framefmt *fmt = &format->format; - struct mt9m114_device *dev = to_mt9m114_sensor(sd); + struct v4l2_mbus_framefmt *fmt = &format->format; int width, height; int ret; if (format->pad) return -EINVAL; fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10; - ret = mt9m114_res2size(dev->res, &width, &height); + ret = mt9m114_res2size(sd, &width, &height); if (ret) return ret; fmt->width = width; @@ -1174,7 +1175,6 @@ static int mt9m114_s_exposure_selection(struct v4l2_subdev *sd, struct v4l2_subdev_selection *sel) { struct i2c_client *client = v4l2_get_subdevdata(sd); - struct mt9m114_device *dev = to_mt9m114_sensor(sd); struct misensor_reg exp_reg; int width, height; int grid_width, grid_height; @@ -1192,7 +1192,7 @@ static int mt9m114_s_exposure_selection(struct v4l2_subdev *sd, grid_right = sel->r.left + sel->r.width - 1; grid_bottom = sel->r.top + sel->r.height - 1; - ret = mt9m114_res2size(dev->res, &width, &height); + ret = mt9m114_res2size(sd, &width, &height); if (ret) return ret;