lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241112202041.16980-1-surajsonawane0215@gmail.com>
Date: Wed, 13 Nov 2024 01:50:41 +0530
From: Suraj Sonawane <surajsonawane0215@...il.com>
To: Liam Girdwood <lgirdwood@...il.com>
Cc: Mark Brown <broonie@...nel.org>,
	linux-kernel@...r.kernel.org,
	Suraj Sonawane <surajsonawane0215@...il.com>
Subject: [PATCH] regulator: aat2870-regulator: replace division condition with direct comparison

Fix an issue detected by the Smatch tool:

drivers/regulator/aat2870-regulator.c:142 aat2870_get_regulator() warn:
replace divide condition '(id - 1) / 2' with '(id - 1) >= 2'

The division '(id - 1) / 2' was used to check if the regulator ID
is greater than or equal to 2, which can be confusing and less
readable. Replacing it with '(id - 1) >= 2' makes the code clearer
by directly comparing the regulator ID. This change also removes
reliance on integer division, which could be harder to understand
and may introduce subtle bugs.

Signed-off-by: Suraj Sonawane <surajsonawane0215@...il.com>
---
 drivers/regulator/aat2870-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/aat2870-regulator.c b/drivers/regulator/aat2870-regulator.c
index 970d86f2b..b48d2987a 100644
--- a/drivers/regulator/aat2870-regulator.c
+++ b/drivers/regulator/aat2870-regulator.c
@@ -139,7 +139,7 @@ static struct aat2870_regulator *aat2870_get_regulator(int id)
 	ri->enable_shift = id - AAT2870_ID_LDOA;
 	ri->enable_mask = 0x1 << ri->enable_shift;
 
-	ri->voltage_addr = (id - AAT2870_ID_LDOA) / 2 ?
+	ri->voltage_addr = (id - AAT2870_ID_LDOA) >= 2 ?
 			   AAT2870_LDO_CD : AAT2870_LDO_AB;
 	ri->voltage_shift = (id - AAT2870_ID_LDOA) % 2 ? 0 : 4;
 	ri->voltage_mask = 0xF << ri->voltage_shift;
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