diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 913469198..0f958af7b 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -77,6 +77,8 @@ + +

Add bzip2 compression support.

diff --git a/src/common/compress/bz2/common.c b/src/common/compress/bz2/common.c index 8efb567f6..622b7c99d 100644 --- a/src/common/compress/bz2/common.c +++ b/src/common/compress/bz2/common.c @@ -20,77 +20,71 @@ bz2Error(int error) if (error < 0) { const char *errorMsg; - const ErrorType *errorType = &FormatError; + const ErrorType *errorType = &AssertError; switch (error) { case BZ_SEQUENCE_ERROR: { errorMsg = "sequence error"; - errorType = &AssertError; break; } case BZ_PARAM_ERROR: { errorMsg = "parameter error"; - errorType = &AssertError; break; } case BZ_MEM_ERROR: { errorMsg = "memory error"; - errorType = &AssertError; + errorType = &MemoryError; break; } case BZ_DATA_ERROR: { errorMsg = "data error"; - errorType = &AssertError; + errorType = &FormatError; break; } case BZ_DATA_ERROR_MAGIC: { errorMsg = "data error magic"; - errorType = &AssertError; + errorType = &FormatError; break; } case BZ_IO_ERROR: { errorMsg = "io error"; - errorType = &AssertError; break; } case BZ_UNEXPECTED_EOF: { errorMsg = "unexpected eof"; - errorType = &AssertError; break; } case BZ_OUTBUFF_FULL: { errorMsg = "outbuff full"; - errorType = &AssertError; break; } case BZ_CONFIG_ERROR: { errorMsg = "config error"; - errorType = &AssertError; break; } default: { errorMsg = "unknown error"; - errorType = &AssertError; + break; } } diff --git a/src/common/compress/gz/common.c b/src/common/compress/gz/common.c index 327f61417..b21353f7c 100644 --- a/src/common/compress/gz/common.c +++ b/src/common/compress/gz/common.c @@ -16,7 +16,7 @@ gzError(int error) if (error != Z_OK && error != Z_STREAM_END) { const char *errorMsg; - const ErrorType *errorType = &FormatError; + const ErrorType *errorType = &AssertError; switch (error) { @@ -24,7 +24,6 @@ gzError(int error) case Z_NEED_DICT: { errorMsg = "need dictionary"; - errorType = &AssertError; break; } @@ -32,19 +31,20 @@ gzError(int error) case Z_ERRNO: { errorMsg = "file error"; - errorType = &AssertError; break; } case Z_STREAM_ERROR: { errorMsg = "stream error"; + errorType = &FormatError; break; } case Z_DATA_ERROR: { errorMsg = "data error"; + errorType = &FormatError; break; } @@ -59,20 +59,20 @@ gzError(int error) case Z_BUF_ERROR: { errorMsg = "no space in buffer"; - errorType = &AssertError; break; } case Z_VERSION_ERROR: { errorMsg = "incompatible version"; + errorType = &FormatError; break; } default: { errorMsg = "unknown error"; - errorType = &AssertError; + break; } } diff --git a/test/src/module/common/compressTest.c b/test/src/module/common/compressTest.c index e40bd9c99..9862a7dfa 100644 --- a/test/src/module/common/compressTest.c +++ b/test/src/module/common/compressTest.c @@ -150,10 +150,12 @@ testSuite(CompressType type, const char *decompressCmd) TEST_TITLE("compress a large non-zero input buffer into small output buffer"); decompressed = bufNew(1024 * 1024 - 1); - unsigned char *c = bufPtr(decompressed); + unsigned char *chr = bufPtr(decompressed); - for (size_t i = 0; i < bufSize(decompressed); i++) - c[i] = (unsigned char)(i % 94 + 32); + // Step through the buffer, setting the individual bytes in a simple pattern (visible ASCII characters, DEC 32 - 126), to make + // sure that we fill the compression library's small output buffer + for (size_t chrIdx = 0; chrIdx < bufSize(decompressed); chrIdx++) + chr[chrIdx] = (unsigned char)(chrIdx % 94 + 32); bufUsedSet(decompressed, bufSize(decompressed)); @@ -223,9 +225,9 @@ testRun(void) TEST_RESULT_INT(bz2Error(BZ_STREAM_END), BZ_STREAM_END, "check stream end"); TEST_ERROR(bz2Error(BZ_SEQUENCE_ERROR), AssertError, "bz2 error: [-1] sequence error"); TEST_ERROR(bz2Error(BZ_PARAM_ERROR), AssertError, "bz2 error: [-2] parameter error"); - TEST_ERROR(bz2Error(BZ_MEM_ERROR), AssertError, "bz2 error: [-3] memory error"); - TEST_ERROR(bz2Error(BZ_DATA_ERROR), AssertError, "bz2 error: [-4] data error"); - TEST_ERROR(bz2Error(BZ_DATA_ERROR_MAGIC), AssertError, "bz2 error: [-5] data error magic"); + TEST_ERROR(bz2Error(BZ_MEM_ERROR), MemoryError, "bz2 error: [-3] memory error"); + TEST_ERROR(bz2Error(BZ_DATA_ERROR), FormatError, "bz2 error: [-4] data error"); + TEST_ERROR(bz2Error(BZ_DATA_ERROR_MAGIC), FormatError, "bz2 error: [-5] data error magic"); TEST_ERROR(bz2Error(BZ_IO_ERROR), AssertError, "bz2 error: [-6] io error"); TEST_ERROR(bz2Error(BZ_UNEXPECTED_EOF), AssertError, "bz2 error: [-7] unexpected eof"); TEST_ERROR(bz2Error(BZ_OUTBUFF_FULL), AssertError, "bz2 error: [-8] outbuff full"); @@ -237,7 +239,7 @@ testRun(void) Bz2Compress *compress = (Bz2Compress *)ioFilterDriver(bz2CompressNew(1)); - compress->stream.avail_in = 999; + compress->stream.avail_in = 999; TEST_RESULT_STR_Z( bz2CompressToLog(compress), "{inputSame: false, done: false, flushing: false, avail_in: 999}", "format object");