Linux RTC
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: amelie.delaunay@st.com
Cc: rtc-linux@googlegroups.com
Subject: [rtc-linux] [bug report] rtc: add STM32 RTC driver
Date: Mon, 16 Jan 2017 15:13:47 +0300	[thread overview]
Message-ID: <20170116121346.GA28569@mwanda> (raw)

Hello Amelie Delaunay,

The patch 4e64350f42e2: "rtc: add STM32 RTC driver" from Jan 11,
2017, leads to the following static checker warning:

	drivers/rtc/rtc-stm32.c:514 stm32_rtc_init()
	warn: always true condition '(pred_a >= 0) => (0-u32max >= 0)'

drivers/rtc/rtc-stm32.c
   499  static int stm32_rtc_init(struct platform_device *pdev,
   500                            struct stm32_rtc *rtc)
   501  {
   502          unsigned int prer, pred_a, pred_s, pred_a_max, pred_s_max, cr;
   503          unsigned int rate;
   504          int ret = 0;
   505  
   506          rate = clk_get_rate(rtc->ck_rtc);
   507  
   508          /* Find prediv_a and prediv_s to obtain the 1Hz calendar clock */
   509          pred_a_max = STM32_RTC_PRER_PRED_A >> STM32_RTC_PRER_PRED_A_SHIFT;
   510          pred_s_max = STM32_RTC_PRER_PRED_S >> STM32_RTC_PRER_PRED_S_SHIFT;
   511  
   512          for (pred_a = pred_a_max; pred_a >= 0; pred_a--) {
                                          ^^^^^^^^^^^
We should probably make pred_a, pred_s, pred_a_max and pred_s_max
signed.

   513                  pred_s = (rate / (pred_a + 1)) - 1;
   514  
   515                  if (((pred_s + 1) * (pred_a + 1)) == rate)
   516                          break;
   517          }
   518  

regards,
dan carpenter

-- 
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 rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

             reply	other threads:[~2017-01-16 12:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-16 12:13 Dan Carpenter [this message]
2017-01-16 12:19 ` [rtc-linux] RE: [bug report] rtc: add STM32 RTC driver Amelie DELAUNAY
2017-01-16 12:21 ` [rtc-linux] " Dan Carpenter
2017-01-16 12:26   ` Amelie DELAUNAY
2017-01-16 12:29     ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170116121346.GA28569@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=amelie.delaunay@st.com \
    --cc=rtc-linux@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox