Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp253291pxu; Tue, 6 Oct 2020 05:44:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2eO+CAiug0iyr5NgoY0l/OhFBuprhDPERPvTy5s3q7v+Ut2HxN/wcoedvOr5KPRUpNsci X-Received: by 2002:a17:906:d8a3:: with SMTP id qc3mr5138729ejb.183.1601988294159; Tue, 06 Oct 2020 05:44:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601988294; cv=none; d=google.com; s=arc-20160816; b=gh5yaJE9+w3uBBtZOyHKqDHXsF4bgtnSEMzFpu+aTTCuJNmMdCoc4oxmY63TUIbj/+ kpuX5l804RpnsiBMHeWrgWGy2VnuqRCnOSx1vW00zwy9Zaeyf2er94yKgkNZVPSLbQQQ c+TqUk5Rz09auG6wKw5yAMYxo8b3rikc4hmxUG95LIR1gUN4AjgXuqBWz9WdXsbfZgR6 u679EJqNLCpNUCrE8cRU5tZieVgXQH9l/Jmgh4t/cafHcan9mwBKovGp4n8vub8DDG+R wMUISs+/tonBEO8WLAKvYvQz4IVsdvqRedbtSpYOP3Pwm1tc+WHLLTzRSVF+x6gtJaz3 9pew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=XkHBkcqzhGCa3ZV3uftgKF4wB4jpOeTVyDvR3Kv4B8s=; b=s4scX8lbPmy/2OyQJdVpAk3F65EsyIVvvMnbyHO6HLk9CWQqwVCmInxydyPg91oN67 scyEE42400vHISywTeSU8s+kRDt+CF4EM8lvKJJikGGsb5E1ABGyQjIqEc+FoIzFXNXq +VGTfS/hGTHSFEIBmYVM8xklGPSKk3zhDv05ejx20CVkJw86Hm/TBv3vHuoXoQqrNJ7v wAuJC0w3tIIretAEzhcVrZ9Ij3mrBF5x4zHz8EOjcruK8qLixLw0dy7SzNLGywhk24B0 xMi/zh8Qw+VJRvBr1vAd3kilYZGfaAra9xzoSFi/QqoHPeLxeIQ0teSyu0H8RVFOl51g GEcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lv16si420833ejb.305.2020.10.06.05.44.31; Tue, 06 Oct 2020 05:44:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726683AbgJFMma (ORCPT + 99 others); Tue, 6 Oct 2020 08:42:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726362AbgJFMm3 (ORCPT ); Tue, 6 Oct 2020 08:42:29 -0400 Received: from hillosipuli.retiisi.eu (hillosipuli.retiisi.org.uk [IPv6:2a01:4f9:c010:4572::81:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95ACBC061755; Tue, 6 Oct 2020 05:42:29 -0700 (PDT) Received: from valkosipuli.localdomain (valkosipuli.retiisi.org.uk [IPv6:2a01:4f9:c010:4572::80:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by hillosipuli.retiisi.eu (Postfix) with ESMTPS id DD3A0634C87; Tue, 6 Oct 2020 15:41:48 +0300 (EEST) Received: from sailus by valkosipuli.localdomain with local (Exim 4.92) (envelope-from ) id 1kPmHs-0001eV-OW; Tue, 06 Oct 2020 15:41:48 +0300 Date: Tue, 6 Oct 2020 15:41:48 +0300 From: Sakari Ailus To: trix@redhat.com Cc: corbet@lwn.net, mchehab@kernel.org, natechancellor@gmail.com, ndesaulniers@google.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] media: ov7670: check status of ov7670_read Message-ID: <20201006124148.GC5682@valkosipuli.retiisi.org.uk> References: <20200828145518.26324-1-trix@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200828145518.26324-1-trix@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tom, On Fri, Aug 28, 2020 at 07:55:18AM -0700, trix@redhat.com wrote: > From: Tom Rix > > clang static analysis flags this representative problem > > drivers/media/i2c/ov7670.c:1463:9: warning: Assigned > value is garbage or undefined > *value = gain; > ^ ~~~~ > > gain is set by a successful call to ov7670_read() > > So check that ov7670_read() is successful. > > The remaining static analysis problems are false positives. > There appears to be a limitation with checking the > aggregated returns. > > Signed-off-by: Tom Rix > --- > drivers/media/i2c/ov7670.c | 17 +++++++++++++---- > 1 file changed, 13 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c > index b42b289faaef..001d4b09db72 100644 > --- a/drivers/media/i2c/ov7670.c > +++ b/drivers/media/i2c/ov7670.c > @@ -929,6 +929,8 @@ static int ov7670_set_hw(struct v4l2_subdev *sd, int hstart, int hstop, > ret = ov7670_write(sd, REG_HSTART, (hstart >> 3) & 0xff); > ret += ov7670_write(sd, REG_HSTOP, (hstop >> 3) & 0xff); > ret += ov7670_read(sd, REG_HREF, &v); > + if (ret) > + return ret; Thanks for the patch. While the patch fixes a bug, could you also fix adding the return values? These are valid error codes to begin with, but it makes no sense to add them together. > v = (v & 0xc0) | ((hstop & 0x7) << 3) | (hstart & 0x7); > msleep(10); > ret += ov7670_write(sd, REG_HREF, v); > @@ -938,6 +940,8 @@ static int ov7670_set_hw(struct v4l2_subdev *sd, int hstart, int hstop, > ret += ov7670_write(sd, REG_VSTART, (vstart >> 2) & 0xff); > ret += ov7670_write(sd, REG_VSTOP, (vstop >> 2) & 0xff); > ret += ov7670_read(sd, REG_VREF, &v); > + if (ret) > + return ret; > v = (v & 0xf0) | ((vstop & 0x3) << 2) | (vstart & 0x3); > msleep(10); > ret += ov7670_write(sd, REG_VREF, v); > @@ -1460,6 +1464,8 @@ static int ov7670_g_gain(struct v4l2_subdev *sd, __s32 *value) > unsigned char gain; > > ret = ov7670_read(sd, REG_GAIN, &gain); > + if (ret) > + return ret; > *value = gain; > return ret; > } > @@ -1470,11 +1476,14 @@ static int ov7670_s_gain(struct v4l2_subdev *sd, int value) > unsigned char com8; > > ret = ov7670_write(sd, REG_GAIN, value & 0xff); > + if (ret) > + return ret; > /* Have to turn off AGC as well */ > - if (ret == 0) { > - ret = ov7670_read(sd, REG_COM8, &com8); > - ret = ov7670_write(sd, REG_COM8, com8 & ~COM8_AGC); > - } > + ret = ov7670_read(sd, REG_COM8, &com8); > + if (ret) > + return ret; > + ret = ov7670_write(sd, REG_COM8, com8 & ~COM8_AGC); > + > return ret; > } > -- Regards, Sakari Ailus