Petr Písař [Tue, 4 Mar 2025 08:02:22 +0000 (09:02 +0100)]
Increase CMake version to 3.5
CMake 4.0.0 removed a support for CMake scripts older than 3.5 and a build
with CMake 4.0.0-rc2 fails like this:
$ /usr/bin/cmake -S . -B redhat-linux-build
CMake Warning (dev) at CMakeLists.txt:1 (PROJECT):
cmake_minimum_required() should be called prior to this top-level project()
call. Please see the cmake-commands(7) manual for usage documentation of
both commands.
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at CMakeLists.txt:3 (CMAKE_MINIMUM_REQUIRED):
Compatibility with CMake < 3.5 has been removed from CMake.
Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier.
Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.
-- Configuring incomplete, errors occurred!
There seems to be no way of making the script working with all
versions. CMake 3.5 was relased in 2016.
This patch increases the minimal version to 3.5 and moves it to the top
of the script as it needs to be the very first thing of a script as
recommeded by cmake:
CMake Warning (dev) at CMakeLists.txt:1 (PROJECT):
cmake_minimum_required() should be called prior to this top-level project()
call. Please see the cmake-commands(7) manual for usage documentation of
both commands.
I did not set a supported upper version of CMake since I guess
we do not want to update it with every new minor CMake release.
Other printed CMake warnings are not news are not addressed with
this patch.
Petr Písař [Fri, 7 Feb 2025 14:21:16 +0000 (15:21 +0100)]
Fix building in ISO C23
ISO C23 added bool type as a keyword. It is the standard GCC 15 uses by default and
compilation of bindings/perl/solv_perl.c fails then:
bindings/perl/solv_perl.c:1641:13: error: ‘bool’ cannot be defined via ‘typedef’
1641 | typedef int bool;
| ^~~~
/home/test/fedora/libsolv/libsolv-0.7.31-build/libsolv-0.7.31/redhat-linux-build/bindings/perl/solv_perl.c:1641:13: note: ‘bool’ is a keyword with ‘-std=c23’ onwards
/home/test/fedora/libsolv/libsolv-0.7.31-build/libsolv-0.7.31/redhat-linux-build/bindings/perl/solv_perl.c:1641:1: warning: useless type name in empty declaration
1641 | typedef int bool;
| ^~~~~~~
The typedef comes from bindings/solv.i which attemps to supply it in case Swig
undefines it.
This patch fixes it by not defining it in case ISO C23 or newer is in
use. Keywords cannot be checked by a preprocessor, neither undefined
(by Swig).
Make POOL_FLAG_ADDFILEPROVIDESFILTERED behaviour more standard
Turning on POOL_FLAG_ADDFILEPROVIDESFILTERED made the lookup of
all file dependencies lazy, not only the ones required by some
dependency. This changes the way searching works and may also
slow down some use cases.
We now changed addfileprovides() to record the needed non-standard
file dependencies and only make those lazy in createwhatprovides().
Petr Písař [Wed, 10 Jul 2024 14:54:56 +0000 (16:54 +0200)]
Fix a possible format overflow in dump_genid()
GCC 14 called with CFLAGS='-O2 -Wformat-overflow' complains:
/tmp/libsolv/ext/testcase.c: In function ‘dump_genid’:
/tmp/libsolv/ext/testcase.c:1275:33: warning: ‘: genid ’ directive writing 8 bytes into a region of size between 3 and 12 [-Wformat-overflow=]
1275 | sprintf(cntbuf, "genid %2d: genid ", cnt++);
| ^~~~~~~~
/tmp/libsolv/ext/testcase.c:1275:7: note: ‘sprintf’ output between 17 and 26 bytes into a destination of size 20
1275 | sprintf(cntbuf, "genid %2d: genid ", cnt++);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/libsolv/ext/testcase.c:1270:33: warning: ‘: genid ’ directive writing 8 bytes into a region of size between 3 and 12 [-Wformat-overflow=]
1270 | sprintf(cntbuf, "genid %2d: genid ", cnt++);
| ^~~~~~~~
/tmp/libsolv/ext/testcase.c:1270:7: note: ‘sprintf’ output between 17 and 26 bytes into a destination of size 20
1270 | sprintf(cntbuf, "genid %2d: genid ", cnt++);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
That's indeed a bug: sprintf() writes into a 20-byte array cntbuf. cnt
is int, 32-bit long integer on x86_64 Linux platform. dump_genid()
starts with cnt = 1 and increases. It can go up to 2147483647 decimal
value, then wrap to -2147483648 decimal value. That's up to 11 bytes
of the integer, plus 14 bytes of a static string, plus 1 byte of
a trailing '\0'. 26 bytes in total.
While it's improbable that cnt would amount that long number in real
life, it's better to be prepared for the worst. Also a benefit is that
static analyzers will be be content.
This patch increases cntbuf[] size to accomodate common 32-bit
ints. (Generic, albeit illegible, expression would be:
First resolve the given jobs, then the dependencies of the
resulting packages ignoreing the ones provided by currently
installed packages. After that resolve all already installed
packages. This is similar to SOLVER_FLAG_FOCUS_BEST but less
aggressive in updating packages.
This commit implements the file tree work needed
for the "plaindir" format. Like with the "find" command,
we do not follow symlinks to directories in recursive
mode.
Petr Písař [Mon, 13 May 2024 07:55:01 +0000 (09:55 +0200)]
Report unsupported compression in solv_xfopen() with errno
If libsolv was built without Zstandard support and "primary.xml.zst"
was passed solv_xfopen(), solv_xfopen() returned 0 without setting
errno. A calling application could not distinguish an unsupported
compression format from other I/O errors.
This patch improves this situation by setting errno variable to an
appropriate value. The value macros are documented in POSIX 2017.
getdecisionlist: keep track of all literals from a unit rule
Otherwise, sort_unit_decisions() may not find a unit rule and
go into and endless loop. Before this commit, we left out
conflicted packages to make the decisionlist shorter.
An alternative would be to track those left out literals.
David Cantrell [Tue, 26 Mar 2024 16:13:55 +0000 (12:13 -0400)]
Fix a couple small static analysis findings for uninitialized structs
The memset() on the KeyValue is more explicit even though if you trace
the code you will see it fills out the struct. However, it's possible
that not every struct member will be initialized and adding the
memset() makes things more obvious and appeases the static analyzer.
This seems to be unneeded as the Makefile written by cmake
automatically detects that it needs to rebuild if a different
python version is used. But just be be on the safe side...