]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
misc: always cast timeval.tv_usec to long rather than int
authorRuediger Meier <ruediger.meier@ga-group.nl>
Fri, 12 Feb 2016 13:30:52 +0000 (14:30 +0100)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Fri, 12 Feb 2016 13:32:42 +0000 (14:32 +0100)
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
sys-utils/dmesg.c
sys-utils/hwclock.c

index fae6f8754c1e487ee439c6afd930baaf3bb106dd..0bf77af8db911d0b1e410cf540bffcfb5a45f2e7 100644 (file)
@@ -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)));
index 2eb21accb3da7c372f8f446a6daaacd22f017be1..f50739b503fc7ef4f06da1d1cf2451a2d802f350 100644 (file)
@@ -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);
        }
 }