Some are outdated, misleading or just repeat the same thing over and
over. Remove them as they are not needed.
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://lore.kernel.org/r/20240723185921.1005569-3-lucas.de.marchi@gmail.com
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Drop the lengthy license from each file and just use SPDX like most
projects nowadays. This doesn't have any change to license, just how
they are recorded in each file.
This follows the kernel approach: header files use '/*' for comments
while .c files use '//'. For .m4, use "#".
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://lore.kernel.org/r/20240723185921.1005569-2-lucas.de.marchi@gmail.com
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
musl has removed the non-prototype declaration of basename from
string.h [1] which now results in build errors with clang-17+ compiler
Implement GNU basename behavior using strchr which is portable across libcs
Fixes
../git/tools/kmod.c:71:19: error: call to undeclared function 'basename'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
71 | "Commands:\n", basename(argv[0]));
| ^
[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7
Suggested-by: Rich Felker
Signed-off-by: Khem Raj <raj.khem@gmail.com>
[ Implement a basename() function in missing.h and ensure we always use
the right include rather than having a separate gnu_basename() ]
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The symbol was somewhat recently introduced by the kernel and not all
distributions may be have available.
The number is part of the ABI, so we can add a local fallback define.
Closes: https://github.com/kmod-project/kmod/issues/29
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Fix the following warning reported by UBSan (as of gcc-13.1.1):
shared/hash.c:244:35: runtime error: null pointer passed as
argument 2, which is declared to never be null
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
[ reshuffle the code to use return-early style ]
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
None of the API is used outside of the compilation unit.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Add simple functions to put the current thread to sleep using
exponential backoff to split the interval in smaller pieces.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
We need a macro indirection for UNIQ to work. Otherwise it won't be
unique at all since it will just append "UNIQ" to the name:
In file included from testsuite/test-init.c:30:
testsuite/testsuite.h:142:27: error: redefinition of ‘stest_load_resourcesUNIQ’
I changed the style of the hackargs variable in autogen.sh to multiline
because said line was becoming a bit long with the new --with-zstd arg
added.
A previous version of this patch has been running on my two Arch Linux
installations (with an accompanying mkinitcpio patch) for several months
over many kernel updates without any issues.
Any additional testing and/or patch review would of course be appreciated.
Signed-off-by: Torge Matthies <openglfreak@googlemail.com>
shared/macro.h has two versions of assert_cc, one that uses gcc
_Static_assert(), which requires recent enough gcc versions, and one
that uses a fake array to trigger a build error. The latter can only
work inside functions, so assert_cc() should only be used inside
functions.
Fixes the following build failure when building kmod with old gcc
versions such as gcc 4.3.x:
shared/util.c:52: error: expected identifier or '(' before 'do'
shared/util.c:52: error: expected identifier or '(' before 'while'
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
It fixes linking problem
tools/depmod.o: In function `output_symbols_bin':
depmod.c:(.text.output_symbols_bin+0x135): undefined reference to `scratchbuf_str'
for -O0 build, where gcc doesn't actually inline it.
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
This should fill the requirements for "we need to loop over a lot of
strings that usually are small enough to remain on stack, but we want to
protect ourselves against huge strings not fitting in the static
buffer we estimated as sufficient"
shared/util.c: In function ‘read_str_safe’:
shared/util.c:211:24: warning: logical ‘or’ of equal expressions [-Wlogical-op]
if (errno == EAGAIN || errno == EWOULDBLOCK ||
^~
shared/util.c: In function ‘write_str_safe’:
shared/util.c:237:24: warning: logical ‘or’ of equal expressions [-Wlogical-op]
if (errno == EAGAIN || errno == EWOULDBLOCK ||
^~
This is because EAGAIN and EWOULDBLOCK have the same value. Prefer
EAGAIN, but add a static assert to catch if it's not the same in another
architecture.
Since we pass -std=gnu99 to the compiler __STDC_VERSION__ is defined to
199901. Even in this case we can use _Noreturn. Delegate the testing to
the configure phase with a compile test.
In future we want to stop using AC_PROG_CC_99 and start using the new
AC_PROG_CC from autoconf 2.70, which tries to choose the most recent
standard.
Use _builtin_uaddll_overflow/_builtin_uaddl_overflow when available,
abstracting the type to use it with uint64_t.
Otherwise fallback to the implementation as added in 67466f2 ("Prevent
offset + size overflow.").
This also adds the tests for this new helper in the testsuite.
Make the includes be libkmod/libkmod.h for code outside of library. This
fixes the broken build after 1315123 ('build-sys: Don't add libkmod
subdirectory to include path').
It has changed in the past, and these days, anyone can get a copy of the
LGPL via the web rather than by post.
Like 657a122 (Remove FSF mailing address) in libabc by Josh Tripplet,
but let the FSF website in which the license can be found.
Using 2048 as buffer sizer for strbuf is a bit exaggerated. strbuf is
used much more when we are not using mmapped indexes, but it's used for
mmapped when for example searching for an alias. A quick and dirty hack
to output the size of our strbufs is to print buf->used inside
strbuf_str(). Doing this and creating some statistics with:
while read xxx alias xxx; do
tools/modprobe -R "$alias" > /dev/null;
done < /lib/modules/$(uname -r)/modules.alias 2>&1 | \
Rscript -e 'summary (as.numeric (readLines ("stdin")))'
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
1.00 29.00 31.00 31.55 38.00 92.00 26
So, reduce the step to 128, which is still greater than the maximum in
these cases. In the worst case this can only create a few calls to
realloc(), while keeping the memory footprint low for the common cases.
Move underscores() to shared/. It's the same as alias_normalize(), but
it rather operates in place, with the same string being passed.
The difference now that it's in shared/ is that it's a non-logging
function.
This makes us a little bit more verbose: we don't accept partially
correct module and aliases names in kcmdline and in configuration files.
We log an error instead.