diff options
Diffstat (limited to 'test/core/json/json_rewrite.c')
-rw-r--r-- | test/core/json/json_rewrite.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/test/core/json/json_rewrite.c b/test/core/json/json_rewrite.c index 02f60a3163..82cc4090f3 100644 --- a/test/core/json/json_rewrite.c +++ b/test/core/json/json_rewrite.c @@ -34,8 +34,9 @@ #include <stdio.h> #include <stdlib.h> -#include <grpc/support/cmdline.h> #include <grpc/support/alloc.h> +#include <grpc/support/cmdline.h> +#include <grpc/support/log.h> #include "src/core/json/json_reader.h" #include "src/core/json/json_writer.h" @@ -81,7 +82,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; @@ -96,29 +97,30 @@ static void json_reader_string_clear(void* userdata) { static void json_reader_string_add_char(void* userdata, gpr_uint32 c) { json_reader_userdata* state = userdata; check_string(state, 1); - state->scratchpad[state->string_len++] = c; + GPR_ASSERT(c < 256); + state->scratchpad[state->string_len++] = (char)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); + 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 +134,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) { |