[rtems commit] bsps/shared: Fix Coverity warning in MCP7940M
Christian Mauderer
christianm at rtems.org
Thu Aug 3 04:55:55 UTC 2023
Module: rtems
Branch: master
Commit: 5115e6524fbca0d8668c785773d39eff27de6607
Changeset: http://git.rtems.org/rtems/commit/?id=5115e6524fbca0d8668c785773d39eff27de6607
Author: Christian Mauderer <christian.mauderer at embedded-brains.de>
Date: Wed Aug 2 07:41:37 2023 +0200
bsps/shared: Fix Coverity warning in MCP7940M
Fixes the following Coverity warning:
** CID 1539495: Integer handling issues (CONSTANT_EXPRESSION_RESULT)
/bsps/shared/dev/rtc/mcp7940m.c: 317 in mcp7940m_set_time()
Basically coverity warns that (buf[...] & 0x7) can't be bigger than 7.
Just remove the unnecessary comparison.
---
bsps/shared/dev/rtc/mcp7940m.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/bsps/shared/dev/rtc/mcp7940m.c b/bsps/shared/dev/rtc/mcp7940m.c
index 78a4f21b58..1abc5faaad 100644
--- a/bsps/shared/dev/rtc/mcp7940m.c
+++ b/bsps/shared/dev/rtc/mcp7940m.c
@@ -312,9 +312,8 @@ static int mcp7940m_set_time(int minor, const rtems_time_of_day *time)
}
if (rv == 0) {
- /* Make sure weekday is in range. Otherwise it's not relevant. */
- if (RTCWKDAY_WKDAY_GET(buf[REG_RTCWKDAY]) < 1 ||
- RTCWKDAY_WKDAY_GET(buf[REG_RTCWKDAY]) > 7) {
+ /* Make sure weekday is not 0 (out of range). Otherwise it's not used. */
+ if (RTCWKDAY_WKDAY_GET(buf[REG_RTCWKDAY]) < 1) {
buf[REG_RTCWKDAY] &= ~RTCWKDAY_WKDAY_MASK;
buf[REG_RTCWKDAY] |= RTCWKDAY_WKDAY(1);
}
More information about the vc
mailing list