Prototype, not intended for a PR as is.
- LZ4F_preferences_t : reserved array replaced by explicit scalar fields
(nbWorkers, reserved1, reserved0), and LZ4F_compressOptions_t likewise
(stableSrc, reserved2, reserved1, reserved0), as LZ4F_decompressOptions_t.
Same sizes and offsets (ABI unchanged). A future field takes the place of a
reserved one, without changing positional initializers.
One-time source change : the former positional form { ..., { 0, 0, 0 } }
no longer compiles in C++ (warnings in C) ; examples/frameCompress.c updated.
LZ4F_INIT_PREFERENCES : { LZ4F_INIT_FRAMEINFO, 0, 0u, 0u, 0u, 0u, 0u }.
- LZ4F_srcStableUntilFlush (2) is stronger than LZ4F_srcStable (1) : in addition
to the last 64 KB of input (which remain, including after LZ4F_flush()),
all of src remains until LZ4F_flush() / LZ4F_compressEnd() returns
(with autoFlush : until the invocation returns). Docs only : the code already
relied on this (history read in place after a flush, single-threaded path).
- tests/frameMT.c : validateFlushContract : one buffer, 2 invocations separated by
a flush, everything but the last 64 KB scrambled after the flush with content
resembling upcoming data ; nbWorkers 0 and 2, levels 1 and 9, with and without
autoFlush. Scrambling the last 64 KB too is detected (contentChecksum_invalid).
Streaming test : LZ4F_srcStableUntilFlush slices come from a working copy,
scrambled the same way after each flush.
Output unchanged (same digests). Validated : full tests MT / no-MT, ASAN+UBSAN, TSAN,
make test, wine, examples (C, C++), cxxtest, CLI == dev CLI.
The macOS CI job builds the examples with
CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" make test
and clang's -Wconversion implies -Wimplicit-int-float-conversion. In each of
these ratio expressions the numerator is cast explicitly but the denominator is
left to convert implicitly, so newer clang rejects them:
frameCompress.c:446:40: error: implicit conversion from
'const unsigned long long' to 'double' may lose precision
[-Werror,-Wimplicit-int-float-conversion]
446 | (double)ret.size_out / ret.size_in * 100);
| ~ ~~~~^~~~~~~
Cast the denominators too, matching how fileCompress.c:193 already writes the
same computation. The conversion happened anyway via the usual arithmetic
conversions, so the printed values are unchanged.
frameCompress.c is only the first failure; make stops there, and
bench_functions.c has ten more instances of the same pattern behind it.
new method `uncompressed_update` allows to insert blocks without
compression into the lz4 stream.
The usage is documented in the frameCompress example
Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
so "funny" thing with cppcheck
is that no 2 versions give the same list of warnings.
On Mac, I'm using v1.81, which had all warnings fixed.
On Travis CI, it's v1.61, and it complains about a dozen more/different things.
On Linux, it's v1.72, and it finds a completely different list of a half dozen warnings.
Some of these seems to be bugs/limitations in cppcheck itself.
The TravisCI version v1.61 seems unable to understand %zu correctly, and seems to assume it means %u.
The decompression was failing as the srcEnd pointer in
decompress_file_internal was wrongly computed beyond
the end of the memory block.
We need to account for the fact that the header ("info")
was already read in the calling function ("alreadyConsumed").