Skip to contentSkip to conversation

rtc: rzn1: Fix a variable type

PATCH Applied Miquel Raynal 2 participants 2 messages May 20, 2022 – May 24, 2022

Subsystems (2)
lore
Share & tools
lore

Miquel Raynal

author maintainer
#0 lore raw

PATCH 1/1 rtc: rzn1: Fix a variable type

The calculation in ->set_offset() handles both negative and positive offsets. The 'steps' variable will be checked to be in a specific [-x; +x] range, which means it must be a signed integer rather than unsigned.

This also fixes the following smatch warning:

warn: 'steps' 'true' implies 'steps > 0' is 'true'

Fixes be4a11cf98af ("rtc: rzn1: Add oscillator offset support")
---
 drivers/rtc/rtc-rzn1.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/rtc/rtc-rzn1.c +1 -2
index bdd4ebd5c887..66405b43ae7e 100644
@@ -270,8 +270,7 @@ static int rzn1_rtc_read_offset(struct device *dev, long *offset)
 static int rzn1_rtc_set_offset(struct device *dev, long offset)
 {
 	struct rzn1_rtc *rtc = dev_get_drvdata(dev);
-	unsigned int steps;
-	int stepsh, stepsl;
+	int stepsh, stepsl, steps;
 	u32 subu = 0, ctl2;
 	int ret;
 
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 8 lines · Miquel Raynal

The calculation in ->set_offset() handles both negative and positive offsets. The 'steps' variable will be checked to be in a specific [-x; +x] range, which means it must be a signed integer rather than unsigned.

This also fixes the following smatch warning:

[...]

Applied, thanks!

[1/1] rtc: rzn1: Fix a variable type

      commit: 3f3489248927a53fcfec571ff603163f6b676a46

Best regards,

Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com