Branch Coverage

c/compress.c
Criterion Covered Total %
branch 25 74 33.7


line true false branch
44 10 1 if (fugz_imp >= 0) goto done;
47 0 1 if ((handle = dlopen("libdeflate.so", RTLD_LAZY))) {
48 0 0 if ((libdeflate_alloc_compressor = dlsym(handle, "libdeflate_alloc_compressor"))
49 0 0 && (libdeflate_free_compressor = dlsym(handle, "libdeflate_free_compressor"))
50 0 0 && (libdeflate_gzip_compress_bound = dlsym(handle, "libdeflate_gzip_compress_bound"))
51 0 0 && (libdeflate_gzip_compress = dlsym(handle, "libdeflate_gzip_compress"))) {
58 2 0 for (i=2; i<=3; i++) {
59 1 1 if ((handle = dlopen(i == 2 ? "libz-ng.so" : "libz.so", RTLD_LAZY))) {
1 1 if ((handle = dlopen(i == 2 ? "libz-ng.so" : "libz.so", RTLD_LAZY))) {
60 1 0 if (((deflate = dlsym(handle, "zng_deflate")) || (deflate = dlsym(handle, "deflate")))
1 0 if (((deflate = dlsym(handle, "zng_deflate")) || (deflate = dlsym(handle, "deflate")))
61 1 0 && ((deflateEnd = dlsym(handle, "zng_deflateEnd")) || (deflateEnd = dlsym(handle, "deflateEnd")))
1 0 && ((deflateEnd = dlsym(handle, "zng_deflateEnd")) || (deflateEnd = dlsym(handle, "deflateEnd")))
62 1 0 && ((deflateInit2 = dlsym(handle, "zng_deflateInit2")) || (deflateInit2_ = dlsym(handle, "deflateInit2_")))
1 0 && ((deflateInit2 = dlsym(handle, "zng_deflateInit2")) || (deflateInit2_ = dlsym(handle, "deflateInit2_")))
63 1 0 && ((compressBound = dlsym(handle, "zng_compressBound")) || (compressBound = dlsym(handle, "compressBound")))) {
1 0 && ((compressBound = dlsym(handle, "zng_compressBound")) || (compressBound = dlsym(handle, "compressBound")))) {
77 0 0 if (fugz_ld_comp != level) {
78 0 0 if (fugz_ld_ctx) libdeflate_free_compressor(fugz_ld_ctx);
82 0 0 if (!fugz_ld_ctx) fugz_ld_ctx = libdeflate_alloc_compressor(level);
88 0 0 if (!len) fu_confess("Libdeflate compression failed"); /* Shouldn't happen */
101 0 8 : deflateInit2_(&stream, level > 9 ? 9 : level, 8, 16+15, 9, 0, "1.3.1", (int)sizeof(stream));
102 0 8 if (r) fu_confess("Zlib compression failed (%d)", r);
111 0 8 if ((r = deflate(&stream, 4)) != 1) fu_confess("Zlib compression failed (%d)", r);
121 8 0 if (level < 0 || level > 12) fu_confess("Invalid compression level: %"IVdf, level);
0 8 if (level < 0 || level > 12) fu_confess("Invalid compression level: %"IVdf, level);
122 0 8 if (!*fugz_lib()) fu_confess("Unable to load a suitable compression library");
127 0 8 if (fugz_imp == 1) return fugz_compress_ld(aTHX_ level, bytes, inlen);
141 1 0 if (!BrotliEncoderCompress) {
143 0 1 if (!(handle = dlopen("libbrotlienc.so", RTLD_LAZY))
144 0 0 || !(BrotliEncoderMaxCompressedSize = dlsym(handle, "BrotliEncoderMaxCompressedSize"))
145 0 0 || !(BrotliEncoderCompress = dlsym(handle, "BrotliEncoderCompress")))
148 0 0 if (level < 0 || level > 11) fu_confess("Invalid compression level: %"IVdf, level);
0 0 if (level < 0 || level > 11) fu_confess("Invalid compression level: %"IVdf, level);
155 0 0 if (level < 2 && outlen < inlen + 256) outlen = inlen + 256;
0 0 if (level < 2 && outlen < inlen + 256) outlen = inlen + 256;
159 0 0 if (!BrotliEncoderCompress(level, 22, BROTLI_MODE_GENERIC, inlen, bytes, &outlen, SvPVX(out)))