]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
tools: use bool instead of int for log_open
authorTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 18 Feb 2025 21:20:46 +0000 (22:20 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 18 Feb 2025 21:42:17 +0000 (15:42 -0600)
Since log_open takes a booln as argument, turn use_syslog into a
bool instead of using an int. Shrinks binary size with GCC and from
C point of view, this makes the code cleaner.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/282
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
tools/insmod.c
tools/lsmod.c
tools/modprobe.c
tools/rmmod.c

index f7916b5f13c47434ee26e734468456d9ff916b0c..fef00722a8b549c9dc639ed057a2102246a7f30b 100644 (file)
@@ -65,7 +65,7 @@ static int do_insmod(int argc, char *argv[])
        const char *filename;
        char *opts = NULL;
        int verbose = LOG_ERR;
-       int use_syslog = 0;
+       bool use_syslog = false;
        int c, r = 0;
        const char *null_config = NULL;
        unsigned int flags = 0;
@@ -77,7 +77,7 @@ static int do_insmod(int argc, char *argv[])
                        flags |= KMOD_PROBE_FORCE_VERMAGIC;
                        break;
                case 's':
-                       use_syslog = 1;
+                       use_syslog = true;
                        break;
                case 'v':
                        verbose++;
index ea68d1dcefb89896b8fd06ef59bfdf166aac784a..4ece1fbd87d82c62a2de41a54635d23135919a8f 100644 (file)
@@ -44,13 +44,13 @@ static int do_lsmod(int argc, char *argv[])
        const char *null_config = NULL;
        struct kmod_list *list, *itr;
        int verbose = LOG_ERR;
-       int use_syslog = 0;
+       bool use_syslog = false;
        int err, c, r = 0;
 
        while ((c = getopt_long(argc, argv, cmdopts_s, cmdopts, NULL)) != -1) {
                switch (c) {
                case 's':
-                       use_syslog = 1;
+                       use_syslog = true;
                        break;
                case 'v':
                        verbose++;
index ec66e6fcbee7be88f97cff3e62b60cb29f74dabb..79c9fe1d18f900080e80cb8a3a8b95524bd74e73 100644 (file)
@@ -28,7 +28,7 @@
 #include "kmod.h"
 
 static int log_priority = LOG_CRIT;
-static int use_syslog = 0;
+static bool use_syslog = false;
 #define LOG(...) log_printf(log_priority, __VA_ARGS__)
 
 #define DEFAULT_VERBOSE LOG_WARNING
@@ -861,7 +861,7 @@ static int do_modprobe(int argc, char **orig_argv)
                        break;
                case 's':
                        env_modprobe_options_append("-s");
-                       use_syslog = 1;
+                       use_syslog = true;
                        break;
                case 'q':
                        env_modprobe_options_append("-q");
@@ -894,7 +894,7 @@ static int do_modprobe(int argc, char **orig_argv)
 
        if (!use_syslog &&
            (!stderr || fileno(stderr) == -1 || fstat(fileno(stderr), &stat_buf)))
-               use_syslog = 1;
+               use_syslog = true;
 
        log_open(use_syslog);
 
index 0e00edec2671d837292c0487f03524cae3bd66ac..962d85054df0142de7c283d9d425e2be988bd599 100644 (file)
@@ -94,7 +94,7 @@ static int do_rmmod(int argc, char *argv[])
        struct kmod_ctx *ctx;
        const char *null_config = NULL;
        int verbose = LOG_ERR;
-       int use_syslog = 0;
+       bool use_syslog = false;
        int flags = 0;
        int i, c, r = 0;
 
@@ -104,7 +104,7 @@ static int do_rmmod(int argc, char *argv[])
                        flags |= KMOD_REMOVE_FORCE;
                        break;
                case 's':
-                       use_syslog = 1;
+                       use_syslog = true;
                        break;
                case 'v':
                        verbose++;