[PATCH] bsps/shared: Fix Coverity warning in MCP7940M

Joel Sherrill joel at rtems.org
Wed Aug 2 13:31:12 UTC 2023


On Wed, Aug 2, 2023 at 6:45 AM Christian MAUDERER <
christian.mauderer at embedded-brains.de> wrote:

> Hello Joel,
>
> thanks. Is the ID processed somewhere automatically so that I should use
> a special format? Otherwise I can just just add the error message from
> covertity:
>
> ** CID 1539495:  Integer handling issues  (CONSTANT_EXPRESSION_RESULT)
> /bsps/shared/dev/rtc/mcp7940m.c: 317 in mcp7940m_set_time()
>

It is not processed special. The CID is just nice to have in the future
and, if needed,
track back to what Coverity saw.

Especially given the history with some of these static analysis triggered
fixes where
they are hard to get right.

--joel

>
> Best regards
>
> Christian
>
> On 2023-08-02 13:43, Joel Sherrill wrote:
> > Ok but out the Coverity Id number in the commit long message
> >
> > On Wed, Aug 2, 2023, 1:17 AM Christian Mauderer
> > <christian.mauderer at embedded-brains.de
> > <mailto:christian.mauderer at embedded-brains.de>> wrote:
> >
> >     Coverity warns that (buf[...] & 0x7) can't be bigger than 7. This
> patch
> >     removes 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);
> >           }
> >     --
> >     2.35.3
> >
> >     _______________________________________________
> >     devel mailing list
> >     devel at rtems.org <mailto:devel at rtems.org>
> >     http://lists.rtems.org/mailman/listinfo/devel
> >     <http://lists.rtems.org/mailman/listinfo/devel>
> >
>
> --
> --------------------------------------------
> embedded brains GmbH & Co. KG
> Herr Christian MAUDERER
> Dornierstr. 4
> 82178 Puchheim
> Germany
> email:  christian.mauderer at embedded-brains.de
> phone:  +49-89-18 94 741 - 18
> mobile: +49-176-152 206 08
>
> Registergericht: Amtsgericht München
> Registernummer: HRA 117265
> Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
> Unsere Datenschutzerklärung finden Sie hier:
> https://embedded-brains.de/datenschutzerklaerung/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20230802/6e717ce8/attachment.htm>


More information about the devel mailing list