aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar David G. Quintas <dgq@google.com>2015-12-11 14:51:50 -0800
committerGravatar David G. Quintas <dgq@google.com>2015-12-11 14:51:50 -0800
commitce015f647a9f568a6577cd3d764c6e9b795e6e3c (patch)
tree96e9afb1a750d79989f62db6ecf146839e267eed /src
parentd25f579b33a8a2b45cd692af10c34191909e1177 (diff)
parent48ec8062497ecece119d0df61d0bfdca93e11502 (diff)
Merge pull request #4381 from dgquintas/compression_coverage_2
Further coverage for compression
Diffstat (limited to 'src')
-rw-r--r--src/core/compression/algorithm.c24
-rw-r--r--src/core/compression/message_compress.c14
2 files changed, 8 insertions, 30 deletions
diff --git a/src/core/compression/algorithm.c b/src/core/compression/algorithm.c
index 73d91fa8ea..8e4e5c91d4 100644
--- a/src/core/compression/algorithm.c
+++ b/src/core/compression/algorithm.c
@@ -119,8 +119,8 @@ grpc_mdelem *grpc_compression_encoding_mdelem(
return GRPC_MDELEM_GRPC_ENCODING_DEFLATE;
case GRPC_COMPRESS_GZIP:
return GRPC_MDELEM_GRPC_ENCODING_GZIP;
- case GRPC_COMPRESS_ALGORITHMS_COUNT:
- return NULL;
+ default:
+ break;
}
return NULL;
}
@@ -139,25 +139,9 @@ grpc_compression_algorithm grpc_compression_algorithm_for_level(
case GRPC_COMPRESS_LEVEL_HIGH:
return GRPC_COMPRESS_DEFLATE;
default:
- /* we shouldn't be making it here */
- abort();
- return GRPC_COMPRESS_NONE;
- }
-}
-
-grpc_compression_level grpc_compression_level_for_algorithm(
- grpc_compression_algorithm algorithm) {
- grpc_compression_level clevel;
- GRPC_API_TRACE("grpc_compression_level_for_algorithm(algorithm=%d)", 1,
- ((int)algorithm));
- for (clevel = GRPC_COMPRESS_LEVEL_NONE; clevel < GRPC_COMPRESS_LEVEL_COUNT;
- ++clevel) {
- if (grpc_compression_algorithm_for_level(clevel) == algorithm) {
- return clevel;
- }
+ break;
}
- abort();
- return GRPC_COMPRESS_LEVEL_NONE;
+ GPR_UNREACHABLE_CODE(return GRPC_COMPRESS_NONE);
}
void grpc_compression_options_init(grpc_compression_options *opts) {
diff --git a/src/core/compression/message_compress.c b/src/core/compression/message_compress.c
index a723c47819..e72347118f 100644
--- a/src/core/compression/message_compress.c
+++ b/src/core/compression/message_compress.c
@@ -69,8 +69,8 @@ static int zlib_body(z_stream* zs, gpr_slice_buffer* input,
zs->next_out = GPR_SLICE_START_PTR(outbuf);
}
r = flate(zs, flush);
- if (r == Z_STREAM_ERROR) {
- gpr_log(GPR_INFO, "zlib: stream error");
+ if (r < 0 && r != Z_BUF_ERROR /* not fatal */) {
+ gpr_log(GPR_INFO, "zlib error (%d)", r);
goto error;
}
} while (zs->avail_out == 0);
@@ -111,10 +111,7 @@ static int zlib_compress(gpr_slice_buffer* input, gpr_slice_buffer* output,
zs.zfree = zfree_gpr;
r = deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 15 | (gzip ? 16 : 0),
8, Z_DEFAULT_STRATEGY);
- if (r != Z_OK) {
- gpr_log(GPR_ERROR, "deflateInit2 returns %d", r);
- return 0;
- }
+ GPR_ASSERT(r == Z_OK);
r = zlib_body(&zs, input, output, deflate) && output->length < input->length;
if (!r) {
for (i = count_before; i < output->count; i++) {
@@ -138,10 +135,7 @@ static int zlib_decompress(gpr_slice_buffer* input, gpr_slice_buffer* output,
zs.zalloc = zalloc_gpr;
zs.zfree = zfree_gpr;
r = inflateInit2(&zs, 15 | (gzip ? 16 : 0));
- if (r != Z_OK) {
- gpr_log(GPR_ERROR, "inflateInit2 returns %d", r);
- return 0;
- }
+ GPR_ASSERT(r == Z_OK);
r = zlib_body(&zs, input, output, inflate);
if (!r) {
for (i = count_before; i < output->count; i++) {