Commit Graph

2660 Commits

Author SHA1 Message Date
Lasse Collin 4ad88b2544 Tests: test_index: Test lzma_index_buffer_decode() more 2024-04-27 15:13:39 +03:00
Lasse Collin 575b11b0d2 Tests: test_index: Test that *i = NULL is done on LZMA_PROG_ERROR
On LZMA_DATA_ERROR from lzma_index_buffer_decode(), *i = NULL was
already done but this adds a test for that case too.
2024-04-27 15:08:29 +03:00
Lasse Collin 2c970debdb Tests: test_index: Test lzma_index_buffer_encode() with empty output buf 2024-04-27 15:01:25 +03:00
Lasse Collin cd88423e76 Tests: test_index: Replace if-statements with tuktest assertions 2024-04-27 14:59:55 +03:00
Lasse Collin 7f865577a6 Tests: test_index: Make it clear that my_alloc() has no integer overflows
liblzma guarantees that the product of the allocation size arguments
will fit in size_t.

Putting the pre-increment in the if-statement was clearly wrong
although in practice it didn't matter here as the function is
called only a couple of times.
2024-04-27 14:56:16 +03:00
Lasse Collin 12313a3b65 Tests: test_index: Verify also iter.block.number_in_stream 2024-04-27 14:51:52 +03:00
Lasse Collin ad2654010d Tests: test_index: Check cases that aren't a multiple of 4 bytes 2024-04-27 14:51:06 +03:00
Lasse Collin 2524fcf2b6 Tests: test_index: Edit comments and white space 2024-04-27 14:40:25 +03:00
Lasse Collin 71eed2520e liblzma: index_decoder: Fix missing initializations on LZMA_PROG_ERROR
If the arguments to lzma_index_decoder() or lzma_index_buffer_decode()
were such that LZMA_PROG_ERROR was returned, the lzma_index **i
argument wasn't touched even though the API docs say that *i = NULL
is done if an error occurs. This obviously won't be done even now
if i == NULL but otherwise it is best to do it due to the wording
in the API docs.

In practice this matters very little: The problem can occur only
if the functions are called with invalid arguments, that is,
the calling application must already have a bug.
2024-04-27 14:33:38 +03:00
Lasse Collin 0478473953 CMake: Bump maximum policy version to 3.29 2024-04-26 18:25:18 +03:00
Sam James a607e2b40d ci: add NetBSD 2024-04-25 14:08:52 +03:00
Sam James 72c210336d ci: add FreeBSD 2024-04-25 14:08:52 +03:00
Sam James b526ec2dbf ci: add OpenBSD 2024-04-25 14:08:52 +03:00
Sam James c7ef767c49 liblzma: outqueue: add header guard
Reported by github's codeql.
2024-04-25 14:04:24 +03:00
Sam James 55dcae3056 liblzma: easy_preset: add header guard
Reported by github's codeql.
2024-04-25 14:04:24 +03:00
Lasse Collin 4ffc60f323 tuklib_integer: Rename bswapXX to byteswapXX
The __builtin_bswapXX from GCC and Clang are preferred when
they are available. This can allow compilers to emit the x86 MOVBE
instruction instead of doing a load + byteswap as two instructions
(which would happen if the byteswapping is done in inline asm).

bswap16, bswap32, and bswap64 exist in system headers on *BSDs
and Darwin. #defining bswap16 on NetBSD results in a warning about
macro redefinition. It's safest to avoid this namespace conflict
completely.

No OS supported by tuklib_integer.h uses byteswapXX names and
a web search doesn't immediately find any obvious danger of
namespace conflicts. So let's try these still-pretty-short names
for the macros.

