From patchwork Mon Jun 12 12:29:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 691651 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 288BFC7EE2E for ; Mon, 12 Jun 2023 12:34:23 +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 E8FD5844; Mon, 12 Jun 2023 14:33:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E8FD5844 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1686573261; bh=5MBk2tEfr7UuAj9szy/piV0lUfQmXzh3dO2Uq6NpU4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=SW/RuXdpOVVFzo81sb84z98h9mXuemQKN7Bz9W9ylrA5B7Gg5IYugaYn3x/vZ/35t eRSOiZD2XrqFe1/90z5glc+tUhDJM7NAjJc62AYTA+8AO0bNN2sE7xL4cCfAYzfpR/ +wz/wVw9y23jUJTErfbpCkG78mBJt8K0ywR9vNRo= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A09D8F80132; Mon, 12 Jun 2023 14:33:08 +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 22DC9F8055C; Mon, 12 Jun 2023 14:33:08 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 91268F8055B; Mon, 12 Jun 2023 14:33:03 +0200 (CEST) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 21AE3F80130 for ; Mon, 12 Jun 2023 14:30:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 21AE3F80130 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=gm1 header.b=lMmnGJ+L X-GND-Sasl: herve.codina@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686573011; 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=AVqcs+RF8g9xZnk2mzzhe0NIqtDoWUK9eXmhpelzoNA=; b=lMmnGJ+LkP+t8FpO2lpB6zuReoAinfucdXaQVqg8GA52ppvsP3CdnBI6bPA7uv86R+V17R CYeGD2KCsIqcB9EyR84I7KybSX61YrUr8wdX0zsjyrEQMvUOjXRHYCGNGFMHDF+RSs+5Wt 8T7Lkn0e5OFFhZAn5hA2ON5gyv/YqZNwqWjykvuwBqAQOiJ/4RfwUM1bub5GaR56cpsR3G NV9ULgdAXhDqST4zTQyUhl2+Z333eB9yREiqCJvehHtHtANd4f/ZkcEYSSWXC9rDZy/LEE sIhJT1YChAWdqaT5ggxBfzUyRyNKJI0eUqShfQaSRDGqFCLdO6BnlzvY/Qf3Wg== 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 E81F1240024; Mon, 12 Jun 2023 12:30:09 +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 v3 05/12] iio: inkern: Remove the 'unused' variable usage in iio_channel_read_max() Date: Mon, 12 Jun 2023 14:29:19 +0200 Message-Id: <20230612122926.107333-6-herve.codina@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230612122926.107333-1-herve.codina@bootlin.com> References: <20230612122926.107333-1-herve.codina@bootlin.com> MIME-Version: 1.0 Message-ID-Hash: 7XNUUNUQTZBMFPQ6MO57VUZ7P3TRTI2X X-Message-ID-Hash: 7XNUUNUQTZBMFPQ6MO57VUZ7P3TRTI2X X-MailFrom: herve.codina@bootlin.com 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: 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;