Fix some Coverity Scan errors.
This commit is contained in:
parent
dd1122e21c
commit
d92d3a3c4a
|
@ -7,6 +7,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
unsigned sleep(unsigned seconds)
|
unsigned sleep(unsigned seconds)
|
||||||
{
|
{
|
||||||
|
@ -15,7 +16,7 @@ unsigned sleep(unsigned seconds)
|
||||||
ts.tv_sec = seconds;
|
ts.tv_sec = seconds;
|
||||||
ts.tv_nsec = 0;
|
ts.tv_nsec = 0;
|
||||||
if (!nanosleep(&ts,&ts)) return 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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ int usleep(useconds_t useconds)
|
||||||
ts.tv_sec = (long int)useconds / 1000000;
|
ts.tv_sec = (long int)useconds / 1000000;
|
||||||
ts.tv_nsec = ((long int)useconds % 1000000) * 1000;
|
ts.tv_nsec = ((long int)useconds % 1000000) * 1000;
|
||||||
if (!nanosleep(&ts,&ts)) return 0;
|
if (!nanosleep(&ts,&ts)) return 0;
|
||||||
if (errno == EINTR) return ts.tv_sec;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -427,6 +427,8 @@ swscanf (const wchar_t *__restrict str, const wchar_t *__restrict fmt, ...)
|
||||||
f._read = __seofread;
|
f._read = __seofread;
|
||||||
f._ub._base = NULL;
|
f._ub._base = NULL;
|
||||||
f._lb._base = NULL;
|
f._lb._base = NULL;
|
||||||
|
f._flags2 = 0;
|
||||||
|
f._ur = 0;
|
||||||
f._file = -1; /* No file. */
|
f._file = -1; /* No file. */
|
||||||
va_start (ap, fmt);
|
va_start (ap, fmt);
|
||||||
ret = __ssvfwscanf_r (_REENT, &f, fmt, ap);
|
ret = __ssvfwscanf_r (_REENT, &f, fmt, ap);
|
||||||
|
|
|
@ -53,6 +53,8 @@ _vswscanf_r (struct _reent *ptr, const wchar_t *str, const wchar_t *fmt,
|
||||||
f._read = __seofread;
|
f._read = __seofread;
|
||||||
f._ub._base = NULL;
|
f._ub._base = NULL;
|
||||||
f._lb._base = NULL;
|
f._lb._base = NULL;
|
||||||
|
f._flags2 = 0;
|
||||||
|
f._ur = 0;
|
||||||
f._file = -1; /* No file. */
|
f._file = -1; /* No file. */
|
||||||
return __ssvfwscanf_r (ptr, &f, fmt, ap);
|
return __ssvfwscanf_r (ptr, &f, fmt, ap);
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,8 @@ _rs_stir(void)
|
||||||
{
|
{
|
||||||
u_char rnd[KEYSZ + IVSZ];
|
u_char rnd[KEYSZ + IVSZ];
|
||||||
|
|
||||||
|
memset(rnd, 0, (KEYSZ + IVSZ) * sizeof(u_char));
|
||||||
|
|
||||||
if (getentropy(rnd, sizeof rnd) == -1)
|
if (getentropy(rnd, sizeof rnd) == -1)
|
||||||
_getentropy_fail();
|
_getentropy_fail();
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@ time (time_t * t)
|
||||||
{
|
{
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
|
|
||||||
|
now.tv_sec = (time_t) -1;
|
||||||
|
|
||||||
if (_gettimeofday_r (_REENT, &now, NULL) < 0)
|
if (_gettimeofday_r (_REENT, &now, NULL) < 0)
|
||||||
now.tv_sec = (time_t) -1;
|
now.tv_sec = (time_t) -1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue