Fixed conversion warning when calling zng_tr_tally_dist. Signature for dist and len now match zng_emit_dist.
deflate.c(1575,67): warning C4244: 'function': conversion from 'uint32_t' to 'unsigned char', possible loss of data
deflate_fast.c(60,94): warning C4244: 'function': conversion from 'uint32_t' to 'unsigned char', possible loss of data
deflate_medium.c(39,102): warning C4244: 'function': conversion from 'int' to 'unsigned char', possible loss of data
deflate_slow.c(75,101): warning C4244: 'function': conversion from 'unsigned int' to 'unsigned char', possible loss of data
Fixed str uint32_t to uint16_t casting warnings in inflate_string_tpl.h
insert_string_tpl.h(50,26): warning C4244: '=': conversion from 'const uint32_t' to 'Pos', possible loss of data
insert_string_tpl.h(67,1): warning C4244: 'initializing': conversion from 'const uint32_t' to 'Pos', possible loss of data
Fixed match_start uint32_t to uint16_t casting warnings in deflate_medium.c
deflate_medium.c(204,49): warning C4244: '=': conversion from 'unsigned int' to 'uint16_t', possible loss of data
deflate_medium.c(217,59): warning C4244: '=': conversion from 'unsigned int' to 'uint16_t', possible loss of data
deflate_medium.c(238,46): warning C4244: '=': conversion from 'unsigned int' to 'uint16_t', possible loss of data
deflate_medium.c(250,56): warning C4244: '=': conversion from 'unsigned int' to 'uint16_t', possible loss of data
Fixed ubsan warning in gzfread due to size_t overflow. #783
gzread.c:398:18: runtime error: unsigned integer overflow: 2 * 18446744073709551615 cannot be represented in type 'unsigned long'
#0 0x10009d31e in zng_gzfread gzread.c:398
#1 0x100005b1a in test_gzio example.c:213
#2 0x10001093b in main example.c:1034
#3 0x7fff71f57cc8 in start+0x0 (libdyld.dylib:x86_64+0x1acc8)
Fixed ptrdiff_t redefined static analysis warning on GCC. Failing ptrdiff_t detection due to variable unused warning combined with -Werror.
In file included from zlib-ng/zlib-ng.h:33,
from zlib-ng/zutil.h:38,
from zlib-ng/adler32.c:7:
zlib-ng/zconf-ng.h:118:18: error: conflicting types for ‘ptrdiff_t’
118 | typedef uint64_t ptrdiff_t;
| ^~~~~~~~~
In file included from zlib-ng/zutil.h:31,
from zlib-ng/adler32.c:7:
stddef.h:143:26: note: previous declaration of ‘ptrdiff_t’ was here
143 | typedef __PTRDIFF_TYPE__ ptrdiff_t;
| ^~~~~~~~~
Fix incorrect inflateSyncPoint() return value with DFLTCC
DFLTCC does not provide the necessary information to implement
inflateSyncPoint() - Incomplete-Function Status and Incomplete-Function
Length are the fields that provide the relevant information, but
unfortunately it's not enough. If DFLTCC is in use, the current code
checks software decompression state and always returns 0. This
(rightfully) confuses rsync, so fix by returning Z_STREAM_ERROR
instead.
infback.c:200:13: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
624: SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/runner/work/zlib-ng/zlib-ng/infback.c:200:13 in
Simplify zng_calloc and zng_cfree.
Make new static functions zng_alloc and zng_free available to other parts of the code.
Always request aligned allocations, even if UNALIGNED_OK is set.
Dan Kegel [Thu, 16 Jul 2020 16:59:52 +0000 (09:59 -0700)]
test/abicheck.sh: new script to verify abi compatibility with older versions
Verifies that zlib-ng's ABI has not changed since the reference commit
(indicated by variables ABI_URL and ABI_COMMIT in the script).
If --zlib-compat is given, the reference commit is zlib's 1.2.11;
otherwise, it's zlib-ng's 1d2504ddc489 (for now).
Ignores new symbols entirely, as they probably don't break backwards compatibility.
Ignores warnings listed in test/abi/ignore, currently, just those related to internal_state or z_stream*.
If --refresh is given, actually checks out the reference commit,
builds it, and stores its ABI description into an .abi file;
otherwise just uses the .abi file saved in git for that CHOST.
(--refresh_if is similar, but only does the above if the file
is not present.)
Known issues:
- pkgcheck.yml skips -m32 abicheck failures loudly until #705 is fixed
- although abicheck.sh supports -m32 (if in both CFLAGS and LDFLAGS), it doesn't yet support -32 in CONFIGURE_ARGS.
- only includes a few abi definitions; the rest can be added in a followon commit (see --refresh).
Changes to deflate's internal_state struct members:
- Change window_size from unsigned long to unsigned int
- Change block_start from long to int
- Change high_water from unsigned long to unsigned int
- Reorder to promote cache locality in hot code and decrease holes.
On x86_64 this means the struct goes from:
/* size: 6008, cachelines: 94, members: 57 */
/* sum members: 5984, holes: 6, sum holes: 24 */
/* last cacheline: 56 bytes */
To:
/* size: 5984, cachelines: 94, members: 57 */
/* sum members: 5972, holes: 3, sum holes: 8 */
/* padding: 4 */
/* last cacheline: 32 bytes */
value, which can be uint64_t, is printed using %llx, which, strictly
speaking, is not correct, and triggers -Wformat.
Since we don't really know what type value can have (send_bits_trace
is a macro), don't use <inttypes.h>, but rather cast it to long long.
Also cast length to int in order to prevent similar issues in the
future.
Some gcc versions complain that parameter c is always less than
MAX_MATCH-MIN_MATCH, and therefore the assertion that checks for this
is useless, but in reality some day MIN_MATCH and MAX_MATCH can change.