Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp12180976rwd; Fri, 23 Jun 2023 02:29:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4LpArvKndK0Croop3wM+SVR39T6PyHEKCAWDPQN9WnBRu1y9QxVk1QRCRv06R0altRCiGS X-Received: by 2002:a05:6a20:3ca2:b0:122:5c71:6c81 with SMTP id b34-20020a056a203ca200b001225c716c81mr13121747pzj.43.1687512547575; Fri, 23 Jun 2023 02:29:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687512547; cv=none; d=google.com; s=arc-20160816; b=omxTL5ZHO5sdDdzs2/i4s4qwBtdMV/7vQfzD11xziw6ybh0dqZ5P7mlMXMipkV+3FL nkWyYTtmjY2P+A3OEFDFv7IoSu85V3UNWImtdnoCcrQwi/7j6B56+KVuR49zZ1Ld9fCQ EdEJU3X84lnlEFgp7rR8Ea5Bz8JxPghjr+JH4zuZe0a3ahEeXC51rhUA7pkmXzd/bg8F yGpY6hm5e6yb7t/0hZOERjVOq4LeiJOd0lmZ50pLKYZVO1oFkw/a6YKdXJDCWFSQAFAK mUr+6gorIO7+4hlcf7tpIZFOfW+btMFlFoTuBRimQJOsmBa4rXojLSjt3uhyxQUfqPod Uv2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/hsiLkhiPhkv1THloCiztKYYIF7LrdRF7qyhpJmA/Ws=; b=04F9tq8xcToxMN4Xd1XiUz4+90ipbiPth+2jPxryXCGC4nBp0Q0cRY3SpAM+82DTez zRfjWyLestkMntKWiJO85cTaW3msjoHQqLDhmMbiyupgSMO34x45NTI+eXyZZbAAmVcM zsfclr4Fs5lQdHtePUU+/KfbmW5jx9Nj84HIKiUUewEVOBSxrqm4rziyrnrvWDtvTXTi jI5P38KapQVjPXnHmoXPz6ClAEVzlTf8GDWJ3Fq6BMkm5S6XKFmHWK5nW6hi1Oh36ohj gTMgBIVA39r5+poZkV3DHnxwBOwUwShHkbYvgt6N/bLng+zcB/cY5BMZpl7k25TpfO/1 6plw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ONhXLrnB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f17-20020a170903105100b001ac6e1fd203si5116490plc.180.2023.06.23.02.28.55; Fri, 23 Jun 2023 02:29:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ONhXLrnB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231824AbjFWI7D (ORCPT + 99 others); Fri, 23 Jun 2023 04:59:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231935AbjFWI6w (ORCPT ); Fri, 23 Jun 2023 04:58:52 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1C742137; Fri, 23 Jun 2023 01:58:50 -0700 (PDT) X-GND-Sasl: herve.codina@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1687510729; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/hsiLkhiPhkv1THloCiztKYYIF7LrdRF7qyhpJmA/Ws=; b=ONhXLrnBHT9aoyHuwq5KlvouXzbQh+QAmv9J7ceVVSq34ivg6s8qyGIr6i04Sagh36RmE5 QX5t9pUBXx8h4CQxdlHYVRAdUnpCPiZ7B64oigbrIStqKvmyXOxh4QsLrrg4MvujZFuNaP BqfMwsfKiRw7UaBllrYpDvsidpVA5t8euhAHUmC0W4piebJHsAK+XMLIylcD1yi8cbCk1l fUpajUGxh2VxZM8U6BfKDYpZmT1NIw+chgYSsMPisZnwSJPEE27cYzbiWk6/kFRs0qWjK3 JkttD8Dx+vz3+ndT3Ph4yLXVgJZsZrX90UlV3MAc4PdcN/q8wXB1fbwC98NNow== X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com X-GND-Sasl: herve.codina@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPA id 2F61FE0004; Fri, 23 Jun 2023 08:58:48 +0000 (UTC) From: Herve Codina To: Herve Codina , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Cameron , Lars-Peter Clausen , Jaroslav Kysela , Takashi Iwai , Kuninori Morimoto , Andy Shevchenko Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Wojciech Ziemba , Christophe Leroy , Thomas Petazzoni , Jonathan Cameron Subject: [PATCH v6 05/13] iio: inkern: Remove the 'unused' variable usage in iio_channel_read_max() Date: Fri, 23 Jun 2023 10:58:22 +0200 Message-Id: <20230623085830.749991-6-herve.codina@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230623085830.749991-1-herve.codina@bootlin.com> References: <20230623085830.749991-1-herve.codina@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; -- 2.40.1