Add casts when storing values in a struct timespec.
Fixes -Wconversion warnings on some 32-bit systems where time_t is still 32-bit.
This commit is contained in:
@@ -382,11 +382,11 @@ json_store_timespec(struct json_item *item, struct timespec *ts)
|
|||||||
if (item->type != JSON_NUMBER)
|
if (item->type != JSON_NUMBER)
|
||||||
continue;
|
continue;
|
||||||
if (strcmp(item->name, "seconds") == 0) {
|
if (strcmp(item->name, "seconds") == 0) {
|
||||||
ts->tv_sec = item->u.number;
|
ts->tv_sec = (time_t)item->u.number;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strcmp(item->name, "nanoseconds") == 0) {
|
if (strcmp(item->name, "nanoseconds") == 0) {
|
||||||
ts->tv_nsec = item->u.number;
|
ts->tv_nsec = (long)item->u.number;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -84,7 +84,8 @@ iolog_parse_loginfo_legacy(FILE *fp, const char *iolog_dir,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
*ep = '\0';
|
*ep = '\0';
|
||||||
evlog->submit_time.tv_sec = sudo_strtonum(cp, 0, TIME_T_MAX, &errstr);
|
evlog->submit_time.tv_sec =
|
||||||
|
(time_t)sudo_strtonum(cp, 0, TIME_T_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_warn(U_("%s: time stamp %s: %s"), iolog_dir, cp, errstr);
|
sudo_warn(U_("%s: time stamp %s: %s"), iolog_dir, cp, errstr);
|
||||||
goto done;
|
goto done;
|
||||||
|
@@ -105,7 +105,7 @@ iolog_parse_delay(const char *cp, struct timespec *delay,
|
|||||||
}
|
}
|
||||||
memcpy(numbuf, cp, len);
|
memcpy(numbuf, cp, len);
|
||||||
numbuf[len] = '\0';
|
numbuf[len] = '\0';
|
||||||
delay->tv_sec = sudo_strtonum(numbuf, 0, TIME_T_MAX, &errstr);
|
delay->tv_sec = (time_t)sudo_strtonum(numbuf, 0, TIME_T_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||||
"%s: number of seconds is %s", numbuf, errstr);
|
"%s: number of seconds is %s", numbuf, errstr);
|
||||||
|
@@ -150,8 +150,8 @@ evlog_new(TimeSpec *submit_time, InfoMessage **info_msgs, size_t infolen,
|
|||||||
|
|
||||||
/* Submit time. */
|
/* Submit time. */
|
||||||
if (submit_time != NULL) {
|
if (submit_time != NULL) {
|
||||||
evlog->submit_time.tv_sec = submit_time->tv_sec;
|
evlog->submit_time.tv_sec = (time_t)submit_time->tv_sec;
|
||||||
evlog->submit_time.tv_nsec = submit_time->tv_nsec;
|
evlog->submit_time.tv_nsec = (long)submit_time->tv_nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Default values */
|
/* Default values */
|
||||||
@@ -891,8 +891,8 @@ update_elapsed_time(TimeSpec *delta, struct timespec *elapsed)
|
|||||||
debug_decl(update_elapsed_time, SUDO_DEBUG_UTIL);
|
debug_decl(update_elapsed_time, SUDO_DEBUG_UTIL);
|
||||||
|
|
||||||
/* Cannot use timespecadd since msg doesn't use struct timespec. */
|
/* Cannot use timespecadd since msg doesn't use struct timespec. */
|
||||||
elapsed->tv_sec += delta->tv_sec;
|
elapsed->tv_sec += (time_t)delta->tv_sec;
|
||||||
elapsed->tv_nsec += delta->tv_nsec;
|
elapsed->tv_nsec += (long)delta->tv_nsec;
|
||||||
while (elapsed->tv_nsec >= 1000000000) {
|
while (elapsed->tv_nsec >= 1000000000) {
|
||||||
elapsed->tv_sec++;
|
elapsed->tv_sec++;
|
||||||
elapsed->tv_nsec -= 1000000000;
|
elapsed->tv_nsec -= 1000000000;
|
||||||
|
@@ -588,7 +588,7 @@ cb_server_timeout(struct logsrvd_config *config, const char *str, size_t offset)
|
|||||||
const char *errstr;
|
const char *errstr;
|
||||||
debug_decl(cb_server_timeout, SUDO_DEBUG_UTIL);
|
debug_decl(cb_server_timeout, SUDO_DEBUG_UTIL);
|
||||||
|
|
||||||
timeout = sudo_strtonum(str, 0, TIME_T_MAX, &errstr);
|
timeout = (time_t)sudo_strtonum(str, 0, TIME_T_MAX, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
|
|
||||||
@@ -794,7 +794,7 @@ cb_relay_timeout(struct logsrvd_config *config, const char *str, size_t offset)
|
|||||||
const char *errstr;
|
const char *errstr;
|
||||||
debug_decl(cb_relay_timeout, SUDO_DEBUG_UTIL);
|
debug_decl(cb_relay_timeout, SUDO_DEBUG_UTIL);
|
||||||
|
|
||||||
timeout = sudo_strtonum(str, 0, TIME_T_MAX, &errstr);
|
timeout = (time_t)sudo_strtonum(str, 0, TIME_T_MAX, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
|
|
||||||
@@ -810,7 +810,7 @@ cb_relay_connect_timeout(struct logsrvd_config *config, const char *str, size_t
|
|||||||
const char *errstr;
|
const char *errstr;
|
||||||
debug_decl(cb_relay_connect_timeout, SUDO_DEBUG_UTIL);
|
debug_decl(cb_relay_connect_timeout, SUDO_DEBUG_UTIL);
|
||||||
|
|
||||||
timeout = sudo_strtonum(str, 0, TIME_T_MAX, &errstr);
|
timeout = (time_t)sudo_strtonum(str, 0, TIME_T_MAX, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
|
|
||||||
@@ -843,7 +843,7 @@ cb_retry_interval(struct logsrvd_config *config, const char *str, size_t offset)
|
|||||||
const char *errstr;
|
const char *errstr;
|
||||||
debug_decl(cb_retry_interval, SUDO_DEBUG_UTIL);
|
debug_decl(cb_retry_interval, SUDO_DEBUG_UTIL);
|
||||||
|
|
||||||
interval = sudo_strtonum(str, 0, TIME_T_MAX, &errstr);
|
interval = (time_t)sudo_strtonum(str, 0, TIME_T_MAX, &errstr);
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
|
|
||||||
|
@@ -443,8 +443,8 @@ journal_restart(RestartMessage *msg, uint8_t *buf, size_t buflen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Seek forward to resume point. */
|
/* Seek forward to resume point. */
|
||||||
target.tv_sec = msg->resume_point->tv_sec;
|
target.tv_sec = (time_t)msg->resume_point->tv_sec;
|
||||||
target.tv_nsec = msg->resume_point->tv_nsec;
|
target.tv_nsec = (long)msg->resume_point->tv_nsec;
|
||||||
if (!journal_seek(&target, closure)) {
|
if (!journal_seek(&target, closure)) {
|
||||||
sudo_warn(U_("unable to seek to [%lld, %ld] in journal file %s"),
|
sudo_warn(U_("unable to seek to [%lld, %ld] in journal file %s"),
|
||||||
(long long)target.tv_sec, target.tv_nsec, journal_path);
|
(long long)target.tv_sec, target.tv_nsec, journal_path);
|
||||||
|
@@ -404,8 +404,8 @@ store_exit_local(ExitMessage *msg, uint8_t *buf, size_t len,
|
|||||||
debug_decl(store_exit_local, SUDO_DEBUG_UTIL);
|
debug_decl(store_exit_local, SUDO_DEBUG_UTIL);
|
||||||
|
|
||||||
if (msg->run_time != NULL) {
|
if (msg->run_time != NULL) {
|
||||||
evlog->run_time.tv_sec = msg->run_time->tv_sec;
|
evlog->run_time.tv_sec = (time_t)msg->run_time->tv_sec;
|
||||||
evlog->run_time.tv_nsec = msg->run_time->tv_nsec;
|
evlog->run_time.tv_nsec = (long)msg->run_time->tv_nsec;
|
||||||
}
|
}
|
||||||
evlog->exit_value = msg->exit_value;
|
evlog->exit_value = msg->exit_value;
|
||||||
if (msg->signal != NULL && msg->signal[0] != '\0') {
|
if (msg->signal != NULL && msg->signal[0] != '\0') {
|
||||||
@@ -459,8 +459,8 @@ store_restart_local(RestartMessage *msg, uint8_t *buf, size_t len,
|
|||||||
int iofd;
|
int iofd;
|
||||||
debug_decl(store_restart_local, SUDO_DEBUG_UTIL);
|
debug_decl(store_restart_local, SUDO_DEBUG_UTIL);
|
||||||
|
|
||||||
target.tv_sec = msg->resume_point->tv_sec;
|
target.tv_sec = (time_t)msg->resume_point->tv_sec;
|
||||||
target.tv_nsec = msg->resume_point->tv_nsec;
|
target.tv_nsec = (long)msg->resume_point->tv_nsec;
|
||||||
|
|
||||||
/* We must allocate closure->evlog for iolog_path. */
|
/* We must allocate closure->evlog for iolog_path. */
|
||||||
closure->evlog = calloc(1, sizeof(*closure->evlog));
|
closure->evlog = calloc(1, sizeof(*closure->evlog));
|
||||||
@@ -544,8 +544,8 @@ store_alert_local(AlertMessage *msg, uint8_t *buf, size_t len,
|
|||||||
if (closure->evlog == NULL)
|
if (closure->evlog == NULL)
|
||||||
closure->evlog = evlog;
|
closure->evlog = evlog;
|
||||||
}
|
}
|
||||||
alert_time.tv_sec = msg->alert_time->tv_sec;
|
alert_time.tv_sec = (time_t)msg->alert_time->tv_sec;
|
||||||
alert_time.tv_nsec = msg->alert_time->tv_nsec;
|
alert_time.tv_nsec = (long)msg->alert_time->tv_nsec;
|
||||||
|
|
||||||
if (!eventlog_alert(evlog, 0, &alert_time, msg->reason, NULL)) {
|
if (!eventlog_alert(evlog, 0, &alert_time, msg->reason, NULL)) {
|
||||||
closure->errstr = _("error logging alert event");
|
closure->errstr = _("error logging alert event");
|
||||||
|
@@ -1142,8 +1142,8 @@ handle_commit_point(TimeSpec *commit_point, struct client_closure *closure)
|
|||||||
|
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO, "%s: commit point: [%lld, %d]",
|
sudo_debug_printf(SUDO_DEBUG_INFO, "%s: commit point: [%lld, %d]",
|
||||||
__func__, (long long)commit_point->tv_sec, commit_point->tv_nsec);
|
__func__, (long long)commit_point->tv_sec, commit_point->tv_nsec);
|
||||||
closure->committed.tv_sec = commit_point->tv_sec;
|
closure->committed.tv_sec = (time_t)commit_point->tv_sec;
|
||||||
closure->committed.tv_nsec = commit_point->tv_nsec;
|
closure->committed.tv_nsec = (long)commit_point->tv_nsec;
|
||||||
|
|
||||||
debug_return_bool(true);
|
debug_return_bool(true);
|
||||||
}
|
}
|
||||||
@@ -1518,14 +1518,14 @@ parse_timespec(struct timespec *ts, char *strval)
|
|||||||
*nsecstr++ = '\0';
|
*nsecstr++ = '\0';
|
||||||
|
|
||||||
ts->tv_nsec = 0;
|
ts->tv_nsec = 0;
|
||||||
ts->tv_sec = sudo_strtonum(strval, 0, TIME_T_MAX, &errstr);
|
ts->tv_sec = (time_t)sudo_strtonum(strval, 0, TIME_T_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_warnx(U_("%s: %s"), strval, U_(errstr));
|
sudo_warnx(U_("%s: %s"), strval, U_(errstr));
|
||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nsecstr != NULL) {
|
if (nsecstr != NULL) {
|
||||||
ts->tv_nsec = sudo_strtonum(nsecstr, 0, LONG_MAX, &errstr);
|
ts->tv_nsec = (long)sudo_strtonum(nsecstr, 0, LONG_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
sudo_warnx(U_("%s: %s"), nsecstr, U_(errstr));
|
sudo_warnx(U_("%s: %s"), nsecstr, U_(errstr));
|
||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
|
@@ -999,7 +999,7 @@ store_timespec(const char *str, struct sudo_defs_types *def)
|
|||||||
ts.tv_sec++;
|
ts.tv_sec++;
|
||||||
nsec -= 1000000000;
|
nsec -= 1000000000;
|
||||||
}
|
}
|
||||||
ts.tv_nsec = nsec;
|
ts.tv_nsec = (long)nsec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sign == '-') {
|
if (sign == '-') {
|
||||||
|
@@ -498,7 +498,7 @@ iolog_deserialize_info(struct log_details *details, char * const user_info[],
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strncmp(*cur, "log_server_timeout=", sizeof("log_server_timeout=") - 1) == 0) {
|
if (strncmp(*cur, "log_server_timeout=", sizeof("log_server_timeout=") - 1) == 0) {
|
||||||
details->server_timeout.tv_sec =
|
details->server_timeout.tv_sec = (time_t)
|
||||||
sudo_strtonum(*cur + sizeof("log_server_timeout=") - 1, 1,
|
sudo_strtonum(*cur + sizeof("log_server_timeout=") - 1, 1,
|
||||||
TIME_T_MAX, NULL);
|
TIME_T_MAX, NULL);
|
||||||
continue;
|
continue;
|
||||||
|
@@ -1513,8 +1513,8 @@ handle_commit_point(TimeSpec *commit_point, struct client_closure *closure)
|
|||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
closure->committed.tv_sec = commit_point->tv_sec;
|
closure->committed.tv_sec = (time_t)commit_point->tv_sec;
|
||||||
closure->committed.tv_nsec = commit_point->tv_nsec;
|
closure->committed.tv_nsec = (long)commit_point->tv_nsec;
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"%s: received [%lld, %d], elapsed [%lld, %ld], committed [%lld, %ld]",
|
"%s: received [%lld, %d], elapsed [%lld, %ld], committed [%lld, %ld]",
|
||||||
__func__, (long long)commit_point->tv_sec, commit_point->tv_nsec,
|
__func__, (long long)commit_point->tv_sec, commit_point->tv_nsec,
|
||||||
|
Reference in New Issue
Block a user