]> git.puffer.fish Git - matthieu/frr.git/commitdiff
*: use long long to print time_t
authorDavid Lamparter <equinox@opensourcerouting.org>
Tue, 3 Mar 2015 07:48:11 +0000 (08:48 +0100)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 30 May 2016 01:08:04 +0000 (21:08 -0400)
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>
(cherry picked from commit ef008d2f8dc8f7160d8a3d24a15f2fad79ef3242)

bgpd/bgp_damp.c
isisd/isis_adjacency.c
isisd/isis_spf.c
isisd/isisd.c
ospf6d/ospf6_spf.c
ospf6d/ospf6_top.c
ospf6d/ospf6d.h
ospfd/ospf_ase.c
ospfd/ospf_dump.c
watchquagga/watchquagga.c

index c1ab04407b05796e30eea6a59813b60f7911ece2..2e2dc42ad12c44cd1a7fa4289e513468ef9c0728 100644 (file)
@@ -530,15 +530,15 @@ bgp_config_write_damp (struct vty *vty)
           && 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);
 }
 
index bfd43d454bd32c5c0ec078eefe11e5ff14f1c3db..c7ab83ba0bef62924a86fc4646f692216e223967 100644 (file)
@@ -390,7 +390,8 @@ isis_adj_print_vty (struct isis_adjacency *adj, struct vty *vty, char detail)
       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));
index 84c89bf61e0b8c08ad42fd28b7b637187f0573f6..d5ac85ef50ba93edd61bbdf91edebb418690f1bb 100644 (file)
@@ -1472,7 +1472,8 @@ isis_spf_schedule6 (struct isis_area *area, int level)
 
   if (isis->debugs & DEBUG_SPF_EVENTS)
     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));
+                area->area_tag, level,
+               (long long)(area->min_spf_interval[level-1] - diff));
 
   spftree->pending = 1;
 
index c1f83e1d0ea43637e165c3cc7f2aa3869044d6de..228d2bcb31f2faa620374a407ed3e3ef87bf483f 100644 (file)
@@ -1364,8 +1364,8 @@ DEFUN (show_isis_summary,
       vty_out_timestr(vty, spftree->last_run_timestamp);
       vty_out (vty, "%s", VTY_NEWLINE);
 
-      vty_out (vty, "      last run duration : %ld 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);
index fda3bb5fb87b23890d543cbcaf687b5548803b7a..7dc4801a8d18c60c55c0794874eb971c83b9c42a 100644 (file)
@@ -651,11 +651,12 @@ ospf6_spf_calculation_thread (struct thread *t)
   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);
index 350e8ac9fdf686b1265e387cfb50ee5e7ba34359..b4e937a63aece1ae23539a4706ef15641ab65e92 100644 (file)
@@ -725,8 +725,9 @@ ospf6_show (struct vty *vty, struct ospf6 *o)
       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);
index 4122b3093003d4c88f3149e9536fdaf76aca2bef..9e2efb41d716969532c240d2817746e6aa55b076 100644 (file)
@@ -71,19 +71,19 @@ extern struct thread_master *master;
       }                                               \
   } 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 {                                                    \
index af1abfbc93944af32096b1d845e7dc0a92a24355..74c1711ef145e4fbebf758cd9a08f18b0b573b7c 100644 (file)
@@ -679,8 +679,8 @@ ospf_ase_calculate_timer (struct thread *t)
 
       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;
index 4c1f0549ebbc0ab115fde4f49f49dbc1ebcc66ac..56dac83b7c434d9768d7dd920633d111d94209e9 100644 (file)
@@ -299,13 +299,13 @@ ospf_timeval_dump (struct timeval *t, char *buf, size_t size)
   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;
 }
index 5cb224a45ab2530add57bd3f2f4eb7fcf35b6c39..e882653e3853028e07b49f0a848e4cb9d72a1198 100644 (file)
@@ -389,7 +389,7 @@ restart_kill(struct thread *t_kill)
   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++;
@@ -662,15 +662,17 @@ handle_read(struct thread *t_read)
        {
          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)