summaryrefslogtreecommitdiff
path: root/src/common/compress_zstd.c
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2017-05-17 12:52:07 +0000
committerAlexander Færøy <ahf@torproject.org>2017-05-17 13:23:54 +0000
commitfcf836d239d3545ff02df63d47e1b23b000138e0 (patch)
tree24e319e70e0474a4982def12c7c9053b8b3f3e9a /src/common/compress_zstd.c
parent77511aed6c0c8cfc16aa4aa47c3c2f4c6efe4dc7 (diff)
downloadtor-fcf836d239d3545ff02df63d47e1b23b000138e0.tar.gz
tor-fcf836d239d3545ff02df63d47e1b23b000138e0.zip
Add coverage markers in Zstd + LZMA compression backends.
See: https://bugs.torproject.org/22286
Diffstat (limited to 'src/common/compress_zstd.c')
-rw-r--r--src/common/compress_zstd.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/common/compress_zstd.c b/src/common/compress_zstd.c
index 99d05c37bd..f54c4e1b31 100644
--- a/src/common/compress_zstd.c
+++ b/src/common/compress_zstd.c
@@ -194,31 +194,39 @@ tor_zstd_compress_new(int compress,
result->u.compress_stream = ZSTD_createCStream();
if (result->u.compress_stream == NULL) {
+ // LCOV_EXCL_START
log_warn(LD_GENERAL, "Error while creating Zstandard stream");
goto err;
+ // LCOV_EXCL_STOP
}
retval = ZSTD_initCStream(result->u.compress_stream, preset);
if (ZSTD_isError(retval)) {
+ // LCOV_EXCL_START
log_warn(LD_GENERAL, "Zstandard stream initialization error: %s",
ZSTD_getErrorName(retval));
goto err;
+ // LCOV_EXCL_STOP
}
} else {
result->u.decompress_stream = ZSTD_createDStream();
if (result->u.decompress_stream == NULL) {
+ // LCOV_EXCL_START
log_warn(LD_GENERAL, "Error while creating Zstandard stream");
goto err;
+ // LCOV_EXCL_STOP
}
retval = ZSTD_initDStream(result->u.decompress_stream);
if (ZSTD_isError(retval)) {
+ // LCOV_EXCL_START
log_warn(LD_GENERAL, "Zstandard stream initialization error: %s",
ZSTD_getErrorName(retval));
goto err;
+ // LCOV_EXCL_STOP
}
}
@@ -226,6 +234,7 @@ tor_zstd_compress_new(int compress,
return result;
err:
+ // LCOV_EXCL_START
if (compress) {
ZSTD_freeCStream(result->u.compress_stream);
} else {
@@ -234,6 +243,7 @@ tor_zstd_compress_new(int compress,
tor_free(result);
return NULL;
+ // LCOV_EXCL_STOP
#else // HAVE_ZSTD.
(void)compress;
(void)method;
@@ -294,10 +304,12 @@ tor_zstd_compress_process(tor_zstd_compress_state_t *state,
}
if (ZSTD_isError(retval)) {
+ // LCOV_EXCL_START
log_warn(LD_GENERAL, "Zstandard %s didn't finish: %s.",
state->compress ? "compression" : "decompression",
ZSTD_getErrorName(retval));
return TOR_COMPRESS_ERROR;
+ // LCOV_EXCL_STOP
}
if (state->compress && !finish) {
@@ -307,9 +319,11 @@ tor_zstd_compress_process(tor_zstd_compress_state_t *state,
*out_len = output.size - output.pos;
if (ZSTD_isError(retval)) {
+ // LCOV_EXCL_START
log_warn(LD_GENERAL, "Zstandard compression unable to flush: %s.",
ZSTD_getErrorName(retval));
return TOR_COMPRESS_ERROR;
+ // LCOV_EXCL_STOP
}
if (retval > 0)
@@ -326,10 +340,12 @@ tor_zstd_compress_process(tor_zstd_compress_state_t *state,
*out_len = output.size - output.pos;
if (ZSTD_isError(retval)) {
+ // LCOV_EXCL_START
log_warn(LD_GENERAL, "Zstandard compression unable to write "
"epilogue: %s.",
ZSTD_getErrorName(retval));
return TOR_COMPRESS_ERROR;
+ // LCOV_EXCL_STOP
}
// endStream returns the number of bytes that is needed to write the