*: use long long to print time_t
Since we can't assume time_t to be long, int, or even long long, this
consistently uses %lld/long long (or %llu/unsigned long long in a few
cases) to print time_t/susecond_t values. This should fix a bunch of
warnings, on NetBSD in particular.
(Unfortunately, there seems to be no "PRId64" style printing macro for
time_t...)
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/babeld/babeld.c b/babeld/babeld.c
index 1ae3f04..eaa91b7 100644
--- a/babeld/babeld.c
+++ b/babeld/babeld.c
@@ -328,8 +328,8 @@
/* if there is no timeout, we must wait. */
if(timeval_compare(&tv, &babel_now) > 0) {
timeval_minus(&tv, &tv, &babel_now);
- debugf(BABEL_DEBUG_TIMEOUT, "babel main loop : timeout: %ld msecs",
- tv.tv_sec * 1000 + tv.tv_usec / 1000);
+ debugf(BABEL_DEBUG_TIMEOUT, "babel main loop : timeout: %lld msecs",
+ tv.tv_sec * 1000LL + tv.tv_usec / 1000LL);
/* it happens often to have less than 1 ms, it's bad. */
timeval_add_msec(&tv, &tv, 300);
babel_set_timer(&tv);
diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c
index 0ffafb7..1da1e69 100644
--- a/bgpd/bgp_damp.c
+++ b/bgpd/bgp_damp.c
@@ -529,15 +529,15 @@
&& bgp_damp_cfg.reuse_limit == DEFAULT_REUSE
&& bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS
&& bgp_damp_cfg.max_suppress_time == bgp_damp_cfg.half_life*4)
- vty_out (vty, " bgp dampening %ld%s",
- bgp_damp_cfg.half_life/60,
+ vty_out (vty, " bgp dampening %lld%s",
+ bgp_damp_cfg.half_life/60LL,
VTY_NEWLINE);
else
- vty_out (vty, " bgp dampening %ld %d %d %ld%s",
- bgp_damp_cfg.half_life/60,
+ vty_out (vty, " bgp dampening %lld %d %d %lld%s",
+ bgp_damp_cfg.half_life/60LL,
bgp_damp_cfg.reuse_limit,
bgp_damp_cfg.suppress_value,
- bgp_damp_cfg.max_suppress_time/60,
+ bgp_damp_cfg.max_suppress_time/60LL,
VTY_NEWLINE);
}
diff --git a/isisd/isis_adjacency.c b/isisd/isis_adjacency.c
index 414885f..a352436 100644
--- a/isisd/isis_adjacency.c
+++ b/isisd/isis_adjacency.c
@@ -396,7 +396,8 @@
vty_out (vty, "%-13s", adj_state2string (adj->adj_state));
now = time (NULL);
if (adj->last_upd)
- vty_out (vty, "%-9lu", adj->last_upd + adj->hold_time - now);
+ vty_out (vty, "%-9llu",
+ (unsigned long long)adj->last_upd + adj->hold_time - now);
else
vty_out (vty, "- ");
vty_out (vty, "%-10s", snpa_print (adj->snpa));
diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c
index fd93efa..a4cbba6 100644
--- a/isisd/isis_spf.c
+++ b/isisd/isis_spf.c
@@ -1456,8 +1456,8 @@
assert (area->is_type & level);
if (isis->debugs & DEBUG_SPF_EVENTS)
- zlog_debug ("ISIS-Spf (%s) L%d SPF schedule called, lastrun %d sec ago",
- area->area_tag, level, diff);
+ zlog_debug ("ISIS-Spf (%s) L%d SPF schedule called, lastrun %lld sec ago",
+ area->area_tag, level, (long long)diff);
if (spftree->pending)
return ISIS_OK;
@@ -1476,8 +1476,9 @@
area->min_spf_interval[1] - diff);
if (isis->debugs & DEBUG_SPF_EVENTS)
- zlog_debug ("ISIS-Spf (%s) L%d SPF scheduled %d sec from now",
- area->area_tag, level, area->min_spf_interval[level-1] - diff);
+ zlog_debug ("ISIS-Spf (%s) L%d SPF scheduled %lld sec from now",
+ area->area_tag, level,
+ (long long)(area->min_spf_interval[level-1] - diff));
spftree->pending = 1;
diff --git a/isisd/isisd.c b/isisd/isisd.c
index ce6a262..2431557 100644
--- a/isisd/isisd.c
+++ b/isisd/isisd.c
@@ -1297,8 +1297,8 @@
vty_out_timestr(vty, spftree->last_run_timestamp);
vty_out (vty, "%s", VTY_NEWLINE);
- vty_out (vty, " last run duration : %u msec%s",
- spftree->last_run_duration, VTY_NEWLINE);
+ vty_out (vty, " last run duration : %llu msec%s",
+ (unsigned long long)spftree->last_run_duration, VTY_NEWLINE);
vty_out (vty, " run count : %d%s",
spftree->runcount, VTY_NEWLINE);
diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c
index d0e9101..47a655c 100644
--- a/ospf6d/ospf6_spf.c
+++ b/ospf6d/ospf6_spf.c
@@ -601,11 +601,12 @@
ospf6_spf_reason_string(ospf6->spf_reason, rbuf, sizeof(rbuf));
if (IS_OSPF6_DEBUG_SPF (PROCESS) || IS_OSPF6_DEBUG_SPF (TIME))
- zlog_debug ("SPF runtime: %ld sec %ld usec",
- runtime.tv_sec, runtime.tv_usec);
+ zlog_debug ("SPF runtime: %lld sec %lld usec",
+ (long long)runtime.tv_sec, (long long)runtime.tv_usec);
- zlog_info("SPF processing: # Areas: %d, SPF runtime: %ld sec %ld usec, "
- "Reason: %s\n", areas_processed, runtime.tv_sec, runtime.tv_usec,
+ zlog_info("SPF processing: # Areas: %d, SPF runtime: %lld sec %lld usec, "
+ "Reason: %s\n", areas_processed,
+ (long long)runtime.tv_sec, (long long)runtime.tv_usec,
rbuf);
ospf6->last_spf_reason = ospf6->spf_reason;
ospf6_reset_spf_reason(ospf6);
diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c
index e4e6f17..7fffba8 100644
--- a/ospf6d/ospf6_top.c
+++ b/ospf6d/ospf6_top.c
@@ -663,8 +663,9 @@
timerstring(&result, buf, sizeof(buf));
ospf6_spf_reason_string(o->last_spf_reason, rbuf, sizeof(rbuf));
vty_out(vty, "last executed %s ago, reason %s%s", buf, rbuf, VNL);
- vty_out (vty, " Last SPF duration %ld sec %ld usec%s",
- o->ts_spf_duration.tv_sec, o->ts_spf_duration.tv_usec, VNL);
+ vty_out (vty, " Last SPF duration %lld sec %lld usec%s",
+ (long long)o->ts_spf_duration.tv_sec,
+ (long long)o->ts_spf_duration.tv_usec, VNL);
}
else
vty_out(vty, "has not been run$%s", VNL);
diff --git a/ospf6d/ospf6d.h b/ospf6d/ospf6d.h
index 4122b30..9e2efb4 100644
--- a/ospf6d/ospf6d.h
+++ b/ospf6d/ospf6d.h
@@ -71,19 +71,19 @@
} \
} while (0)
#endif /*timersub*/
-#define timerstring(tv, buf, size) \
- do { \
- if ((tv)->tv_sec / 60 / 60 / 24) \
- snprintf (buf, size, "%ldd%02ld:%02ld:%02ld", \
- (tv)->tv_sec / 60 / 60 / 24, \
- (tv)->tv_sec / 60 / 60 % 24, \
- (tv)->tv_sec / 60 % 60, \
- (tv)->tv_sec % 60); \
- else \
- snprintf (buf, size, "%02ld:%02ld:%02ld", \
- (tv)->tv_sec / 60 / 60 % 24, \
- (tv)->tv_sec / 60 % 60, \
- (tv)->tv_sec % 60); \
+#define timerstring(tv, buf, size) \
+ do { \
+ if ((tv)->tv_sec / 60 / 60 / 24) \
+ snprintf (buf, size, "%lldd%02lld:%02lld:%02lld", \
+ (tv)->tv_sec / 60LL / 60 / 24, \
+ (tv)->tv_sec / 60LL / 60 % 24, \
+ (tv)->tv_sec / 60LL % 60, \
+ (tv)->tv_sec % 60LL); \
+ else \
+ snprintf (buf, size, "%02lld:%02lld:%02lld", \
+ (tv)->tv_sec / 60LL / 60 % 24, \
+ (tv)->tv_sec / 60LL % 60, \
+ (tv)->tv_sec % 60LL); \
} while (0)
#define timerstring_local(tv, buf, size) \
do { \
diff --git a/ospfd/ospf_ase.c b/ospfd/ospf_ase.c
index 8aedc80..04240c1 100644
--- a/ospfd/ospf_ase.c
+++ b/ospfd/ospf_ase.c
@@ -679,8 +679,8 @@
quagga_gettime(QUAGGA_CLK_MONOTONIC, &stop_time);
- zlog_info ("SPF Processing Time(usecs): External Routes: %ld\n",
- (stop_time.tv_sec - start_time.tv_sec)*1000000L+
+ zlog_info ("SPF Processing Time(usecs): External Routes: %lld\n",
+ (stop_time.tv_sec - start_time.tv_sec)*1000000LL+
(stop_time.tv_usec - start_time.tv_usec));
}
return 0;
diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c
index ebcc717..2e4e69d 100644
--- a/ospfd/ospf_dump.c
+++ b/ospfd/ospf_dump.c
@@ -299,13 +299,13 @@
else if (d)
snprintf (buf, size, "%1ldd%02ldh%02ldm", d, h, m);
else if (h)
- snprintf (buf, size, "%ldh%02ldm%02lds", h, m, t->tv_sec);
+ snprintf (buf, size, "%ldh%02ldm%02lds", h, m, (long)t->tv_sec);
else if (m)
- snprintf (buf, size, "%ldm%02lds", m, t->tv_sec);
+ snprintf (buf, size, "%ldm%02lds", m, (long)t->tv_sec);
else if (ms)
- snprintf (buf, size, "%ld.%03lds", t->tv_sec, ms);
+ snprintf (buf, size, "%ld.%03lds", (long)t->tv_sec, ms);
else
- snprintf (buf, size, "%ld usecs", t->tv_usec);
+ snprintf (buf, size, "%ld usecs", (long)t->tv_usec);
return buf;
}
diff --git a/watchquagga/watchquagga.c b/watchquagga/watchquagga.c
index c1c8892..c34816c 100644
--- a/watchquagga/watchquagga.c
+++ b/watchquagga/watchquagga.c
@@ -381,7 +381,7 @@
time_elapsed(&delay,&restart->time);
zlog_warn("Warning: %s %s child process %d still running after "
"%ld seconds, sending signal %d",
- restart->what,restart->name,(int)restart->pid,delay.tv_sec,
+ restart->what,restart->name,(int)restart->pid, (long)delay.tv_sec,
(restart->kills ? SIGKILL : SIGTERM));
kill(-restart->pid,(restart->kills ? SIGKILL : SIGTERM));
restart->kills++;
@@ -654,15 +654,17 @@
{
dmn->state = DAEMON_UP;
zlog_warn("%s state -> up : echo response received after %ld.%06ld "
- "seconds", dmn->name,delay.tv_sec,delay.tv_usec);
+ "seconds", dmn->name,
+ (long)delay.tv_sec, (long)delay.tv_usec);
}
else
zlog_warn("%s: slow echo response finally received after %ld.%06ld "
- "seconds", dmn->name,delay.tv_sec,delay.tv_usec);
+ "seconds", dmn->name,
+ (long)delay.tv_sec, (long)delay.tv_usec);
}
else if (gs.loglevel > LOG_DEBUG+1)
zlog_debug("%s: echo response received after %ld.%06ld seconds",
- dmn->name,delay.tv_sec,delay.tv_usec);
+ dmn->name, (long)delay.tv_sec, (long)delay.tv_usec);
SET_READ_HANDLER(dmn);
if (dmn->t_wakeup)