Thanks to Sam James for pointing out the compiler warning on
NetBSD 10.0.
2024-04-25 14:00:57 +03:00
Lasse Collin 08ab0966a7 liblzma: API doc cleanups 2024-04-24 01:20:58 +03:00
Lasse Collin 3ac8a9bb4c Tests: test_filter_str: Add a few assertions 2024-04-23 16:35:33 +03:00
Lasse Collin 26c69be805 Tests: test_filter_str: Move one assertion and add a comment 2024-04-23 16:35:08 +03:00
Lasse Collin 4f6af853bc Tests: test_filter_str: Tweak comments and white space 2024-04-23 16:26:06 +03:00
Lasse Collin c92663aa1b Tests: test_filter_str: Add missing RISC-V case
Fixes: 89ea1a22f4
2024-04-23 16:25:22 +03:00
Lasse Collin b0366df1d7 Tests: test_filter_str: Test *error_pos more thoroughly 2024-04-22 23:01:53 +03:00
Lasse Collin 70d12dd069 liblzma: lzma_str_to_filters: Set *error_pos on all errors
The API docs clearly say that if error_pos isn't NULL then *error
is always set on any error. However, it wasn't touched if str == NULL
or filters == NULL or unsupported flags were specified.

Fixes: cedeeca2ea
2024-04-22 22:03:04 +03:00
Lasse Collin ed8e552395 liblzma: Clean up white space 2024-04-22 20:31:25 +03:00
Lasse Collin 2f06920f20 Tests: test_filter_flags: Edit comments and style 2024-04-22 18:35:19 +03:00
Lasse Collin b101e1d1db Tests: Fix C99/C11 compatibility when features are disabled
The array could become empty and then the initializer would be
simply {} which is allowed only in GNU-C and C23.
2024-04-22 16:39:44 +03:00
Lasse Collin f8f3a220ac DOS: Omit useless defines from config.h 2024-04-21 20:32:16 +03:00
Lasse Collin fc1921b04b Build: Omit useless checks for fcntl.h, limits.h, and sys/time.h 2024-04-21 20:27:50 +03:00
Lasse Collin 6aa2a6deeb liblzma: Silence a warning from Coverity static analysis
It is logical why it cannot know for sure that the value has
to be at most 4 if it is less than 16.

The x86 filter is based on a very old LZMA SDK version. Newer
ones have quite a different implementation for the same filter.

Thanks to Sam James.
2024-04-20 12:09:37 +03:00
Lasse Collin e89d3e83b4 Update .gitignore 2024-04-19 23:18:19 +03:00
Lasse Collin 86fc4ee859 Tests: test_lzip_decoder: Tweak coding style and comments 2024-04-19 20:53:24 +03:00
Lasse Collin 38be573a27 Tests: test_lzip_decoder: Remove redundant initializations 2024-04-19 20:51:36 +03:00
Lasse Collin d7e4bc53ea Tests: test_lzip_decoder: Remove unneeded tuktest_malloc() calls 2024-04-19 20:47:24 +03:00
Lasse Collin eeca8f7c5b xz: Fix white space error.
Thanks to xx on #tukaani.
2024-04-15 20:35:07 +03:00
Sam James 462ca94099 xz: add missing noreturn for message_filters_help
Fixes: a165d7df19
2024-04-14 17:26:54 +03:00
Sam James 863f13d282 xz: signals: suppress -Wsign-conversion on macOS
On macOS, we get:
```
signals.c: In function 'signals_init':
signals.c:76:17: error: conversion to 'sigset_t' {aka 'unsigned int'} from 'int' may change the sign of the result [-Werror=sign-conversion]
   76 |                 sigaddset(&hooked_signals, sigs[i]);
      |                 ^~~~~~~~~
signals.c:81:17: error: conversion to 'sigset_t' {aka 'unsigned int'} from 'int' may change the sign of the result [-Werror=sign-conversion]
   81 |                 sigaddset(&hooked_signals, message_progress_sigs[i]);
      |                 ^~~~~~~~~
signals.c:86:9: error: conversion to 'sigset_t' {aka 'unsigned int'} from 'int' may change the sign of the result [-Werror=sign-conversion]
   86 |         sigaddset(&hooked_signals, SIGTSTP);
      |         ^~~~~~~~~
```

