diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2022-08-31 15:18:08 -0400 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2022-08-31 15:18:08 -0400 |
commit | d92d3a3c4a7af1ebe56d58c32986ab410f6071ec (patch) | |
tree | dc9d1165c287da28953546cdad9184e5828d14ab /newlib/libc | |
parent | dd1122e21cb4ea78ce4c5894787c8f085469f9dd (diff) | |
download | newlib-d92d3a3c4a7af1ebe56d58c32986ab410f6071ec.zip newlib-d92d3a3c4a7af1ebe56d58c32986ab410f6071ec.tar.gz newlib-d92d3a3c4a7af1ebe56d58c32986ab410f6071ec.tar.bz2 |
Fix some Coverity Scan errors.
Diffstat (limited to 'newlib/libc')
-rw-r--r-- | newlib/libc/posix/sleep.c | 3 | ||||
-rw-r--r-- | newlib/libc/posix/usleep.c | 1 | ||||
-rw-r--r-- | newlib/libc/stdio/swscanf.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdio/vswscanf.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdlib/arc4random.c | 2 | ||||
-rw-r--r-- | newlib/libc/time/time.c | 2 |
6 files changed, 10 insertions, 2 deletions
diff --git a/newlib/libc/posix/sleep.c b/newlib/libc/posix/sleep.c index f7c780e..0d6cd71 100644 --- a/newlib/libc/posix/sleep.c +++ b/newlib/libc/posix/sleep.c @@ -7,6 +7,7 @@ #include <errno.h> #include <time.h> #include <unistd.h> +#include <limits.h> unsigned sleep(unsigned seconds) { @@ -15,7 +16,7 @@ unsigned sleep(unsigned seconds) ts.tv_sec = seconds; ts.tv_nsec = 0; if (!nanosleep(&ts,&ts)) return 0; - if (errno == EINTR) return ts.tv_sec; + if (errno == EINTR) return ts.tv_sec & UINT_MAX; return -1; } diff --git a/newlib/libc/posix/usleep.c b/newlib/libc/posix/usleep.c index 9322b65..cc1b314 100644 --- a/newlib/libc/posix/usleep.c +++ b/newlib/libc/posix/usleep.c @@ -15,7 +15,6 @@ int usleep(useconds_t useconds) ts.tv_sec = (long int)useconds / 1000000; ts.tv_nsec = ((long int)useconds % 1000000) * 1000; if (!nanosleep(&ts,&ts)) return 0; - if (errno == EINTR) return ts.tv_sec; return -1; } diff --git a/newlib/libc/stdio/swscanf.c b/newlib/libc/stdio/swscanf.c index 5514e68..578ac3c 100644 --- a/newlib/libc/stdio/swscanf.c +++ b/newlib/libc/stdio/swscanf.c @@ -427,6 +427,8 @@ swscanf (const wchar_t *__restrict str, const wchar_t *__restrict fmt, ...) f._read = __seofread; f._ub._base = NULL; f._lb._base = NULL; + f._flags2 = 0; + f._ur = 0; f._file = -1; /* No file. */ va_start (ap, fmt); ret = __ssvfwscanf_r (_REENT, &f, fmt, ap); diff --git a/newlib/libc/stdio/vswscanf.c b/newlib/libc/stdio/vswscanf.c index 13b61f4..415c98b 100644 --- a/newlib/libc/stdio/vswscanf.c +++ b/newlib/libc/stdio/vswscanf.c @@ -53,6 +53,8 @@ _vswscanf_r (struct _reent *ptr, const wchar_t *str, const wchar_t *fmt, f._read = __seofread; f._ub._base = NULL; f._lb._base = NULL; + f._flags2 = 0; + f._ur = 0; f._file = -1; /* No file. */ return __ssvfwscanf_r (ptr, &f, fmt, ap); } diff --git a/newlib/libc/stdlib/arc4random.c b/newlib/libc/stdlib/arc4random.c index 5860d64..7bd9e7c 100644 --- a/newlib/libc/stdlib/arc4random.c +++ b/newlib/libc/stdlib/arc4random.c @@ -86,6 +86,8 @@ _rs_stir(void) { u_char rnd[KEYSZ + IVSZ]; + memset(rnd, 0, (KEYSZ + IVSZ) * sizeof(u_char)); + if (getentropy(rnd, sizeof rnd) == -1) _getentropy_fail(); diff --git a/newlib/libc/time/time.c b/newlib/libc/time/time.c index 93e061b..b431f7a 100644 --- a/newlib/libc/time/time.c +++ b/newlib/libc/time/time.c @@ -37,6 +37,8 @@ time (time_t * t) { struct timeval now; + now.tv_sec = (time_t) -1; + if (_gettimeofday_r (_REENT, &now, NULL) < 0) now.tv_sec = (time_t) -1; |