[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Use %f, not %lf when formatting doubles



commit 0bec9f320b81a85ba3596e9780b1cf7c770dfb31
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Wed May 16 14:26:35 2012 -0400

    Use %f, not %lf when formatting doubles
    
    %f is correct; %lf is only needed with scanf.  Apparently, on some
    old BSDs, %lf is deprecated.
    
    Didn't we do this before?  Yes, we did.  But we only got the
    instances of %lf, not more complicated things like %.5lf .  This
    patch tries to get everything.
    
    Based on a patch for 3894 by grarpamp.
---
 changes/bug3894_fmt_doubles |    4 ++++
 src/or/dirserv.c            |    2 +-
 src/or/geoip.c              |    4 ++--
 src/or/rephist.c            |    6 +++---
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/changes/bug3894_fmt_doubles b/changes/bug3894_fmt_doubles
new file mode 100644
index 0000000..0cd0aa2
--- /dev/null
+++ b/changes/bug3894_fmt_doubles
@@ -0,0 +1,4 @@
+  o Minor bugfixes:
+    - Format more doubles with %f, not %lf. Patch from grarpamp to make
+      Tor build correctly on older BSDs again. Fixes bug 3894; bugfix on
+      Tor 0.2.0.8-alpha.
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 0308d4d..a98b20b 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -1939,7 +1939,7 @@ dirserv_compute_performance_thresholds(routerlist_t *rl)
   log(LOG_INFO, LD_DIRSERV,
       "Cutoffs: For Stable, %lu sec uptime, %lu sec MTBF. "
       "For Fast: %lu bytes/sec. "
-      "For Guard: WFU %.03lf%%, time-known %lu sec, "
+      "For Guard: WFU %.03f%%, time-known %lu sec, "
       "and bandwidth %lu or %lu bytes/sec. We%s have enough stability data.",
       (unsigned long)stable_uptime,
       (unsigned long)stable_mtbf,
diff --git a/src/or/geoip.c b/src/or/geoip.c
index c51142c..8fb4c98 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -1026,9 +1026,9 @@ geoip_dirreq_stats_write(time_t now)
   memset(ns_v2_responses, 0, sizeof(ns_v2_responses));
   memset(ns_v3_responses, 0, sizeof(ns_v3_responses));
   if (!geoip_get_mean_shares(now, &v2_share, &v3_share)) {
-    if (fprintf(out, "dirreq-v2-share %0.2lf%%\n", v2_share*100) < 0)
+    if (fprintf(out, "dirreq-v2-share %0.2f%%\n", v2_share*100) < 0)
       goto done;
-    if (fprintf(out, "dirreq-v3-share %0.2lf%%\n", v3_share*100) < 0)
+    if (fprintf(out, "dirreq-v3-share %0.2f%%\n", v3_share*100) < 0)
       goto done;
   }
 
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 1dd3d94..f05186e 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -838,7 +838,7 @@ rep_hist_record_mtbf_data(time_t now, int missing_means_down)
       format_iso_time(time_buf, hist->start_of_run);
       t = time_buf;
     }
-    PRINTF((f, "+MTBF %lu %.5lf%s%s\n",
+    PRINTF((f, "+MTBF %lu %.5f%s%s\n",
             hist->weighted_run_length, hist->total_run_weights,
             t ? " S=" : "", t ? t : ""));
     t = NULL;
@@ -888,10 +888,10 @@ rep_hist_format_router_status(or_history_t *hist, time_t now)
   tor_asprintf(&cp,
                "%s%s%s"
                "%s%s%s"
-               "wfu %0.3lf\n"
+               "wfu %0.3f\n"
                " weighted-time %lu\n"
                " weighted-uptime %lu\n"
-               "mtbf %0.1lf\n"
+               "mtbf %0.1f\n"
                " weighted-run-length %lu\n"
                " total-run-weights %f\n",
                up?"uptime-started ":"", up?sor_buf:"", up?" UTC\n":"",



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits