History

rtc: ds1685: remove superfluous checks for out-of-range u8 values

drivers/rtc/rtc-ds1685.c: In function `ds1685_rtc_read_alarm': drivers/rtc/rtc-ds1685.c:402: warning: comparison is always true due to limited range of data type drivers/rtc/rtc-ds1685.c:409: warning: comparison is always true due to limited range of data type drivers/rtc/rtc-ds1685.c:416: warning: comparison is always true due to limited range of data type drivers/rtc/rtc-ds1685.c: In function `ds1685_rtc_set_alarm': drivers/rtc/rtc-ds1685.c:475: warning: comparison is always true due to limited range of data type drivers/rtc/rtc-ds1685.c:478: warning: comparison is always true due to limited range of data type drivers/rtc/rtc-ds1685.c:481: warning: comparison is always true due to limited range of data type u8 cannot contain a value larger than 0xff, hence drop the checks. Wrapping the checks in unlikely() indicated some sense of humor, though ;-)

Geert Uytterhoeven committed 11 years ago

Commit 39ea34c1 parent 682354d1 file · +6 −6Browse files

Unified · Split

drivers/rtc/rtc-ds1685.c+6−6
@@ -399,21 +399,21 @@ ds1685_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) · 398 unmodified lines
399399 * of this RTC chip. We check for it anyways in case support is
400400 * added in the future.
401401 */
402− if (unlikely((seconds >= 0xc0) && (seconds <= 0xff)))
402+ if (unlikely(seconds >= 0xc0))
403403 alrm->time.tm_sec = -1;
404404 else
405405 alrm->time.tm_sec = ds1685_rtc_bcd2bin(rtc, seconds,
406406 RTC_SECS_BCD_MASK,
407407 RTC_SECS_BIN_MASK);
408408
409− if (unlikely((minutes >= 0xc0) && (minutes <= 0xff)))
409+ if (unlikely(minutes >= 0xc0))
410410 alrm->time.tm_min = -1;
411411 else
412412 alrm->time.tm_min = ds1685_rtc_bcd2bin(rtc, minutes,
413413 RTC_MINS_BCD_MASK,
414414 RTC_MINS_BIN_MASK);
415415
416− if (unlikely((hours >= 0xc0) && (hours <= 0xff)))
416+ if (unlikely(hours >= 0xc0))
417417 alrm->time.tm_hour = -1;
418418 else
419419 alrm->time.tm_hour = ds1685_rtc_bcd2bin(rtc, hours,
@@ -472,13 +472,13 @@ ds1685_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) · 52 unmodified lines
472472 * field, and we only support four fields. We put the support
473473 * here anyways for the future.
474474 */
475− if (unlikely((seconds >= 0xc0) && (seconds <= 0xff)))
475+ if (unlikely(seconds >= 0xc0))
476476 seconds = 0xff;
477477
478− if (unlikely((minutes >= 0xc0) && (minutes <= 0xff)))
478+ if (unlikely(minutes >= 0xc0))
479479 minutes = 0xff;
480480
481− if (unlikely((hours >= 0xc0) && (hours <= 0xff)))
481+ if (unlikely(hours >= 0xc0))
482482 hours = 0xff;
483483
484484 alrm->time.tm_mon = -1;