From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C6DDAEB64D9 for ; Sat, 17 Jun 2023 17:43:55 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id ACB6982C; Sat, 17 Jun 2023 19:43:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz ACB6982C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1687023833; bh=v1w7IgjTyIRIpWfJqtbFcmG8AX0rS71G6iGgqf6oZgc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=N+tuaChA+dDAzv1OqkDaUnikskH+r2QNxo03wVF7YrGzziG3Ldv4Pr3fo654VwsPG vTvMJThN7ysez/fwd5vKRK3yBbtPCSYfFlwGc7KT4R9eKjN1yLd11AtCLEFkNn1S63 QQ/MuEX0zIxrd/FCxAx5AJseqoqLCfaIyMM/yaIM= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 27BB8F8052E; Sat, 17 Jun 2023 19:42:40 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id CBBB3F800ED; Sat, 17 Jun 2023 19:42:39 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9B794F80149; Sat, 17 Jun 2023 19:42:36 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 15BF5F800ED for ; Sat, 17 Jun 2023 19:42:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 15BF5F800ED Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=tpj7glSM Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6C61D60C36; Sat, 17 Jun 2023 17:42:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8133C433C8; Sat, 17 Jun 2023 17:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687023751; bh=v1w7IgjTyIRIpWfJqtbFcmG8AX0rS71G6iGgqf6oZgc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=tpj7glSMKVEgkv5Zp0h9t+gFIyMECcjE8yd4g03TIKnD9ezc7ZlsWmaAcq3nJhuwa h/spBKln7Bi020Uo1p2UZCnn5RIdSaPQhhv+L+83hxAijVxpaBSmB5KYkaw9kNJbpK 431U5SaJ6yTtn2JwItbltWxWG0VNn4p9KfGb3IXAXS3ZUq7ePOivZFYRXuCC5EXJiH CzvGK0sbvwCuYOlM0TOI8eQpOa2k2mt2BhXSOBNL9AbHs/n7UPFIOeMSEtM/Zagrt1 PPcZ3W/3yLKwMkHRt+IcfQH2D80eEgGcQxlvz2yAyTomSd/s1Jv4kDyiHofV/vRd2t 0PdySRWvL376Q== Date: Sat, 17 Jun 2023 18:42:22 +0100 From: Jonathan Cameron To: Herve Codina Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lars-Peter Clausen , Jaroslav Kysela , Takashi Iwai , Kuninori Morimoto , Andy Shevchenko , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: Re: [PATCH v5 05/13] iio: inkern: Remove the 'unused' variable usage in iio_channel_read_max() Message-ID: <20230617184222.7cb6870d@jic23-huawei> In-Reply-To: <20230615152631.224529-6-herve.codina@bootlin.com> References: <20230615152631.224529-1-herve.codina@bootlin.com> <20230615152631.224529-6-herve.codina@bootlin.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 2S5EOWLUOQFDPOMLWEFSRBZXQTPHWIRY X-Message-ID-Hash: 2S5EOWLUOQFDPOMLWEFSRBZXQTPHWIRY X-MailFrom: jic23@kernel.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu, 15 Jun 2023 17:26:23 +0200 Herve Codina wrote: > The code uses a local variable to initialize a null pointer in order to > avoid accessing this null pointer later on. > > Simply removed the 'unused' variable and check for the null pointer just > before accessing it. > > Signed-off-by: Herve Codina > Reviewed-by: Andy Shevchenko Acked-by: Jonathan Cameron A this series has grown more changes in IIO over time.... Hopefully who ever takes it can provide an immutable branch to make it easy to avoid any dependency issues for other work in IIO. Thanks, Jonathan > --- > drivers/iio/inkern.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c > index f738db9a0c04..ce537b4ca6ca 100644 > --- a/drivers/iio/inkern.c > +++ b/drivers/iio/inkern.c > @@ -849,14 +849,10 @@ static int iio_channel_read_max(struct iio_channel *chan, > int *val, int *val2, int *type, > enum iio_chan_info_enum info) > { > - int unused; > const int *vals; > int length; > int ret; > > - if (!val2) > - val2 = &unused; > - > ret = iio_channel_read_avail(chan, &vals, type, &length, info); > if (ret < 0) > return ret; > @@ -869,7 +865,8 @@ static int iio_channel_read_max(struct iio_channel *chan, > break; > default: > *val = vals[4]; > - *val2 = vals[5]; > + if (val2) > + *val2 = vals[5]; > } > return 0; >