summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Long <ryan.long@oarcorp.com>2021-03-02 11:08:28 -0500
committerJoel Sherrill <joel@rtems.org>2021-03-08 14:04:10 -0600
commit597e4f476568a225d14dfaff02074cf269ad62ac (patch)
tree863bb161d7abf38b5f3a4893b55c005f83f518bf
parentmain_edit.c: Fix Unchecked return value (CID #1255318) (diff)
downloadrtems-597e4f476568a225d14dfaff02074cf269ad62ac.tar.bz2
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
-rw-r--r--cpukit/libmisc/uuid/gen_uuid.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/cpukit/libmisc/uuid/gen_uuid.c b/cpukit/libmisc/uuid/gen_uuid.c
index 3ca75a08ce..5bb34c0b09 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);
+ }
}
#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);
}
*clock_high = clock_reg >> 32;