Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2325087rwd; Wed, 14 Jun 2023 00:53:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7YrYbWcWsFtO8l3aBRtRA8LCQvjIr47grImRaW1RT54T2Y4bSws4r+4jtT+v9+ckT9MU5o X-Received: by 2002:a17:907:1689:b0:977:d8bf:58e2 with SMTP id hc9-20020a170907168900b00977d8bf58e2mr817338ejc.37.1686729225237; Wed, 14 Jun 2023 00:53:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686729225; cv=none; d=google.com; s=arc-20160816; b=Ds79LSD4GE8C/Md+kPGLfDVWht/y10cJQMgjS4mvLZIf6UMkllzQT0I4ZUembdLBt6 0aNhNed4BaOllk+NH0mUnAhd3DosYxxy0GbkWQgl4zkbQMKehMOCj3jLEtFiaIY7Rc0C /DXUTnbNs2qtAQTgjcpq8BLbvec9+6xb/Xj+abMcKh5SDTn/uZt9xuvME2Oexvp98Em2 eni/pZSsZQ1m71ITsI00x6J4PSyQ9rL2XtsCHyz6um2dROOoZ5StKFWyUTL462BapvnI /KICY3g/oeI0qf+zj9JA5JfwgkPZRMBfa2DnR/uMmj3Li5EcfFu4iIo2OGsvTGK7vmND y2Gg== 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=UT9BqZMAzsqeXdAE1pg2RpGSNQzWx+Tv//AxxVjuYWPerPrhWSb6v+E/lrULLfBVaX 02AmYETYY04rcMWQ8qTSnOGTeMu9Z+ypTsxEE4ETziuJL7LAjtxNJCbvYx2/5J1IK9V5 11JnaIPURrYp9FUwtZQJ0SfJjGJcL/oUxjZamV5Myg4E8lcekUOKpLbEnOuRBXgM2tZ7 lbHfggZM0tGcu9k9IKonodabIv4jRCSVgFyz8zABGYAp3FIgkU1YEH9tOd0tufQSM9XQ UW9+BjfhYA8PID6RTByWIRNZrNdDhOgJ8WeKyTK+KpIwrlAhSsuIcJSrmh1YCVqjWbMh KFUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Ujb6byVz; 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 q14-20020a1709060f8e00b0098283e90548si30169ejj.570.2023.06.14.00.53.20; Wed, 14 Jun 2023 00:53:45 -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=Ujb6byVz; 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 S243518AbjFNHue (ORCPT + 99 others); Wed, 14 Jun 2023 03:50:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243354AbjFNHtj (ORCPT ); Wed, 14 Jun 2023 03:49:39 -0400 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E09E1BC5; Wed, 14 Jun 2023 00:49:37 -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=1686728975; 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=Ujb6byVz6xAJtqKOMKEQtjG3xe6iIYKPGrHEfXRwBlClFYHJ/p+0jTKy02C1Q286OKL/SZ ILQgzNF6pej6fg81ryl6Q9t7iU3DB77LvHCbuhsMSoUn06yUmqk3PdXmIZnfYTKJ/sGuly S/2POfPSxQuIqoIxdQaEsQUGWCkMeOrCoCnXJ+lA17w+kAx8Q3F2yjiV4xqpAXr9NTzgsY f6OVZo+5oe8+/bpa0OTdRsWxdr1+Ixp2XSxJyTTpX3+dQO4eo2ZgsTtef/2M+6tYn1DxbM DZOAvrlDeqtksY9eu9cDE5iYn35vzntW0WdqKbHIC5j69PHIloHsvZFoFM2kjw== 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 9A1301C000D; Wed, 14 Jun 2023 07:49:34 +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 v4 05/13] iio: inkern: Remove the 'unused' variable usage in iio_channel_read_max() Date: Wed, 14 Jun 2023 09:48:56 +0200 Message-Id: <20230614074904.29085-6-herve.codina@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230614074904.29085-1-herve.codina@bootlin.com> References: <20230614074904.29085-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_NONE, 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 --- 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