Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1279901rwd; Thu, 15 Jun 2023 08:30:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ77UYeGGEEc3KrP6+EWAgTp892hVdp/WQiBFOs8Solg3AX3A6EU+A5Qv1dVP3EfaU63bd5R X-Received: by 2002:a05:6a00:1a4a:b0:64d:1185:2411 with SMTP id h10-20020a056a001a4a00b0064d11852411mr5270845pfv.18.1686843004585; Thu, 15 Jun 2023 08:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686843004; cv=none; d=google.com; s=arc-20160816; b=jNDaMo3QNtsyNY7UyWcHbM4UaGVeqM7w3smkgtb+zs3gx8pj86uu9BfqAILTnzs3gV 2gm/NvW4lxzyxX1YnYn9Qg79Mis0woeyRATMfxJyxGdyRDxCcVkQ/LvAFv3knHVmOo3n M8WLxW4N8yR63th1ow2v/kbrPiqiKTH3qRSbAvL2aESs1woAILQBHRzRIbDYzmcwohhW S8nec7a8zZqBryneopKiMPDBKp3ADu4eZ+YCAW4mtd4OckEExK7lVotXv0Vv/T7VKoq0 33o5yAE+wPxDW9hgPWCKkIT8Y1rXRejEjY77kmy4V4bYofW0JNXViMzCPDxBhsul9eWl mfOg== 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=FkQZxmbGPKkjmBtgt+Imn8A43/IEec3F3481+44qF+k=; b=aFgB4sJqs9BxUTVXtINw2c/g07OIJNZsiUyF9KmkrXqmZIyxXBbesU3OILxsx/bh4p XfjOl/frZ8uOCq9Hzt4LZzyfw60mE9MShKRT5Pfgmrs64a8IEp8KbXdv8XbNrPldp/Bx vZSLnTDHQXeDvawz6I0HCnOB5F22jIq56seCW1uOZBMSnZOoLK6zMJ6nsefToQnag9vx uJG/qSDtrJEyIKzEljaeKb7gl9WWkLPzFtlpIghyouqjhULDROaO5wTWvd19YzLhvarv U8UUtV8tSOGGRz34YpIKtfpDdOUGy6JV+PabMlKlb2KnkcUXqYl9evDm4e8/T7WOp7BS FcBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="GgF3GI/+"; 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 s19-20020a639253000000b0051f74e18927si13038399pgn.184.2023.06.15.08.29.50; Thu, 15 Jun 2023 08:30:04 -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="GgF3GI/+"; 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 S1344999AbjFOP1T (ORCPT + 99 others); Thu, 15 Jun 2023 11:27:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345154AbjFOP0r (ORCPT ); Thu, 15 Jun 2023 11:26:47 -0400 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8845E1FD7; Thu, 15 Jun 2023 08:26:45 -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=1686842804; 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=FkQZxmbGPKkjmBtgt+Imn8A43/IEec3F3481+44qF+k=; b=GgF3GI/+SctDgQM7VM6aUN0cAqd9I4I3SlRY61XiineJ9+g8j4xEacTE9ErCME+qZPFdGw 6o22aF6G/DVqvv8TxOoYntsyd2p3EnosDAX30GAc/yGWsqayoG1ZALJzdFk0N7OhxrO42s V0cVu+1OUhyTW6CIbNaExuIT3mqx3cZd+gq3REarFMjqHhH7JbuYg0C5uIdOblWX3dPEbt NKnzw0uoutfLL+aQGcQxPf9h0abBjY7Rnk4ubxeuQG3TTeiGDwl7TF6u49ZMY+DJdCV66q DUxyT0+efaYuiewg+n9iTaF6f9ux/cCoERDOETSfXGk6j+sPl2QMiXdhSMDR6g== 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 2190BFF804; Thu, 15 Jun 2023 15:26:43 +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, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v5 05/13] iio: inkern: Remove the 'unused' variable usage in iio_channel_read_max() Date: Thu, 15 Jun 2023 17:26:23 +0200 Message-Id: <20230615152631.224529-6-herve.codina@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230615152631.224529-1-herve.codina@bootlin.com> References: <20230615152631.224529-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,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 --- 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