[PATCH 01/12] gen_uuid.c: Fix two Unchecked return value from library errors
Gedare Bloom
gedare at rtems.org
Thu Mar 4 16:28:57 UTC 2021
On Thu, Mar 4, 2021 at 7:05 AM Ryan Long <thisisryanlong at gmail.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 | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/cpukit/libmisc/uuid/gen_uuid.c b/cpukit/libmisc/uuid/gen_uuid.c
> index 3ca75a0..0f2aba0 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);
> @@ -165,7 +166,12 @@ static int get_random_fd(void)
> if (fd >= 0) {
> i = fcntl(fd, F_GETFD);
> if (i >= 0)
> - fcntl(fd, F_SETFD, i | FD_CLOEXEC);
> + #ifdef __rtems__
remove ifdefs, this file is now "clone and own" by us.
> + sc = fcntl(fd, F_SETFD, i | FD_CLOEXEC);
> + _Assert_Unused_variable_unequal(sc, -1);
> + #else
> + fcntl(fd, F_SETFD, i | FD_CLOEXEC);
> + #endif
> }
> #endif
> srand((getpid() << ((sizeof(pid_t)*CHAR_BIT)>>1)) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
> @@ -334,6 +340,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 +433,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);
> }
>
> *clock_high = clock_reg >> 32;
> --
> 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