We use `int` for `hooked_signals` but we can't just cast to whatever
`sigset_t` is because `sigset_t` is an opaque type. It's an unsigned int
on macOS. On macOS, `sigaddset` is implemented as a macro.

Just suppress -Wsign-conversion for `signals_init` for macOS given
there's no real nice way of fixing this.
2024-04-14 17:26:43 +03:00
Lasse Collin fcbd0d1999 Tests: test_microlzma: Add a "FIXME?" about LZMA_FINISH handling 2024-04-13 22:39:10 +03:00
Lasse Collin 0fe2dfa683 Tests: test_microlzma: Tweak comments, coding style, and minor details
A few lines were reordered, a few ARRAY_SIZE were changed to sizeof,
and a few uint32_t were changed to size_t. No real functional changes
were intended.
2024-04-13 21:01:10 +03:00
Ryan Carsten Schmidt 97f0ee0f1f
CI: Use only the active CPUs on macOS
hw.ncpu counts all CPUs including inactive ones. hw.activecpu counts
only the active CPUs.
2024-04-12 19:31:13 -05:00
Sam James 73f629e321 ci: rename ci_build.sh -> ci_build.bash
We discussed the name and it's less cognitive load to just call it '.bash'
so you don't have an immediate question about if bashisms are OK.
2024-04-11 00:15:35 +03:00
Sam James 8709407a9e ci: build in parallel by default 2024-04-11 00:15:35 +03:00
Sam James 65bf7e0a1c ci: default to -O2
We need this for when we're passing sanitizer flags or -gdwarf-4 for Clang
with Valgrind. Just always start with -O2 if CFLAGS isn't set in the
environment and append what was passed on the command line.
2024-04-11 00:15:35 +03:00
Sam James bc899f9e07 ci: make automake's test runner verbose on failures
This is a lot easier to work with than the save-logs thing the action
tries to do...
2024-04-11 00:15:35 +03:00
Sam James b5e3470442 ci: make UBSAN abort on errors
Unfortunately, UBSAN doesn't do this by default. See also the change
I made in Meson for this in October [0].

[0] 7b7d2e060b
2024-04-11 00:15:35 +03:00
Sam James 6c095a98fb ci: test Valgrind
Using `--trace-children=yes` has a trade-off here, as it makes
`test_scripts.sh` pretty slow when calling various non-xz utilities.

But I also feel like it's not useless to have Valgrind used there and it's
not easy to exclude Valgrind just for that one test...

I did consider using AX_VALGRIND_CHECK [0][1] but I couldn't get it working
immediately with some conditionally-built tests and I wondered if it was
worth spending time on at least while we're debating xz's future build
system situation.

[0] https://www.gnu.org/software/autoconf-archive/ax_valgrind_check.html
[1] https://tecnocode.co.uk/2014/12/23/automatically-valgrinding-code-with-ax_valgrind_check/
2024-04-11 00:15:35 +03:00
Lasse Collin 6286c1900c liblzma: CRC: Simplify table omission macros
A macro is useful to prevent a single #if directive from
getting too ugly but only one macro is needed for all archs.
2024-04-10 23:33:17 +03:00
Lasse Collin 45da936c87 liblzma: ARM64 CRC: Fix omission of CRC32 table
The macro name had an odd typo so the table wasn't omitted
when it should have.

Fixes: 1940f0ec28
2024-04-10 23:12:23 +03:00
Lasse Collin 308a9af854 Build: If ARM64 feature detection func is found, stop looking for others
This can speed up configure a tiny bit.

Fixes: c5f6d79cc9
2024-04-10 23:12:23 +03:00
Lasse Collin fc43cecd32 liblzma: ARM64 CRC32: Change style of the macOS code to match FreeBSD
I didn't test this but it shouldn't change any functionality.

Fixes: 761f5b69a4
2024-04-10 23:12:23 +03:00
Lasse Collin 1024cd4cd9 liblzma: ARM64 CRC32: Add error checking to FreeBSD-specific code
Also add parenthesis to the return statement.

I didn't test this.

Fixes: 761f5b69a4
2024-04-10 23:12:23 +03:00