diff options
author | Ruediger Meier | 2016-02-12 14:30:52 +0100 |
---|---|---|
committer | Ruediger Meier | 2016-02-12 14:32:42 +0100 |
commit | c2114018018b836b743265ef6014387952219d94 (patch) | |
tree | 5cceac23f7b4c0d922fd79c647b04bc404eff5a3 | |
parent | travis: install mdadm (diff) | |
download | kernel-qcow2-util-linux-c2114018018b836b743265ef6014387952219d94.tar.gz kernel-qcow2-util-linux-c2114018018b836b743265ef6014387952219d94.tar.xz kernel-qcow2-util-linux-c2114018018b836b743265ef6014387952219d94.zip |
misc: always cast timeval.tv_usec to long rather than int
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
-rw-r--r-- | sys-utils/dmesg.c | 15 | ||||
-rw-r--r-- | sys-utils/hwclock.c | 35 |
2 files changed, 26 insertions, 24 deletions
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index fae6f8754..0bf77af8d 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -835,7 +835,7 @@ static char *iso_8601_time(struct dmesg_control *ctl, struct dmesg_record *rec, return buf; } len = strlen(buf); - snprintf(buf + len, bufsiz - len, ",%06d", (int)rec->tv.tv_usec); + snprintf(buf + len, bufsiz - len, ",%06ld", (long)rec->tv.tv_usec); len = strlen(buf); strftime(buf + len, bufsiz - len, "%z", &tm); return buf; @@ -894,10 +894,10 @@ static void print_record(struct dmesg_control *ctl, * backward compatibility with syslog(2) buffers only */ if (ctl->raw) { - ctl->indent = printf("<%d>[%5d.%06d] ", + ctl->indent = printf("<%d>[%5ld.%06ld] ", LOG_MAKEPRI(rec->facility, rec->level), - (int) rec->tv.tv_sec, - (int) rec->tv.tv_usec); + (long) rec->tv.tv_sec, + (long) rec->tv.tv_usec); goto mesg; } @@ -948,11 +948,12 @@ static void print_record(struct dmesg_control *ctl, ctl->lasttm = cur; break; case DMESG_TIMEFTM_TIME: - ctl->indent = printf("[%5d.%06d] ", (int)rec->tv.tv_sec, (int)rec->tv.tv_usec); + ctl->indent = printf("[%5ld.%06ld] ", + (long)rec->tv.tv_sec, (long)rec->tv.tv_usec); break; case DMESG_TIMEFTM_TIME_DELTA: - ctl->indent = printf("[%5d.%06d <%12.06f>] ", (int)rec->tv.tv_sec, - (int)rec->tv.tv_usec, record_count_delta(ctl, rec)); + ctl->indent = printf("[%5ld.%06ld <%12.06f>] ", (long)rec->tv.tv_sec, + (long)rec->tv.tv_usec, record_count_delta(ctl, rec)); break; case DMESG_TIMEFTM_ISO8601: ctl->indent = printf("%s ", iso_8601_time(ctl, rec, buf, sizeof(buf))); diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index 2eb21accb..f50739b50 100644 --- a/sys-utils/hwclock.c +++ b/sys-utils/hwclock.c @@ -610,18 +610,18 @@ set_hardware_clock_exact(const time_t sethwtime, if (ticksize < 0) { if (debug) printf(_("time jumped backward %.6f seconds " - "to %ld.%06d - retargeting\n"), + "to %ld.%06ld - retargeting\n"), ticksize, (long)nowsystime.tv_sec, - (int)nowsystime.tv_usec); + (long)nowsystime.tv_usec); /* The retarget is handled at the end of the loop. */ } else if (deltavstarget < 0) { /* deltavstarget < 0 if current time < target time */ if (debug >= 2) - printf(_("%ld.%06d < %ld.%06d (%.6f)\n"), + printf(_("%ld.%06ld < %ld.%06ld (%.6f)\n"), (long)nowsystime.tv_sec, - (int)nowsystime.tv_usec, + (long)nowsystime.tv_usec, (long)targetsystime.tv_sec, - (int)targetsystime.tv_usec, + (long)targetsystime.tv_usec, deltavstarget); continue; /* not there yet - keep spinning */ } else if (deltavstarget <= target_time_tolerance_secs) { @@ -633,12 +633,12 @@ set_hardware_clock_exact(const time_t sethwtime, * aim for the next opportunity. */ if (debug) - printf(_("missed it - %ld.%06d is too far " - "past %ld.%06d (%.6f > %.6f)\n"), + printf(_("missed it - %ld.%06ld is too far " + "past %ld.%06ld (%.6f > %.6f)\n"), (long)nowsystime.tv_sec, - (int)nowsystime.tv_usec, + (long)nowsystime.tv_usec, (long)targetsystime.tv_sec, - (int)targetsystime.tv_usec, + (long)targetsystime.tv_usec, deltavstarget, target_time_tolerance_secs); target_time_tolerance_secs += tolerance_incr_secs; @@ -661,14 +661,14 @@ set_hardware_clock_exact(const time_t sethwtime, - RTC_SET_DELAY_SECS /* don't count this */ + 0.5 /* for rounding */); if (debug) - printf(_("%ld.%06d is close enough to %ld.%06d (%.6f < %.6f)\n" - "Set RTC to %ld (%ld + %d; refsystime = %ld.%06d)\n"), - (long)nowsystime.tv_sec, (int)nowsystime.tv_usec, - (long)targetsystime.tv_sec, (int)targetsystime.tv_usec, + printf(_("%ld.%06ld is close enough to %ld.%06ld (%.6f < %.6f)\n" + "Set RTC to %ld (%ld + %d; refsystime = %ld.%06ld)\n"), + (long)nowsystime.tv_sec, (long)nowsystime.tv_usec, + (long)targetsystime.tv_sec, (long)targetsystime.tv_usec, deltavstarget, target_time_tolerance_secs, (long)newhwtime, (long)sethwtime, (int)(newhwtime - sethwtime), - (long)refsystime.tv_sec, (int)refsystime.tv_usec); + (long)refsystime.tv_sec, (long)refsystime.tv_usec); set_hardware_clock(newhwtime, universal, testing); } @@ -693,7 +693,8 @@ display_time(const bool hclock_valid, struct timeval hwctime) lt = localtime(&hwctime.tv_sec); strftime(ctime_now, sizeof(ctime_now), format, lt); - printf(_("%s and %06d microseconds\n"), ctime_now, (int)hwctime.tv_usec); + printf(_("%s and %06ld microseconds\n"), + ctime_now, (long)hwctime.tv_usec); } } @@ -1099,8 +1100,8 @@ calculate_adjustment(const double factor, "Time since last adjustment is %d seconds\n", (int)(systime - last_time)), (int)(systime - last_time)); - printf(_("Calculated Hardware Clock drift is %ld.%06d seconds\n"), - (long)tdrift_p->tv_sec, (int)tdrift_p->tv_usec); + printf(_("Calculated Hardware Clock drift is %ld.%06ld seconds\n"), + (long)tdrift_p->tv_sec, (long)tdrift_p->tv_usec); } } |