]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
shared: use strlen() for string literals
authorEmil Velikov <emil.l.velikov@gmail.com>
Sat, 24 May 2025 11:06:13 +0000 (12:06 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Thu, 29 May 2025 22:10:16 +0000 (17:10 -0500)
Older compilers had struggles expanding strlen(string-literal) to a
constant compile time expression. Thus our code-base used sizeof() - 1
instead.

This has been resolved for years, so let's use the correct function.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/354
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
shared/util.c

index e6916f84ad8743506f2d2d6f2b27f6f2288941a0..ba9181542b0d78f9675ad6e2c7e83fa14e7bcefb 100644 (file)
@@ -26,15 +26,15 @@ static const struct kmod_ext {
        const char *ext;
        size_t len;
 } kmod_exts[] = {
-       { KMOD_EXTENSION_UNCOMPRESSED, sizeof(KMOD_EXTENSION_UNCOMPRESSED) - 1 },
+       { KMOD_EXTENSION_UNCOMPRESSED, strlen(KMOD_EXTENSION_UNCOMPRESSED) },
 #if ENABLE_ZLIB
-       { ".ko.gz", sizeof(".ko.gz") - 1 },
+       { ".ko.gz", strlen(".ko.gz") },
 #endif
 #if ENABLE_XZ
-       { ".ko.xz", sizeof(".ko.xz") - 1 },
+       { ".ko.xz", strlen(".ko.xz") },
 #endif
 #if ENABLE_ZSTD
-       { ".ko.zst", sizeof(".ko.zst") - 1 },
+       { ".ko.zst", strlen(".ko.zst") },
 #endif
        {},
 };