diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/cc/compat_compiler.h | 3 | ||||
-rw-r--r-- | src/lib/tls/tortls.c | 4 | ||||
-rw-r--r-- | src/or/confparse.c | 2 | ||||
-rw-r--r-- | src/or/cpuworker.c | 2 | ||||
-rw-r--r-- | src/or/hibernate.c | 3 | ||||
-rw-r--r-- | src/or/main.c | 8 | ||||
-rw-r--r-- | src/or/rephist.c | 4 | ||||
-rw-r--r-- | src/or/status.c | 8 | ||||
-rw-r--r-- | src/test/test_util.c | 6 |
9 files changed, 18 insertions, 22 deletions
diff --git a/src/lib/cc/compat_compiler.h b/src/lib/cc/compat_compiler.h index 42ceeadd3e..0f1acc381a 100644 --- a/src/lib/cc/compat_compiler.h +++ b/src/lib/cc/compat_compiler.h @@ -106,9 +106,6 @@ #endif /* !defined(HAVE_MACRO__func__) */ #endif /* defined(_MSC_VER) */ -#define U64_TO_DBL(x) ((double) (x)) -#define DBL_TO_U64(x) ((uint64_t) (x)) - #ifdef ENUM_VALS_ARE_SIGNED #define ENUM_BF(t) unsigned #else diff --git a/src/lib/tls/tortls.c b/src/lib/tls/tortls.c index 3eee41bd16..1cd22a7eba 100644 --- a/src/lib/tls/tortls.c +++ b/src/lib/tls/tortls.c @@ -2442,8 +2442,8 @@ tls_get_write_overhead_ratio,(void)) if (total_bytes_written_over_tls == 0) return 1.0; - return U64_TO_DBL(total_bytes_written_by_tls) / - U64_TO_DBL(total_bytes_written_over_tls); + return ((double)total_bytes_written_by_tls) / + ((double)total_bytes_written_over_tls); } /** Implement check_no_tls_errors: If there are any pending OpenSSL diff --git a/src/or/confparse.c b/src/or/confparse.c index 8db6d60807..08f5fd0487 100644 --- a/src/or/confparse.c +++ b/src/or/confparse.c @@ -1117,7 +1117,7 @@ config_parse_units(const char *val, struct unit_table_t *u, int *ok) if (!cp) { *ok = 1; - v = use_float ? DBL_TO_U64(d) : v; + v = use_float ? ((uint64_t)d) : v; goto done; } diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index 6750790205..b37dfd1684 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -283,7 +283,7 @@ get_overhead_for_onionskins(uint32_t *usec_out, double *frac_out, onionskins_usec_internal[onionskin_type]; *usec_out = (uint32_t)(overhead / onionskins_n_processed[onionskin_type]); - *frac_out = U64_TO_DBL(overhead) / onionskins_usec_internal[onionskin_type]; + *frac_out = ((double)overhead) / onionskins_usec_internal[onionskin_type]; return 0; } diff --git a/src/or/hibernate.c b/src/or/hibernate.c index c6190bc89c..30a5edc1f2 100644 --- a/src/or/hibernate.c +++ b/src/or/hibernate.c @@ -799,7 +799,7 @@ hibernate_soft_limit_reached(void) * - We have used up 95% of our bytes. * - We have less than 500MB of bytes left. */ - uint64_t soft_limit = DBL_TO_U64(U64_TO_DBL(acct_max) * SOFT_LIM_PCT); + uint64_t soft_limit = (uint64_t) (acct_max * SOFT_LIM_PCT); if (acct_max > SOFT_LIM_BYTES && acct_max - SOFT_LIM_BYTES > soft_limit) { soft_limit = acct_max - SOFT_LIM_BYTES; } @@ -1227,4 +1227,3 @@ hibernate_set_state_for_testing_(hibernate_state_t newstate) hibernate_state = newstate; } #endif /* defined(TOR_UNIT_TESTS) */ - diff --git a/src/or/main.c b/src/or/main.c index c2fa416d6b..f07d9da8b0 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -3279,12 +3279,12 @@ dumpstats(int severity) (stats_n_destroy_cells_processed)); if (stats_n_data_cells_packaged) tor_log(severity,LD_NET,"Average packaged cell fullness: %2.3f%%", - 100*(U64_TO_DBL(stats_n_data_bytes_packaged) / - U64_TO_DBL(stats_n_data_cells_packaged*RELAY_PAYLOAD_SIZE)) ); + 100*(((double)stats_n_data_bytes_packaged) / + ((double)stats_n_data_cells_packaged*RELAY_PAYLOAD_SIZE)) ); if (stats_n_data_cells_received) tor_log(severity,LD_NET,"Average delivered cell fullness: %2.3f%%", - 100*(U64_TO_DBL(stats_n_data_bytes_received) / - U64_TO_DBL(stats_n_data_cells_received*RELAY_PAYLOAD_SIZE)) ); + 100*(((double)stats_n_data_bytes_received) / + ((double)stats_n_data_cells_received*RELAY_PAYLOAD_SIZE)) ); cpuworker_log_onionskin_overhead(severity, ONION_HANDSHAKE_TYPE_TAP, "TAP"); cpuworker_log_onionskin_overhead(severity, ONION_HANDSHAKE_TYPE_NTOR,"ntor"); diff --git a/src/or/rephist.c b/src/or/rephist.c index 12b0225aab..34c06760bc 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -1218,9 +1218,9 @@ rep_hist_bandwidth_assess(void) r = find_largest_max(read_array); w = find_largest_max(write_array); if (r>w) - return (int)(U64_TO_DBL(w)/NUM_SECS_ROLLING_MEASURE); + return (int)(((double)w)/NUM_SECS_ROLLING_MEASURE); else - return (int)(U64_TO_DBL(r)/NUM_SECS_ROLLING_MEASURE); + return (int)(((double)r)/NUM_SECS_ROLLING_MEASURE); } /** Print the bandwidth history of b (either [dir-]read_array or diff --git a/src/or/status.c b/src/or/status.c index 5c0a768ace..4538e22a56 100644 --- a/src/or/status.c +++ b/src/or/status.c @@ -79,10 +79,10 @@ bytes_to_usage(uint64_t bytes) if (bytes < (1<<20)) { /* Less than a megabyte. */ tor_asprintf(&bw_string, "%"PRIu64" kB", (bytes>>10)); } else if (bytes < (1<<30)) { /* Megabytes. Let's add some precision. */ - double bw = U64_TO_DBL(bytes); + double bw = ((double)bytes); tor_asprintf(&bw_string, "%.2f MB", bw/(1<<20)); } else { /* Gigabytes. */ - double bw = U64_TO_DBL(bytes); + double bw = ((double)bytes); tor_asprintf(&bw_string, "%.2f GB", bw/(1<<30)); } @@ -150,8 +150,8 @@ log_heartbeat(time_t now) double fullness_pct = 100; if (stats_n_data_cells_packaged && !hibernating) { fullness_pct = - 100*(U64_TO_DBL(stats_n_data_bytes_packaged) / - U64_TO_DBL(stats_n_data_cells_packaged*RELAY_PAYLOAD_SIZE)); + 100*(((double)stats_n_data_bytes_packaged) / + ((double)stats_n_data_cells_packaged*RELAY_PAYLOAD_SIZE)); } const double overhead_pct = ( r - 1.0 ) * 100.0; diff --git a/src/test/test_util.c b/src/test/test_util.c index 67a10a8a57..e6348bfea8 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -2184,10 +2184,10 @@ test_util_parse_integer(void *arg) /* Test parse_double */ double d = tor_parse_double("10", 0, (double)UINT64_MAX,&i,NULL); tt_int_op(1,OP_EQ, i); - tt_assert(DBL_TO_U64(d) == 10); + tt_assert(((uint64_t)d) == 10); d = tor_parse_double("0", 0, (double)UINT64_MAX,&i,NULL); tt_int_op(1,OP_EQ, i); - tt_assert(DBL_TO_U64(d) == 0); + tt_assert(((uint64_t)d) == 0); d = tor_parse_double(" ", 0, (double)UINT64_MAX,&i,NULL); tt_double_op(fabs(d), OP_LT, 1e-10); tt_int_op(0,OP_EQ, i); @@ -2199,7 +2199,7 @@ test_util_parse_integer(void *arg) tt_int_op(1,OP_EQ, i); d = tor_parse_double("-.0", 0, (double)UINT64_MAX,&i,NULL); tt_int_op(1,OP_EQ, i); - tt_assert(DBL_TO_U64(d) == 0); + tt_assert(((uint64_t)d) == 0); d = tor_parse_double("-10", -100.0, 100.0,&i,NULL); tt_int_op(1,OP_EQ, i); tt_double_op(fabs(d - -10.0),OP_LT, 1E-12); |