Clean up various things that broke with our stdint.h changes

Casting before printf was necessary; now it's not so smart.

We don't have SIZEOF_UINT8_T any more.
This commit is contained in:
Nick Mathewson 2018-07-03 10:26:06 -04:00
parent e2a94dc481
commit c75215c23a
5 changed files with 12 additions and 23 deletions

View File

@ -168,7 +168,7 @@ tor_cert_parse(const uint8_t *encoded, const size_t len)
memcpy(cert->signed_key.pubkey, parsed->certified_key, 32); memcpy(cert->signed_key.pubkey, parsed->certified_key, 32);
int64_t valid_until_64 = ((int64_t)parsed->exp_field) * 3600; int64_t valid_until_64 = ((int64_t)parsed->exp_field) * 3600;
#if SIZEOF_TIME_T < SIZEOF_INT64_T #if SIZEOF_TIME_T < 8
if (valid_until_64 > TIME_MAX) if (valid_until_64 > TIME_MAX)
valid_until_64 = TIME_MAX - 1; valid_until_64 = TIME_MAX - 1;
#endif #endif
@ -723,4 +723,3 @@ tor_cert_encode_ed22519(const tor_cert_t *cert, char **cert_str_out)
tor_free(ed_cert_b64); tor_free(ed_cert_b64);
return ret; return ret;
} }

View File

@ -50,28 +50,20 @@
tt_double_op((a), OP_LE, (b)); \ tt_double_op((a), OP_LE, (b)); \
STMT_END STMT_END
#ifdef _MSC_VER
#define U64_PRINTF_TYPE uint64_t
#define I64_PRINTF_TYPE int64_t
#else
#define U64_PRINTF_TYPE unsigned long long
#define I64_PRINTF_TYPE long long
#endif /* defined(_MSC_VER) */
#define tt_size_op(a,op,b) \ #define tt_size_op(a,op,b) \
tt_assert_test_fmt_type(a,b,#a" "#op" "#b,size_t,(val1_ op val2_), \ tt_assert_test_fmt_type(a,b,#a" "#op" "#b,size_t,(val1_ op val2_), \
U64_PRINTF_TYPE, U64_FORMAT, \ size_t, "%"TOR_PRIuSZ, \
{print_ = (U64_PRINTF_TYPE) value_;}, {}, TT_EXIT_TEST_FUNCTION) {print_ = (size_t) value_;}, {}, TT_EXIT_TEST_FUNCTION)
#define tt_u64_op(a,op,b) \ #define tt_u64_op(a,op,b) \
tt_assert_test_fmt_type(a,b,#a" "#op" "#b,uint64_t,(val1_ op val2_), \ tt_assert_test_fmt_type(a,b,#a" "#op" "#b,uint64_t,(val1_ op val2_), \
U64_PRINTF_TYPE, U64_FORMAT, \ uint64_t, "%"PRIu64, \
{print_ = (U64_PRINTF_TYPE) value_;}, {}, TT_EXIT_TEST_FUNCTION) {print_ = (uint64_t) value_;}, {}, TT_EXIT_TEST_FUNCTION)
#define tt_i64_op(a,op,b) \ #define tt_i64_op(a,op,b) \
tt_assert_test_fmt_type(a,b,#a" "#op" "#b,int64_t,(val1_ op val2_), \ tt_assert_test_fmt_type(a,b,#a" "#op" "#b,int64_t,(val1_ op val2_), \
I64_PRINTF_TYPE, I64_FORMAT, \ int64_t, "%"PRId64, \
{print_ = (I64_PRINTF_TYPE) value_;}, {}, TT_EXIT_TEST_FUNCTION) {print_ = (int64_t) value_;}, {}, TT_EXIT_TEST_FUNCTION)
/** /**
* Declare that the test is done, even though no tt___op() calls were made. * Declare that the test is done, even though no tt___op() calls were made.

View File

@ -2862,12 +2862,12 @@ crypto_rand_check_failure_mode_identical(void)
{ {
/* just in case the buffer size isn't a multiple of sizeof(int64_t) */ /* just in case the buffer size isn't a multiple of sizeof(int64_t) */
#define FAILURE_MODE_BUFFER_SIZE_I64 \ #define FAILURE_MODE_BUFFER_SIZE_I64 \
(FAILURE_MODE_BUFFER_SIZE/SIZEOF_INT64_T) (FAILURE_MODE_BUFFER_SIZE/8)
#define FAILURE_MODE_BUFFER_SIZE_I64_BYTES \ #define FAILURE_MODE_BUFFER_SIZE_I64_BYTES \
(FAILURE_MODE_BUFFER_SIZE_I64*SIZEOF_INT64_T) (FAILURE_MODE_BUFFER_SIZE_I64*8)
#if FAILURE_MODE_BUFFER_SIZE_I64 < 2 #if FAILURE_MODE_BUFFER_SIZE_I64 < 2
#error FAILURE_MODE_BUFFER_SIZE needs to be at least 2*SIZEOF_INT64_T #error FAILURE_MODE_BUFFER_SIZE needs to be at least 2*8
#endif #endif
int64_t buf[FAILURE_MODE_BUFFER_SIZE_I64]; int64_t buf[FAILURE_MODE_BUFFER_SIZE_I64];
@ -3063,4 +3063,3 @@ struct testcase_t crypto_tests[] = {
{ "failure_modes", test_crypto_failure_modes, TT_FORK, NULL, NULL }, { "failure_modes", test_crypto_failure_modes, TT_FORK, NULL, NULL },
END_OF_TESTCASES END_OF_TESTCASES
}; };

View File

@ -575,4 +575,3 @@ struct testcase_t geoip_tests[] = {
END_OF_TESTCASES END_OF_TESTCASES
}; };

View File

@ -5564,7 +5564,7 @@ test_util_max_mem(void *arg)
tt_uint_op(memory1, OP_GT, (1<<20)); tt_uint_op(memory1, OP_GT, (1<<20));
} else { } else {
/* You do not have a petabyte. */ /* You do not have a petabyte. */
#if SIZEOF_SIZE_T == SIZEOF_UINT64_T #if SIZEOF_SIZE_T >= 8
tt_u64_op(memory1, OP_LT, (U64_LITERAL(1)<<50)); tt_u64_op(memory1, OP_LT, (U64_LITERAL(1)<<50));
#endif #endif
} }