[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Use -Wdouble-promotion in GCC >= 4.6
commit 8f2d2933f912c9952453b17b19636c26579e2323
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Mon May 30 13:57:32 2016 -0400
Use -Wdouble-promotion in GCC >= 4.6
This warning triggers on silently promoting a float to a double. In
our code, it's just a sign that somebody used a float by mistake,
since we always prefer double.
---
configure.ac | 1 +
src/or/channel.c | 2 +-
src/or/channeltls.c | 3 ++-
src/test/test_channel.c | 16 ++++++++--------
src/test/test_channeltls.c | 14 +++++++-------
5 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/configure.ac b/configure.ac
index dc3a329..38c922b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1756,6 +1756,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
CFLAGS="$CFLAGS -Wlogical-op"
# and these should be just fine in gcc 4.6
CFLAGS="$CFLAGS -Wmissing-format-attribute -Wsuggest-attribute=noreturn -Wsync-nand -Wtrampolines -Wunused-but-set-parameter -Wunused-but-set-variable -Wvariadic-macros"
+ CFLAGS="$CFLAGS -Wdouble-promotion"
fi
if test "x$have_gcc47" = "xyes"; then
diff --git a/src/or/channel.c b/src/or/channel.c
index 75b16d7..3b81839 100644
--- a/src/or/channel.c
+++ b/src/or/channel.c
@@ -4524,7 +4524,7 @@ channel_update_xmit_queue_size(channel_t *chan)
/* Next, adjust by the overhead factor, if any is available */
if (chan->get_overhead_estimate) {
overhead = chan->get_overhead_estimate(chan);
- if (overhead >= 1.0f) {
+ if (overhead >= 1.0) {
queued = (uint64_t)(queued * overhead);
} else {
/* Ignore silly overhead factors */
diff --git a/src/or/channeltls.c b/src/or/channeltls.c
index 293f010..a7de986 100644
--- a/src/or/channeltls.c
+++ b/src/or/channeltls.c
@@ -462,7 +462,8 @@ channel_tls_get_overhead_estimate_method(channel_t *chan)
* Never estimate more than 2.0; otherwise we get silly large estimates
* at the very start of a new TLS connection.
*/
- if (overhead > 2.0f) overhead = 2.0f;
+ if (overhead > 2.0)
+ overhead = 2.0;
}
log_debug(LD_CHANNEL,
diff --git a/src/test/test_channel.c b/src/test/test_channel.c
index 846e419..79bc5ac 100644
--- a/src/test/test_channel.c
+++ b/src/test/test_channel.c
@@ -33,7 +33,7 @@ static int test_destroy_not_pending_calls = 0;
static int test_doesnt_want_writes_count = 0;
static int test_dumpstats_calls = 0;
static int test_has_waiting_cells_count = 0;
-static double test_overhead_estimate = 1.0f;
+static double test_overhead_estimate = 1.0;
static int test_releases_count = 0;
static circuitmux_t *test_target_cmux = NULL;
static unsigned int test_cmux_cells = 0;
@@ -792,7 +792,7 @@ test_channel_incoming(void *arg)
/* Accept cells to lower layer */
test_chan_accept_cells = 1;
/* Use default overhead factor */
- test_overhead_estimate = 1.0f;
+ test_overhead_estimate = 1.0;
ch = new_fake_channel();
tt_assert(ch);
@@ -881,7 +881,7 @@ test_channel_lifecycle(void *arg)
/* Accept cells to lower layer */
test_chan_accept_cells = 1;
/* Use default overhead factor */
- test_overhead_estimate = 1.0f;
+ test_overhead_estimate = 1.0;
ch1 = new_fake_channel();
tt_assert(ch1);
@@ -989,7 +989,7 @@ test_channel_lifecycle_2(void *arg)
/* Accept cells to lower layer */
test_chan_accept_cells = 1;
/* Use default overhead factor */
- test_overhead_estimate = 1.0f;
+ test_overhead_estimate = 1.0;
ch = new_fake_channel();
tt_assert(ch);
@@ -1136,7 +1136,7 @@ test_channel_multi(void *arg)
/* Accept cells to lower layer */
test_chan_accept_cells = 1;
/* Use default overhead factor */
- test_overhead_estimate = 1.0f;
+ test_overhead_estimate = 1.0;
ch1 = new_fake_channel();
tt_assert(ch1);
@@ -1444,7 +1444,7 @@ test_channel_queue_incoming(void *arg)
/* Accept cells to lower layer */
test_chan_accept_cells = 1;
/* Use default overhead factor */
- test_overhead_estimate = 1.0f;
+ test_overhead_estimate = 1.0;
ch = new_fake_channel();
tt_assert(ch);
@@ -1589,11 +1589,11 @@ test_channel_queue_size(void *arg)
channel_update_xmit_queue_size(ch);
tt_u64_op(ch->bytes_queued_for_xmit, ==, 512);
/* Now try a larger one */
- test_overhead_estimate = 2.0f;
+ test_overhead_estimate = 2.0;
channel_update_xmit_queue_size(ch);
tt_u64_op(ch->bytes_queued_for_xmit, ==, 1024);
/* Go back to 1.0 */
- test_overhead_estimate = 1.0f;
+ test_overhead_estimate = 1.0;
channel_update_xmit_queue_size(ch);
tt_u64_op(ch->bytes_queued_for_xmit, ==, 512);
/* Check the global estimate too */
diff --git a/src/test/test_channeltls.c b/src/test/test_channeltls.c
index f5fa50c..394612f 100644
--- a/src/test/test_channeltls.c
+++ b/src/test/test_channeltls.c
@@ -206,31 +206,31 @@ test_channeltls_overhead_estimate(void *arg)
ch = channel_tls_connect(&test_addr, 567, test_digest);
tt_assert(ch != NULL);
- /* First case: silly low ratios should get clamped to 1.0f */
+ /* First case: silly low ratios should get clamped to 1.0 */
tlschan = BASE_CHAN_TO_TLS(ch);
tt_assert(tlschan != NULL);
tlschan->conn->bytes_xmitted = 128;
tlschan->conn->bytes_xmitted_by_tls = 64;
r = ch->get_overhead_estimate(ch);
- tt_assert(fabs(r - 1.0f) < 1E-12);
+ tt_assert(fabs(r - 1.0) < 1E-12);
tlschan->conn->bytes_xmitted_by_tls = 127;
r = ch->get_overhead_estimate(ch);
- tt_assert(fabs(r - 1.0f) < 1E-12);
+ tt_assert(fabs(r - 1.0) < 1E-12);
/* Now middle of the range */
tlschan->conn->bytes_xmitted_by_tls = 192;
r = ch->get_overhead_estimate(ch);
- tt_assert(fabs(r - 1.5f) < 1E-12);
+ tt_assert(fabs(r - 1.5) < 1E-12);
- /* Now above the 2.0f clamp */
+ /* Now above the 2.0 clamp */
tlschan->conn->bytes_xmitted_by_tls = 257;
r = ch->get_overhead_estimate(ch);
- tt_assert(fabs(r - 2.0f) < 1E-12);
+ tt_assert(fabs(r - 2.0) < 1E-12);
tlschan->conn->bytes_xmitted_by_tls = 512;
r = ch->get_overhead_estimate(ch);
- tt_assert(fabs(r - 2.0f) < 1E-12);
+ tt_assert(fabs(r - 2.0) < 1E-12);
done:
if (ch) {
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits