From be82e64b3debcdb1d9ec6a149fc85af0d46bfb7e Mon Sep 17 00:00:00 2001 From: Noah Eisen Date: Fri, 9 Feb 2018 09:16:55 -0800 Subject: Autofix c casts to c++ casts --- test/core/slice/b64_test.cc | 6 +++--- test/core/slice/percent_encode_fuzzer.cc | 2 +- test/core/slice/slice_test.cc | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'test/core/slice') diff --git a/test/core/slice/b64_test.cc b/test/core/slice/b64_test.cc index 94785fd1e2..6b29443ba1 100644 --- a/test/core/slice/b64_test.cc +++ b/test/core/slice/b64_test.cc @@ -34,7 +34,7 @@ static int buffers_are_equal(const unsigned char* buf1, for (i = 0; i < size; i++) { if (buf1[i] != buf2[i]) { gpr_log(GPR_ERROR, "buf1 and buf2 differ: buf1[%d] = %x vs buf2[%d] = %x", - (int)i, buf1[i], (int)i, buf2[i]); + static_cast(i), buf1[i], static_cast(i), buf2[i]); return 0; } } @@ -61,7 +61,7 @@ static void test_full_range_encode_decode_b64(int url_safe, int multiline) { size_t i; char* b64; grpc_slice orig_decoded; - for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i; + for (i = 0; i < sizeof(orig); i++) orig[i] = static_cast(i); /* Try all the different paddings. */ for (i = 0; i < 3; i++) { @@ -114,7 +114,7 @@ static void test_url_safe_unsafe_mismatch_failure(void) { char* b64; grpc_slice orig_decoded; int url_safe = 1; - for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i; + for (i = 0; i < sizeof(orig); i++) orig[i] = static_cast(i); grpc_core::ExecCtx exec_ctx; b64 = grpc_base64_encode(orig, sizeof(orig), url_safe, 0); diff --git a/test/core/slice/percent_encode_fuzzer.cc b/test/core/slice/percent_encode_fuzzer.cc index 201ae2790e..1e4e95d97e 100644 --- a/test/core/slice/percent_encode_fuzzer.cc +++ b/test/core/slice/percent_encode_fuzzer.cc @@ -34,7 +34,7 @@ static void test(const uint8_t* data, size_t size, const uint8_t* dict) { struct grpc_memory_counters counters; grpc_init(); grpc_memory_counters_init(); - grpc_slice input = grpc_slice_from_copied_buffer((const char*)data, size); + grpc_slice input = grpc_slice_from_copied_buffer(reinterpret_cast(data), size); grpc_slice output = grpc_percent_encode_slice(input, dict); grpc_slice decoded_output; // encoder must always produce decodable output diff --git a/test/core/slice/slice_test.cc b/test/core/slice/slice_test.cc index e40154dd0e..5a49793a9e 100644 --- a/test/core/slice/slice_test.cc +++ b/test/core/slice/slice_test.cc @@ -57,7 +57,7 @@ static void test_slice_malloc_returns_something_sensible(void) { } /* We must be able to write to every byte of the data */ for (i = 0; i < length; i++) { - GRPC_SLICE_START_PTR(slice)[i] = (uint8_t)i; + GRPC_SLICE_START_PTR(slice)[i] = static_cast(i); } /* And finally we must succeed in destroying the slice */ grpc_slice_unref(slice); @@ -77,7 +77,7 @@ static void test_slice_new_returns_something_sensible(void) { } /* destroy function that sets a mark to indicate it was called. */ -static void set_mark(void* p) { *((int*)p) = 1; } +static void set_mark(void* p) { *(static_cast(p)) = 1; } static void test_slice_new_with_user_data(void) { int marker = 0; @@ -143,7 +143,7 @@ static void test_slice_sub_works(unsigned length) { beginning of the slice. */ slice = grpc_slice_malloc(length); for (i = 0; i < length; i++) { - GRPC_SLICE_START_PTR(slice)[i] = (uint8_t)i; + GRPC_SLICE_START_PTR(slice)[i] = static_cast(i); } /* Ensure that for all subsets length is correct and that we start on the @@ -183,7 +183,7 @@ static void test_slice_split_head_works(size_t length) { beginning of the slice. */ slice = grpc_slice_malloc(length); for (i = 0; i < length; i++) { - GRPC_SLICE_START_PTR(slice)[i] = (uint8_t)i; + GRPC_SLICE_START_PTR(slice)[i] = static_cast(i); } /* Ensure that for all subsets length is correct and that we start on the @@ -211,7 +211,7 @@ static void test_slice_split_tail_works(size_t length) { beginning of the slice. */ slice = grpc_slice_malloc(length); for (i = 0; i < length; i++) { - GRPC_SLICE_START_PTR(slice)[i] = (uint8_t)i; + GRPC_SLICE_START_PTR(slice)[i] = static_cast(i); } /* Ensure that for all subsets length is correct and that we start on the -- cgit v1.2.3