From 32ca48ce0b963949ff29d2dcd526b174679779aa Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 10 Sep 2015 11:47:15 -0700 Subject: Core compiles with -Wsign-conversion --- test/core/json/json_rewrite.c | 26 +++++++++++++------------- test/core/json/json_rewrite_test.c | 28 ++++++++++++++-------------- 2 files changed, 27 insertions(+), 27 deletions(-) (limited to 'test/core/json') diff --git a/test/core/json/json_rewrite.c b/test/core/json/json_rewrite.c index 02f60a3163..561bf487b9 100644 --- a/test/core/json/json_rewrite.c +++ b/test/core/json/json_rewrite.c @@ -81,7 +81,7 @@ grpc_json_writer_vtable writer_vtable = {json_writer_output_char, static void check_string(json_reader_userdata* state, size_t needed) { if (state->free_space >= needed) return; needed -= state->free_space; - needed = (needed + 0xff) & ~0xff; + needed = (needed + 0xffu) & ~0xffu; state->scratchpad = gpr_realloc(state->scratchpad, state->allocated + needed); state->free_space += needed; state->allocated += needed; @@ -103,22 +103,22 @@ static void json_reader_string_add_utf32(void* userdata, gpr_uint32 c) { if (c <= 0x7f) { json_reader_string_add_char(userdata, c); } else if (c <= 0x7ff) { - int b1 = 0xc0 | ((c >> 6) & 0x1f); - int b2 = 0x80 | (c & 0x3f); + gpr_uint32 b1 = 0xc0u | ((c >> 6u) & 0x1fu); + gpr_uint32 b2 = 0x80u | (c & 0x3fu); json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b2); - } else if (c <= 0xffff) { - int b1 = 0xe0 | ((c >> 12) & 0x0f); - int b2 = 0x80 | ((c >> 6) & 0x3f); - int b3 = 0x80 | (c & 0x3f); + } else if (c <= 0xffffu) { + gpr_uint32 b1 = 0xe0u | ((c >> 12u) & 0x0fu); + gpr_uint32 b2 = 0x80u | ((c >> 6u) & 0x3fu); + gpr_uint32 b3 = 0x80u | (c & 0x3fu); json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b2); json_reader_string_add_char(userdata, b3); - } else if (c <= 0x1fffff) { - int b1 = 0xf0 | ((c >> 18) & 0x07); - int b2 = 0x80 | ((c >> 12) & 0x3f); - int b3 = 0x80 | ((c >> 6) & 0x3f); - int b4 = 0x80 | (c & 0x3f); + } else if (c <= 0x1fffffu) { + gpr_uint32 b1 = 0xf0u | ((c >> 18u) & 0x07u); + gpr_uint32 b2 = 0x80u | ((c >> 12u) & 0x3fu); + gpr_uint32 b3 = 0x80u | ((c >> 6u) & 0x3fu); + gpr_uint32 b4 = 0x80u | (c & 0x3fu); json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b2); json_reader_string_add_char(userdata, b3); @@ -132,7 +132,7 @@ static gpr_uint32 json_reader_read_char(void* userdata) { r = fgetc(state->in); if (r == EOF) r = GRPC_JSON_READ_CHAR_EOF; - return r; + return (gpr_uint32)r; } static void json_reader_container_begins(void* userdata, grpc_json_type type) { diff --git a/test/core/json/json_rewrite_test.c b/test/core/json/json_rewrite_test.c index f5859322ea..7cf184950e 100644 --- a/test/core/json/json_rewrite_test.c +++ b/test/core/json/json_rewrite_test.c @@ -93,7 +93,7 @@ grpc_json_writer_vtable writer_vtable = {json_writer_output_char, static void check_string(json_reader_userdata* state, size_t needed) { if (state->free_space >= needed) return; needed -= state->free_space; - needed = (needed + 0xff) & ~0xff; + needed = (needed + 0xffu) & ~0xffu; state->scratchpad = gpr_realloc(state->scratchpad, state->allocated + needed); state->free_space += needed; state->allocated += needed; @@ -114,23 +114,23 @@ static void json_reader_string_add_char(void* userdata, gpr_uint32 c) { static void json_reader_string_add_utf32(void* userdata, gpr_uint32 c) { if (c <= 0x7f) { json_reader_string_add_char(userdata, c); - } else if (c <= 0x7ff) { - int b1 = 0xc0 | ((c >> 6) & 0x1f); - int b2 = 0x80 | (c & 0x3f); + } else if (c <= 0x7ffu) { + gpr_uint32 b1 = 0xc0u | ((c >> 6u) & 0x1fu); + gpr_uint32 b2 = 0x80u | (c & 0x3fu); json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b2); - } else if (c <= 0xffff) { - int b1 = 0xe0 | ((c >> 12) & 0x0f); - int b2 = 0x80 | ((c >> 6) & 0x3f); - int b3 = 0x80 | (c & 0x3f); + } else if (c <= 0xffffu) { + gpr_uint32 b1 = 0xe0u | ((c >> 12u) & 0x0fu); + gpr_uint32 b2 = 0x80u | ((c >> 6u) & 0x3fu); + gpr_uint32 b3 = 0x80u | (c & 0x3fu); json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b2); json_reader_string_add_char(userdata, b3); - } else if (c <= 0x1fffff) { - int b1 = 0xf0 | ((c >> 18) & 0x07); - int b2 = 0x80 | ((c >> 12) & 0x3f); - int b3 = 0x80 | ((c >> 6) & 0x3f); - int b4 = 0x80 | (c & 0x3f); + } else if (c <= 0x1fffffu) { + gpr_uint32 b1 = 0xf0u | ((c >> 18u) & 0x07u); + gpr_uint32 b2 = 0x80u | ((c >> 12u) & 0x3fu); + gpr_uint32 b3 = 0x80u | ((c >> 6u) & 0x3fu); + gpr_uint32 b4 = 0x80u | (c & 0x3fu); json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b2); json_reader_string_add_char(userdata, b3); @@ -151,7 +151,7 @@ static gpr_uint32 json_reader_read_char(void* userdata) { r = fgetc(state->in); if (r == EOF) r = GRPC_JSON_READ_CHAR_EOF; - return r; + return (gpr_uint32)r; } static void json_reader_container_begins(void* userdata, grpc_json_type type) { -- cgit v1.2.3