public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Joshua Kinard <kumba@gentoo.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] rtc: ds1685: correct check of day of month
Date: Sat, 21 May 2016 00:38:29 +0200	[thread overview]
Message-ID: <20160520223829.GA4963@piout.net> (raw)
In-Reply-To: <1463598569-4329-1-git-send-email-xypron.glpk@gmx.de>

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@gmx.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

  reply	other threads:[~2016-05-20 22:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-18 19:09 [PATCH 1/1] rtc: ds1685: correct check of day of month Heinrich Schuchardt
2016-05-20 22:38 ` Alexandre Belloni [this message]
2016-05-21 22:18   ` [PATCH v2 " Heinrich Schuchardt
2016-06-04 13:46     ` Alexandre Belloni

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=20160520223829.GA4963@piout.net \
    --to=alexandre.belloni@free-electrons.com \
    --cc=a.zummo@towertech.it \
    --cc=kumba@gentoo.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rtc-linux@googlegroups.com \
    --cc=xypron.glpk@gmx.de \
    /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