Skip to contentSkip to conversation

drivers/rtc/rtc-stm32.c:514:27-33: WARNING: Unsigned expression compared with zero: pred_a >= 0

PATCH In review Julia Lawall 2 participants 2 messages Jan 13, 2017 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 12/12 drivers/rtc/rtc-stm32.c:514:27-33: WARNING: Unsigned expression compared with zero: pred_a >= 0

pred_a is unsigned, and thus the test on line 514 that it is >= 0 will always be true.

julia

---------- Forwarded message ----------

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
head:   4e64350f42e2ce153bdffd9fe1741333f5a41e57
commit: 4e64350f42e2ce153bdffd9fe1741333f5a41e57 [12/12] rtc: add STM32 RTC driver

:::::: branch date: 77 minutes ago
:::::: commit date: 77 minutes ago

Quoted 1 line
Quoted 1 line

drivers/rtc/rtc-stm32.c:514:27-33: WARNING: Unsigned expression compared with zero: pred_a >= 0

git remote add abelloni https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git
git remote update abelloni
git checkout 4e64350f42e2ce153bdffd9fe1741333f5a41e57
vim +514 drivers/rtc/rtc-stm32.c

4e64350f Amelie Delaunay 2017-01-11  498  MODULE_DEVICE_TABLE(of, stm32_rtc_of_match);
4e64350f Amelie Delaunay 2017-01-11  499  #endif
4e64350f Amelie Delaunay 2017-01-11  500
4e64350f Amelie Delaunay 2017-01-11  501  static int stm32_rtc_init(struct platform_device *pdev,
4e64350f Amelie Delaunay 2017-01-11  502  			  struct stm32_rtc *rtc)
4e64350f Amelie Delaunay 2017-01-11  503  {
4e64350f Amelie Delaunay 2017-01-11  504  	unsigned int prer, pred_a, pred_s, pred_a_max, pred_s_max, cr;
4e64350f Amelie Delaunay 2017-01-11  505  	unsigned int rate;
4e64350f Amelie Delaunay 2017-01-11  506  	int ret = 0;
4e64350f Amelie Delaunay 2017-01-11  507
4e64350f Amelie Delaunay 2017-01-11  508  	rate = clk_get_rate(rtc->ck_rtc);
4e64350f Amelie Delaunay 2017-01-11  509
4e64350f Amelie Delaunay 2017-01-11  510  	/* Find prediv_a and prediv_s to obtain the 1Hz calendar clock */
4e64350f Amelie Delaunay 2017-01-11  511  	pred_a_max = STM32_RTC_PRER_PRED_A >> STM32_RTC_PRER_PRED_A_SHIFT;
4e64350f Amelie Delaunay 2017-01-11  512  	pred_s_max = STM32_RTC_PRER_PRED_S >> STM32_RTC_PRER_PRED_S_SHIFT;
4e64350f Amelie Delaunay 2017-01-11  513
4e64350f Amelie Delaunay 2017-01-11 @514  	for (pred_a = pred_a_max; pred_a >= 0; pred_a--) {
4e64350f Amelie Delaunay 2017-01-11  515  		pred_s = (rate / (pred_a + 1)) - 1;
4e64350f Amelie Delaunay 2017-01-11  516
4e64350f Amelie Delaunay 2017-01-11  517  		if (((pred_s + 1) * (pred_a + 1)) == rate)
4e64350f Amelie Delaunay 2017-01-11  518  			break;
4e64350f Amelie Delaunay 2017-01-11  519  	}
4e64350f Amelie Delaunay 2017-01-11  520
4e64350f Amelie Delaunay 2017-01-11  521  	/*
4e64350f Amelie Delaunay 2017-01-11  522  	 * Can't find a 1Hz, so give priority to RTC power consumption

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Signature · 8 lines
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#1 lore raw

Hi Julia,

Thanks for the review, I prepare a fix for this warning.

Amelie

Quoted 74 lines

-----Original Message-----
From: Julia Lawall [mailto:[email protected]]
Sent: vendredi 13 janvier 2017 06:43
To: Amelie DELAUNAY <[email protected]>
Cc: Alexandre Belloni <[email protected]>; Mathieu Poirier <[email protected]>; [email protected]; kbuild- [email protected]
Subject: [abelloni:rtc-next 12/12] drivers/rtc/rtc-stm32.c:514:27-33: WARNING:
Unsigned expression compared with zero: pred_a >= 0

pred_a is unsigned, and thus the test on line 514 that it is >= 0 will always be true.

julia

---------- Forwarded message ----------

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
head:   4e64350f42e2ce153bdffd9fe1741333f5a41e57
commit: 4e64350f42e2ce153bdffd9fe1741333f5a41e57 [12/12] rtc: add STM32

RTC driver
:::::: branch date: 77 minutes ago
:::::: commit date: 77 minutes ago

Quoted 2 lines
Quoted 2 lines

drivers/rtc/rtc-stm32.c:514:27-33: WARNING: Unsigned expression compared with zero: pred_a >= 0

git remote add abelloni
https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git
git remote update abelloni
git checkout 4e64350f42e2ce153bdffd9fe1741333f5a41e57 vim +514 drivers/rtc/rtc-stm32.c

4e64350f Amelie Delaunay 2017-01-11 498 MODULE_DEVICE_TABLE(of, stm32_rtc_of_match); 4e64350f Amelie Delaunay 2017-01-11 499 #endif 4e64350f Amelie Delaunay 2017-01-11 500 4e64350f Amelie Delaunay 2017- 01-11 501 static int stm32_rtc_init(struct platform_device *pdev,
4e64350f Amelie Delaunay 2017-01-11 502 struct
stm32_rtc *rtc)

4e64350f Amelie Delaunay 2017-01-11  503  {
4e64350f Amelie Delaunay 2017-01-11  504  	unsigned int prer, pred_a,
pred_s, pred_a_max, pred_s_max, cr;
4e64350f Amelie Delaunay 2017-01-11  505  	unsigned int rate;
4e64350f Amelie Delaunay 2017-01-11  506  	int ret = 0;
4e64350f Amelie Delaunay 2017-01-11  507
4e64350f Amelie Delaunay 2017-01-11  508  	rate = clk_get_rate(rtc-
Quoted 1 line

ck_rtc);

4e64350f Amelie Delaunay 2017-01-11 509
4e64350f Amelie Delaunay 2017-01-11 510 /* Find prediv_a and prediv_s
to obtain the 1Hz calendar clock */
4e64350f Amelie Delaunay 2017-01-11 511 pred_a_max =
STM32_RTC_PRER_PRED_A >> STM32_RTC_PRER_PRED_A_SHIFT;
4e64350f Amelie Delaunay 2017-01-11 512 pred_s_max =
STM32_RTC_PRER_PRED_S >> STM32_RTC_PRER_PRED_S_SHIFT; 4e64350f Amelie Delaunay 2017-01-11 513
4e64350f Amelie Delaunay 2017-01-11 @514 for (pred_a = pred_a_max;
pred_a >= 0; pred_a--) {
4e64350f Amelie Delaunay 2017-01-11 515 pred_s = (rate /
(pred_a + 1)) - 1;
4e64350f Amelie Delaunay 2017-01-11 516
4e64350f Amelie Delaunay 2017-01-11 517 if (((pred_s + 1) *
(pred_a + 1)) == rate)

4e64350f Amelie Delaunay 2017-01-11  518  			break;
4e64350f Amelie Delaunay 2017-01-11  519  	}
4e64350f Amelie Delaunay 2017-01-11  520
4e64350f Amelie Delaunay 2017-01-11  521  	/*
4e64350f Amelie Delaunay 2017-01-11  522  	 * Can't find a 1Hz, so give

priority to RTC power consumption

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Signature · 8 lines
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.