aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-05-30 12:54:31 -0400
committerNick Mathewson <nickm@torproject.org>2016-06-11 10:11:52 -0400
commit493499a3399f8a8532b4b2a80006c033e8f64c58 (patch)
treefb1965c627838137ecd4634fba00cbcccd253372 /src/or
parent2ff20c93a5ec753a0c46ca5ecd991b8e2020f7d0 (diff)
downloadtor-493499a3399f8a8532b4b2a80006c033e8f64c58.tar.gz
tor-493499a3399f8a8532b4b2a80006c033e8f64c58.zip
Add -Wfloat-conversion for GCC >= 4.9
This caught quite a few minor issues in our unit tests and elsewhere in our code.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/channel.c2
-rw-r--r--src/or/config.c4
-rw-r--r--src/or/confparse.c4
-rw-r--r--src/or/routerlist.c2
4 files changed, 6 insertions, 6 deletions
diff --git a/src/or/channel.c b/src/or/channel.c
index f3939399b0..75b16d707f 100644
--- a/src/or/channel.c
+++ b/src/or/channel.c
@@ -4525,7 +4525,7 @@ channel_update_xmit_queue_size(channel_t *chan)
if (chan->get_overhead_estimate) {
overhead = chan->get_overhead_estimate(chan);
if (overhead >= 1.0f) {
- queued *= overhead;
+ queued = (uint64_t)(queued * overhead);
} else {
/* Ignore silly overhead factors */
log_notice(LD_CHANNEL, "Ignoring silly overhead factor %f", overhead);
diff --git a/src/or/config.c b/src/or/config.c
index 03883601a6..13b2269676 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -5782,7 +5782,7 @@ parse_dir_authority_line(const char *line, dirinfo_type_t required_type,
} else if (!strcmpstart(flag, "weight=")) {
int ok;
const char *wstring = flag + strlen("weight=");
- weight = tor_parse_double(wstring, 0, UINT64_MAX, &ok, NULL);
+ weight = tor_parse_double(wstring, 0, (double)UINT64_MAX, &ok, NULL);
if (!ok) {
log_warn(LD_CONFIG, "Invalid weight '%s' on DirAuthority line.",flag);
weight=1.0;
@@ -5926,7 +5926,7 @@ parse_dir_fallback_line(const char *line,
} else if (!strcmpstart(cp, "weight=")) {
int ok;
const char *wstring = cp + strlen("weight=");
- weight = tor_parse_double(wstring, 0, UINT64_MAX, &ok, NULL);
+ weight = tor_parse_double(wstring, 0, (double)UINT64_MAX, &ok, NULL);
if (!ok) {
log_warn(LD_CONFIG, "Invalid weight '%s' on FallbackDir line.", cp);
weight=1.0;
diff --git a/src/or/confparse.c b/src/or/confparse.c
index 4f446d07c3..3532b39d93 100644
--- a/src/or/confparse.c
+++ b/src/or/confparse.c
@@ -1238,7 +1238,7 @@ config_parse_units(const char *val, struct unit_table_t *u, int *ok)
v = tor_parse_uint64(val, 10, 0, UINT64_MAX, ok, &cp);
if (!*ok || (cp && *cp == '.')) {
- d = tor_parse_double(val, 0, UINT64_MAX, ok, &cp);
+ d = tor_parse_double(val, 0, (double)UINT64_MAX, ok, &cp);
if (!*ok)
goto done;
use_float = 1;
@@ -1255,7 +1255,7 @@ config_parse_units(const char *val, struct unit_table_t *u, int *ok)
for ( ;u->unit;++u) {
if (!strcasecmp(u->unit, cp)) {
if (use_float)
- v = u->multiplier * d;
+ v = (uint64_t)(u->multiplier * d);
else
v *= u->multiplier;
*ok = 1;
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 4d9d249d10..abd97bbb96 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -2178,7 +2178,7 @@ scale_array_elements_to_u64(uint64_t *entries_out, const double *entries_in,
double scale_factor = 0.0;
int i;
/* big, but far away from overflowing an int64_t */
-#define SCALE_TO_U64_MAX ((int64_t) (INT64_MAX / 4))
+#define SCALE_TO_U64_MAX ((double) (INT64_MAX / 4))
for (i = 0; i < n_entries; ++i)
total += entries_in[i];