]> git.baikalelectronics.ru Git - kernel.git/commit
rtc: stm32: fix comparison warnings
authorAmelie Delaunay <amelie.delaunay@st.com>
Mon, 16 Jan 2017 10:08:53 +0000 (11:08 +0100)
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>
Sun, 22 Jan 2017 23:47:15 +0000 (00:47 +0100)
commit2d49044094cea2f66885fe39c6d10b2ce2d2a47b
treecef5a5b02f011e0206654f8e029de50c145f7ffc
parent2ca684c815f875e3ab2fb4cec34b8eb6ed2f23b2
rtc: stm32: fix comparison warnings

This patches fixes comparison between signed and unsigned values as it
could produce an incorrect result when the signed value is converted to
unsigned:

drivers/rtc/rtc-stm32.c: In function 'stm32_rtc_valid_alrm':
drivers/rtc/rtc-stm32.c:404:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if ((((tm->tm_year > cur_year) &&
...

It also fixes comparison always true or false due to the fact that unsigned
value is compared against zero with >= or <:

drivers/rtc/rtc-stm32.c: In function 'stm32_rtc_init':
drivers/rtc/rtc-stm32.c:514:35: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
  for (pred_a = pred_a_max; pred_a >= 0; pred_a-- ) {

drivers/rtc/rtc-stm32.c:530:44: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
     (rate - ((pred_a + 1) * (pred_s + 1)) < 0) ?

Fixes: 4b04d1329ee2 ("rtc: add STM32 RTC driver")
Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
drivers/rtc/rtc-stm32.c