[PATCH 1/3] gen_uuid.c: Ignore return values from fcntl()
Gedare Bloom
gedare at rtems.org
Wed Mar 31 16:13:05 UTC 2021
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?
> }
> #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
More information about the devel
mailing list