[PATCH 1/3] gen_uuid.c: Ignore return values from fcntl()

Joel Sherrill joel at rtems.org
Wed Mar 31 16:35:17 UTC 2021


On Wed, Mar 31, 2021 at 11:13 AM Gedare Bloom <gedare at rtems.org> wrote:

> On Wed, Mar 31, 2021 at 9:16 AM Ryan Long <ryan.long at oarcorp.com> wrote:
> >
> > 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 | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/cpukit/libmisc/uuid/gen_uuid.c
> b/cpukit/libmisc/uuid/gen_uuid.c
> > index 3ca75a0..9cd763d 100644
> > --- a/cpukit/libmisc/uuid/gen_uuid.c
> > +++ b/cpukit/libmisc/uuid/gen_uuid.c
> > @@ -164,8 +164,13 @@ static int get_random_fd(void)
> >                         fd = open("/dev/random", O_RDONLY | O_NONBLOCK);
> >                 if (fd >= 0) {
> >                         i = fcntl(fd, F_GETFD);
> > +                       #ifdef __rtems__
> > +                       if (i >= 0)
> > +                               (void) fcntl(fd, F_SETFD, i |
> FD_CLOEXEC);
> > +                       #else
> >                         if (i >= 0)
> >                                 fcntl(fd, F_SETFD, i | FD_CLOEXEC);
> > +                       #endif
> You could do the same thing here as you did below, just put the #ifdef
> after the if (i>=0)
>
> The upstream is
> https://github.com/karelzak/util-linux/blob/master/libuuid/src/gen_uuid.c
> I wonder if we should update?
>

Are you sure that's the master? That's not what the README in the directory
says.

I'm not opposed to updating the code in the directory but I want to make
sure it
comes from the right place.

And do we have any tests to ensure it works if it builds? This wasn't
included
in the last coverage I uploaded but I can ask Alex to turn it on.


> >                 }
> >  #endif
> >                 srand((getpid() << ((sizeof(pid_t)*CHAR_BIT)>>1)) ^
> getuid() ^ tv.tv_sec ^ tv.tv_usec);
> > @@ -426,6 +431,9 @@ try_again:
> >                 }
> >                 rewind(state_f);
> >                 fl.l_type = F_UNLCK;
> > +       #ifdef __rtems__
> > +               (void)
> > +       #endif
> >                 fcntl(state_fd, F_SETLK, &fl);
> >         }
> >
> > --
> > 1.8.3.1
> >
> > _______________________________________________
> > 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20210331/8c2709e0/attachment.html>


More information about the devel mailing list