public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Fix some Coverity Scan errors.
@ 2022-08-31 19:19 Jeff Johnston
0 siblings, 0 replies; only message in thread
From: Jeff Johnston @ 2022-08-31 19:19 UTC (permalink / raw)
To: newlib-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=d92d3a3c4a7af1ebe56d58c32986ab410f6071ec
commit d92d3a3c4a7af1ebe56d58c32986ab410f6071ec
Author: Jeff Johnston <jjohnstn@redhat.com>
Date: Wed Aug 31 15:18:08 2022 -0400
Fix some Coverity Scan errors.
Diff:
---
newlib/libc/posix/sleep.c | 3 ++-
newlib/libc/posix/usleep.c | 1 -
newlib/libc/stdio/swscanf.c | 2 ++
newlib/libc/stdio/vswscanf.c | 2 ++
newlib/libc/stdlib/arc4random.c | 2 ++
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 f7c780ef0..0d6cd710d 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 9322b6551..cc1b31408 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 5514e68c0..578ac3c93 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 13b61f4a3..415c98b0f 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 5860d644a..7bd9e7c5e 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 93e061b83..b431f7ae5 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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-08-31 19:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-31 19:19 [newlib-cygwin] Fix some Coverity Scan errors Jeff Johnston
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).