diff options
author | Nicolas Noble <nicolasnoble@users.noreply.github.com> | 2015-06-22 17:09:06 -0700 |
---|---|---|
committer | Nicolas Noble <nicolasnoble@users.noreply.github.com> | 2015-06-22 17:09:06 -0700 |
commit | bbb9a286f8d41be888e5933f1f10a5b907de11e3 (patch) | |
tree | 659e18958a84cbb4bfe4b6462805fe9f54048423 | |
parent | 3e5964f8fbbcdaf6751ca203843ca127eb215ab7 (diff) | |
parent | 51cd7d72931006ea83e8c1cb9334fac121fc4a5b (diff) |
Merge pull request #2166 from dgquintas/fix_compress_enum_parsing_win
Fixed warning while parsing compression enum bytes.
-rw-r--r-- | src/core/surface/call.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/core/surface/call.c b/src/core/surface/call.c index 6e2714db0b..dd8eaa943e 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -1190,9 +1190,14 @@ static gpr_uint32 decode_compression(grpc_mdelem *md) { if (user_data) { clevel = ((grpc_compression_level)(gpr_intptr)user_data) - COMPRESS_OFFSET; } else { - if (!gpr_parse_bytes_to_uint32(grpc_mdstr_as_c_string(md->value), + gpr_uint32 parsed_clevel_bytes; + if (gpr_parse_bytes_to_uint32(grpc_mdstr_as_c_string(md->value), GPR_SLICE_LENGTH(md->value->slice), - &clevel)) { + &parsed_clevel_bytes)) { + /* the following cast is safe, as a gpr_uint32 should be able to hold all + * possible values of the grpc_compression_level enum */ + clevel = (grpc_compression_level) parsed_clevel_bytes; + } else { clevel = GRPC_COMPRESS_LEVEL_NONE; /* could not parse, no compression */ } grpc_mdelem_set_user_data(md, destroy_compression, |