Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1403237

[PATCH 1/1] rtc: ds1685: correct check of day of month

From Heinrich Schuchardt <xypron.glpk@gmx.de>
Newsgroups linux.kernel
Subject [PATCH 1/1] rtc: ds1685: correct check of day of month
Date 2016-05-18 21:20 +0200
Message-ID <rAfaG-6av-9@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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;
 
 	/*
@@ -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;
 
 	/*
-- 
2.1.4

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 1/1] rtc: ds1685: correct check of day of month Heinrich Schuchardt <xypron.glpk@gmx.de> - 2016-05-18 21:20 +0200
  Re: [PATCH 1/1] rtc: ds1685: correct check of day of month Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2016-05-21 00:40 +0200
    [PATCH v2 1/1] rtc: ds1685: correct check of day of month Heinrich Schuchardt <xypron.glpk@gmx.de> - 2016-05-22 00:30 +0200

csiph-web