Quiet format string warnings in graph_db.
authorEmil Mikulic <emikulic@gmail.com>
Sat, 25 Jan 2014 08:18:50 +0000 (19:18 +1100)
committerEmil Mikulic <emikulic@gmail.com>
Sat, 25 Jan 2014 14:07:28 +0000 (01:07 +1100)
graph_db.c
str.h

index 3f503c0..394fbbc 100644 (file)
@@ -303,7 +303,7 @@ struct str *html_front_page(void) {
    str_append(buf, "</span>");
    if (abs(d_real - d_mono) > 1)
       str_appendf(buf, " (real time is off by %qd sec)",
-                  (int64_t)d_real - (int64_t)d_mono);
+                  (qd)d_real - (qd)d_mono);
 
    if (strftime(start_when, sizeof(start_when),
       "%Y-%m-%d %H:%M:%S %Z%z", localtime(&start_real)) != 0)
@@ -315,9 +315,10 @@ struct str *html_front_page(void) {
       "(<span id=\"pc\">%'u</span> <b>captured,</b> "
       "<span id=\"pd\">%'u</span> <b>dropped)</b><br>\n"
       "</p>\n",
-      acct_total_bytes,
-      acct_total_packets,
-      cap_pkts_recv, cap_pkts_drop);
+      (qu)acct_total_bytes,
+      (qu)acct_total_packets,
+      cap_pkts_recv,
+      cap_pkts_drop);
 
    str_append(buf,
       "<div id=\"graphs\">\n"
@@ -362,7 +363,10 @@ struct str *xml_graphs(void) {
    struct str *buf = str_make(), *rf;
 
    str_appendf(buf, "<graphs tp=\"%qu\" tb=\"%qu\" pc=\"%u\" pd=\"%u\" rf=\"",
-      acct_total_packets, acct_total_bytes, cap_pkts_recv, cap_pkts_drop);
+      (qu)acct_total_packets,
+      (qu)acct_total_bytes,
+      cap_pkts_recv,
+      cap_pkts_drop);
    rf = length_of_time(now_real() - start_real);
    str_appendstr(buf, rf);
    str_free(rf);
@@ -377,7 +381,9 @@ struct str *xml_graphs(void) {
          j = (j + 1) % g->num_bars;
          /* <element pos="" in="" out=""/> */
          str_appendf(buf, "<e p=\"%u\" i=\"%qu\" o=\"%qu\"/>\n",
-            g->offset + j, g->in[j], g->out[j]);
+            g->offset + j,
+            (qu)g->in[j],
+            (qu)g->out[j]);
       } while (j != g->pos);
       str_appendf(buf, "</%s>\n", g->unit);
    }
diff --git a/str.h b/str.h
index 24a8ce1..bd14c2f 100644 (file)
--- a/str.h
+++ b/str.h
 #include <stdarg.h>
 #include <stdint.h>  /* for uint64_t */
 
+typedef long long   signed int qd; /* as in appendf("%qd") */
 typedef long long unsigned int qu; /* as in appendf("%qu") */
 typedef long long unsigned int llu; /* as in printf("%llu") */
 
-_Static_assert(sizeof(qu) == sizeof(uint64_t), "qu must be uint64_t");
-_Static_assert(sizeof(llu) == sizeof(uint64_t), "llu must be uint64_t");
+_Static_assert(sizeof(qd) == sizeof(int64_t), "qd must be uint64_t sized");
+_Static_assert(sizeof(qu) == sizeof(uint64_t), "qu must be uint64_t sized");
+_Static_assert(sizeof(llu) == sizeof(uint64_t), "llu must be uint64_t sized");
 
 /* Note: the contents are 8-bit clean and not zero terminated! */