]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Remove default initializer for static variables
authorEmil Velikov <emil.l.velikov@gmail.com>
Thu, 29 May 2025 08:30:58 +0000 (09:30 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 30 May 2025 02:16:00 +0000 (21:16 -0500)
The spec dictates that static variables are initialized to 0/NULL.
Remove the unnecessary explicit initialization - on older compilers this
sheds a few bytes off the data section of respective binaries.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/358
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod-file-xz.c
libkmod/libkmod-file-zlib.c
libkmod/libkmod-file-zstd.c
shared/util.h
testsuite/testsuite.c
tools/modinfo.c
tools/modprobe.c

index f693877065d2c716e58c2f5fdc3c408e46b8cf82..cafe828c2bd7c17752cea76fd54b0d08b2e5b4a0 100644 (file)
@@ -33,7 +33,7 @@ static int dlopen_lzma(void)
 #if !DLSYM_LOCALLY_ENABLED
        return 0;
 #else
-       static void *dl = NULL;
+       static void *dl;
 
        ELF_NOTE_DLOPEN("xz", "Support for uncompressing xz-compressed modules",
                        ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED, "liblzma.so.5");
index d4e0f8c3285bc7c70837682dd8cafaf75594e235..db9fc8e38191a9ee8878987a56d86921fe300f46 100644 (file)
@@ -36,7 +36,7 @@ static int dlopen_zlib(void)
 #if !DLSYM_LOCALLY_ENABLED
        return 0;
 #else
-       static void *dl = NULL;
+       static void *dl;
 
        ELF_NOTE_DLOPEN("zlib", "Support for uncompressing zlib-compressed modules",
                        ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED, "libz.so.1");
index f403a01b5934f58e295b7c71d2c8b292ba92a6db..8f0945976e9a129519db3d32e129e0118c728660 100644 (file)
@@ -35,7 +35,7 @@ static int dlopen_zstd(void)
 #if !DLSYM_LOCALLY_ENABLED
        return 0;
 #else
-       static void *dl = NULL;
+       static void *dl;
 
        ELF_NOTE_DLOPEN("zstd", "Support for uncompressing zstd-compressed modules",
                        ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED, "libzstd.so.1");
index 5a4256a2777fa4d85dcd879c9b7498c54efae525..1f59ec44a7f2e47d700a8d9b5cd00db46edcb2cb 100644 (file)
@@ -187,7 +187,7 @@ _sentinel_ int dlsym_many(void **dlp, const char *filename, ...);
 #define DLSYM_ARG(symbol__) &sym_##symbol__, STRINGIFY(symbol__),
 
 /* For symbols being dynamically loaded */
-#define DECLARE_DLSYM(symbol) static typeof(symbol) *sym_##symbol = NULL
+#define DECLARE_DLSYM(symbol) static typeof(symbol) *sym_##symbol
 
 /* Pointer indirection to support linking directly */
 #define DECLARE_PTRSYM(symbol) static typeof(symbol) *sym_##symbol = symbol
index 0407a7b5d87e3709db9b5784e67057530896a2d9..8e721040711e16d9977aebebdae4f16d3aaac0fb 100644 (file)
@@ -31,7 +31,7 @@ static const char *ANSI_HIGHLIGHT_RED_ON = "\x1B[1;31m";
 static const char *ANSI_HIGHLIGHT_OFF = "\x1B[0m";
 
 static const char *progname;
-static int oneshot = 0;
+static int oneshot;
 static const char options_short[] = "lhn";
 static const struct option options[] = {
        { "list", no_argument, 0, 'l' },
index 49b790fd0c0712f5c640d582f1a6ae8b32cecab0..75b574056aabae66095142cac691b19373f1311a 100644 (file)
@@ -22,7 +22,7 @@
 #include "kmod.h"
 
 static char separator = '\n';
-static const char *field = NULL;
+static const char *field;
 
 struct param {
        struct param *next;
index a32ccfbaac9b512a945d8c87768dc317820c9c64..a939a3b0ed403fee9c4d5e958f7fbead31570cb9 100644 (file)
@@ -32,19 +32,19 @@ static int log_priority = LOG_CRIT;
 
 #define DEFAULT_VERBOSE LOG_WARNING
 static int verbose = DEFAULT_VERBOSE;
-static int do_show = 0;
-static int dry_run = 0;
-static int ignore_loaded = 0;
-static int lookup_only = 0;
-static int first_time = 0;
-static int ignore_commands = 0;
-static int use_blacklist = 0;
-static int force = 0;
-static int strip_modversion = 0;
-static int strip_vermagic = 0;
-static int remove_holders = 0;
-static unsigned long long wait_msec = 0;
-static int quiet_inuse = 0;
+static int do_show;
+static int dry_run;
+static int ignore_loaded;
+static int lookup_only;
+static int first_time;
+static int ignore_commands;
+static int use_blacklist;
+static int force;
+static int strip_modversion;
+static int strip_vermagic;
+static int remove_holders;
+static unsigned long long wait_msec;
+static int quiet_inuse;
 
 static const char cmdopts_s[] = "arw:RibfDcnC:d:S:sqvVh";
 static const struct option cmdopts[] = {