[rtems commit] gen_uuid.c: Fix two Unchecked return value from library errors

Gedare Bloom gedare at rtems.org
Wed Mar 24 15:51:03 UTC 2021


On Wed, Mar 24, 2021 at 7:03 AM Joel Sherrill <joel at rtems.org> wrote:
>
> I'm reverting this.
>
> I think this is in a batch that did not get tested before I worked
> with Ryan to correct his procedure.to ensure more testing with
> debug enabled.
>
> On most he has filed issues with the upstream, but as you note,
> this isn't the right solution so that doesn't matter here. Probably
> best to ifndef rtems around the unsupported features.
>
> I'm about to push a revert and reopen the ticket.
>
Thanks.

> --joel
>
> On Wed, Mar 24, 2021 at 2:31 AM Sebastian Huber <sebastian.huber at embedded-brains.de> wrote:
>>
>> On 08/03/2021 21:56, Joel Sherrill wrote:
>>
>> > Module:    rtems
>> > Branch:    master
>> > Commit:    597e4f476568a225d14dfaff02074cf269ad62ac
>> > Changeset:http://git.rtems.org/rtems/commit/?id=597e4f476568a225d14dfaff02074cf269ad62ac
>> >
>> > Author:    Ryan Long<ryan.long at oarcorp.com>
>> > Date:      Tue Mar  2 11:08:28 2021 -0500
>> >
>> > gen_uuid.c: Fix two Unchecked return value from library errors
>> >
>> > CID 1049146: Unchecked return value from library in get_clock().
>> > CID 1049147: Unchecked return value from library in get_random_fd().
>> >
>> > Closes #4280
>> >
>> > ---
>> >
>> >   cpukit/libmisc/uuid/gen_uuid.c | 11 ++++++++---
>> >   1 file changed, 8 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/cpukit/libmisc/uuid/gen_uuid.c b/cpukit/libmisc/uuid/gen_uuid.c
>> > index 3ca75a0..5bb34c0 100644
>> > --- a/cpukit/libmisc/uuid/gen_uuid.c
>> > +++ b/cpukit/libmisc/uuid/gen_uuid.c
>> > @@ -155,6 +155,7 @@ static int get_random_fd(void)
>> >       struct timeval  tv;
>> >       static int      fd = -2;
>> >       int             i;
>> > +     int             sc;
>> >
>> >       if (fd == -2) {
>> >               gettimeofday(&tv, 0);
>> > @@ -164,8 +165,10 @@ static int get_random_fd(void)
>> >                       fd = open("/dev/random", O_RDONLY | O_NONBLOCK);
>> >               if (fd >= 0) {
>> >                       i = fcntl(fd, F_GETFD);
>> > -                     if (i >= 0)
>> > -                             fcntl(fd, F_SETFD, i | FD_CLOEXEC);
>> > +                     if (i >= 0) {
>> > +                             sc = fcntl(fd, F_SETFD, i | FD_CLOEXEC);
>> > +                             _Assert_Unused_variable_unequal(sc, -1);
>> > +                     }
>>
>> FD_CLOEXEC is not supported by RTEMS. Do we even have these device files
>> in RTEMS? This is 3rd-party code, what about upstream changes?
>>
>> >               }
>> >   #endif
>> >               srand((getpid() << ((sizeof(pid_t)*CHAR_BIT)>>1)) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
>> > @@ -334,6 +337,7 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low,
>> >       uint64_t                        clock_reg;
>> >       mode_t                          save_umask;
>> >       int                             len;
>> > +     int                             sc;
>> >
>> >       if (state_fd == -2) {
>> >               save_umask = umask(0);
>> > @@ -426,7 +430,8 @@ try_again:
>> >               }
>> >               rewind(state_f);
>> >               fl.l_type = F_UNLCK;
>> > -             fcntl(state_fd, F_SETLK, &fl);
>> > +             sc = fcntl(state_fd, F_SETLK, &fl);
>> > +             _Assert_Unused_variable_unequal(sc, -1);
>> F_SETLK is not supported by RTEMS.
>> >       }
>> >
>> >       *clock_high = clock_reg >> 32;
>>
>> The patch produces warnings like this:
>>
>> ../../../cpukit/libmisc/uuid/gen_uuid.c: In function 'get_clock':
>> ../../../cpukit/libmisc/uuid/gen_uuid.c:434:3: warning: implicit
>> declaration of function '_Assert_Unused_variable_unequal'
>> [-Wimplicit-function-declaration]
>>    434 |   _Assert_Unused_variable_unequal(sc, -1);
>>        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> ../../../cpukit/libmisc/uuid/gen_uuid.c:434:3: warning: nested extern
>> declaration of '_Assert_Unused_variable_unequal' [-Wnested-externs]
>>
>> In total, how was this patch tested?
>>
>> If you add _Assert() stuff, please build with RTEMS_DEBUG enabled and
>> run the tests.
>>
>> --
>> embedded brains GmbH
>> Herr Sebastian HUBER
>> Dornierstr. 4
>> 82178 Puchheim
>> Germany
>> email: sebastian.huber at embedded-brains.de
>> phone: +49-89-18 94 741 - 16
>> fax:   +49-89-18 94 741 - 08
>>
>> Registergericht: Amtsgericht München
>> Registernummer: HRB 157899
>> Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
>> Unsere Datenschutzerklärung finden Sie hier:
>> https://embedded-brains.de/datenschutzerklaerung/
>>
>> _______________________________________________
>> devel mailing list
>> devel at rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list