[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160520223829.GA4963@piout.net>
Date: Sat, 21 May 2016 00:38:29 +0200
From: Alexandre Belloni <alexandre.belloni@...e-electrons.com>
To: Heinrich Schuchardt <xypron.glpk@....de>
Cc: Joshua Kinard <kumba@...too.org>,
Alessandro Zummo <a.zummo@...ertech.it>,
rtc-linux@...glegroups.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] rtc: ds1685: correct check of day of month
Hi,
On 18/05/2016 at 21:09:29 +0200, Heinrich Schuchardt wrote :
> Operator ! has a higher priority than &&.
> (!(mday >= 1) && (mday <= 31)) is false for mday == 32.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@....de>
> ---
> drivers/rtc/rtc-ds1685.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/rtc/rtc-ds1685.c b/drivers/rtc/rtc-ds1685.c
> index b3ce3c6..b4fae3c 100644
> --- a/drivers/rtc/rtc-ds1685.c
> +++ b/drivers/rtc/rtc-ds1685.c
> @@ -389,7 +389,7 @@ ds1685_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
> ds1685_rtc_end_data_access(rtc);
>
> /* Check month date. */
> - if (!(mday >= 1) && (mday <= 31))
> + if ((mday < 1) || (mday > 31))
> return -EDOM;
>
This is a good catch but I think this also breaks the bcd_mode == 1
case because the test happens after the bin2bcd conversion. Can you
check/fix?
> /*
> @@ -461,7 +461,7 @@ ds1685_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
> RTC_MDAY_BCD_MASK);
>
> /* Check the month date for validity. */
> - if (!(mday >= 1) && (mday <= 31))
> + if ((mday < 1) || (mday > 31))
> return -EDOM;
>
> /*
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
Powered by blists - more mailing lists