From: Emil Velikov Date: Sat, 24 May 2025 11:06:13 +0000 (+0100) Subject: shared: use strlen() for string literals X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dfaed74ccbe42b34c384f926a078416199d64baa;p=thirdparty%2Fkmod.git shared: use strlen() for string literals 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 Link: https://github.com/kmod-project/kmod/pull/354 Signed-off-by: Lucas De Marchi --- diff --git a/shared/util.c b/shared/util.c index e6916f84..ba918154 100644 --- a/shared/util.c +++ b/shared/util.c @@ -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 {}, };