From 7536af02cf218f8dcb1368bec6d86c65db95c9b4 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 22 Dec 2015 13:49:30 -0800 Subject: Eliminate gpr_ int types - and insist on C99 variants instead --- src/core/transport/chttp2/bin_encoder.c | 58 ++++++++++++++++----------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'src/core/transport/chttp2/bin_encoder.c') diff --git a/src/core/transport/chttp2/bin_encoder.c b/src/core/transport/chttp2/bin_encoder.c index 9c9070ede4..a6a8e3e035 100644 --- a/src/core/transport/chttp2/bin_encoder.c +++ b/src/core/transport/chttp2/bin_encoder.c @@ -42,8 +42,8 @@ static const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; typedef struct { - gpr_uint16 bits; - gpr_uint8 length; + uint16_t bits; + uint8_t length; } b64_huff_sym; static const b64_huff_sym huff_alphabet[64] = {{0x21, 6}, @@ -111,7 +111,7 @@ static const b64_huff_sym huff_alphabet[64] = {{0x21, 6}, {0x7fb, 11}, {0x18, 6}}; -static const gpr_uint8 tail_xtra[3] = {0, 2, 3}; +static const uint8_t tail_xtra[3] = {0, 2, 3}; gpr_slice grpc_chttp2_base64_encode(gpr_slice input) { size_t input_length = GPR_SLICE_LENGTH(input); @@ -119,7 +119,7 @@ gpr_slice grpc_chttp2_base64_encode(gpr_slice input) { size_t tail_case = input_length % 3; size_t output_length = input_triplets * 4 + tail_xtra[tail_case]; gpr_slice output = gpr_slice_malloc(output_length); - gpr_uint8 *in = GPR_SLICE_START_PTR(input); + uint8_t *in = GPR_SLICE_START_PTR(input); char *out = (char *)GPR_SLICE_START_PTR(output); size_t i; @@ -159,11 +159,11 @@ gpr_slice grpc_chttp2_base64_encode(gpr_slice input) { gpr_slice grpc_chttp2_huffman_compress(gpr_slice input) { size_t nbits; - gpr_uint8 *in; - gpr_uint8 *out; + uint8_t *in; + uint8_t *out; gpr_slice output; - gpr_uint32 temp = 0; - gpr_uint32 temp_length = 0; + uint32_t temp = 0; + uint32_t temp_length = 0; nbits = 0; for (in = GPR_SLICE_START_PTR(input); in != GPR_SLICE_END_PTR(input); ++in) { @@ -180,7 +180,7 @@ gpr_slice grpc_chttp2_huffman_compress(gpr_slice input) { while (temp_length > 8) { temp_length -= 8; - *out++ = (gpr_uint8)(temp >> temp_length); + *out++ = (uint8_t)(temp >> temp_length); } } @@ -189,8 +189,8 @@ gpr_slice grpc_chttp2_huffman_compress(gpr_slice input) { * expanded form due to the "integral promotion" performed (see section * 3.2.1.1 of the C89 draft standard). A cast to the smaller container type * is then required to avoid the compiler warning */ - *out++ = (gpr_uint8)((gpr_uint8)(temp << (8u - temp_length)) | - (gpr_uint8)(0xffu >> temp_length)); + *out++ = (uint8_t)((uint8_t)(temp << (8u - temp_length)) | + (uint8_t)(0xffu >> temp_length)); } GPR_ASSERT(out == GPR_SLICE_END_PTR(output)); @@ -199,28 +199,28 @@ gpr_slice grpc_chttp2_huffman_compress(gpr_slice input) { } typedef struct { - gpr_uint32 temp; - gpr_uint32 temp_length; - gpr_uint8 *out; + uint32_t temp; + uint32_t temp_length; + uint8_t *out; } huff_out; static void enc_flush_some(huff_out *out) { while (out->temp_length > 8) { out->temp_length -= 8; - *out->out++ = (gpr_uint8)(out->temp >> out->temp_length); + *out->out++ = (uint8_t)(out->temp >> out->temp_length); } } -static void enc_add2(huff_out *out, gpr_uint8 a, gpr_uint8 b) { +static void enc_add2(huff_out *out, uint8_t a, uint8_t b) { b64_huff_sym sa = huff_alphabet[a]; b64_huff_sym sb = huff_alphabet[b]; out->temp = (out->temp << (sa.length + sb.length)) | - ((gpr_uint32)sa.bits << sb.length) | sb.bits; - out->temp_length += (gpr_uint32)sa.length + (gpr_uint32)sb.length; + ((uint32_t)sa.bits << sb.length) | sb.bits; + out->temp_length += (uint32_t)sa.length + (uint32_t)sb.length; enc_flush_some(out); } -static void enc_add1(huff_out *out, gpr_uint8 a) { +static void enc_add1(huff_out *out, uint8_t a) { b64_huff_sym sa = huff_alphabet[a]; out->temp = (out->temp << sa.length) | sa.bits; out->temp_length += sa.length; @@ -235,8 +235,8 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) { size_t max_output_bits = 11 * output_syms; size_t max_output_length = max_output_bits / 8 + (max_output_bits % 8 != 0); gpr_slice output = gpr_slice_malloc(max_output_length); - gpr_uint8 *in = GPR_SLICE_START_PTR(input); - gpr_uint8 *start_out = GPR_SLICE_START_PTR(output); + uint8_t *in = GPR_SLICE_START_PTR(input); + uint8_t *start_out = GPR_SLICE_START_PTR(output); huff_out out; size_t i; @@ -246,9 +246,9 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) { /* encode full triplets */ for (i = 0; i < input_triplets; i++) { - enc_add2(&out, in[0] >> 2, (gpr_uint8)((in[0] & 0x3) << 4) | (in[1] >> 4)); - enc_add2(&out, (gpr_uint8)((in[1] & 0xf) << 2) | (in[2] >> 6), - (gpr_uint8)(in[2] & 0x3f)); + enc_add2(&out, in[0] >> 2, (uint8_t)((in[0] & 0x3) << 4) | (in[1] >> 4)); + enc_add2(&out, (uint8_t)((in[1] & 0xf) << 2) | (in[2] >> 6), + (uint8_t)(in[2] & 0x3f)); in += 3; } @@ -257,13 +257,13 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) { case 0: break; case 1: - enc_add2(&out, in[0] >> 2, (gpr_uint8)((in[0] & 0x3) << 4)); + enc_add2(&out, in[0] >> 2, (uint8_t)((in[0] & 0x3) << 4)); in += 1; break; case 2: enc_add2(&out, in[0] >> 2, - (gpr_uint8)((in[0] & 0x3) << 4) | (gpr_uint8)(in[1] >> 4)); - enc_add1(&out, (gpr_uint8)((in[1] & 0xf) << 2)); + (uint8_t)((in[0] & 0x3) << 4) | (uint8_t)(in[1] >> 4)); + enc_add1(&out, (uint8_t)((in[1] & 0xf) << 2)); in += 2; break; } @@ -273,8 +273,8 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) { * expanded form due to the "integral promotion" performed (see section * 3.2.1.1 of the C89 draft standard). A cast to the smaller container type * is then required to avoid the compiler warning */ - *out.out++ = (gpr_uint8)((gpr_uint8)(out.temp << (8u - out.temp_length)) | - (gpr_uint8)(0xffu >> out.temp_length)); + *out.out++ = (uint8_t)((uint8_t)(out.temp << (8u - out.temp_length)) | + (uint8_t)(0xffu >> out.temp_length)); } GPR_ASSERT(out.out <= GPR_SLICE_END_PTR(output)); -- cgit v1.2.3