]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
kmod: use program_invocation_short_name more often
authorTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 19 Feb 2025 18:18:23 +0000 (19:18 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 21 Feb 2025 19:59:03 +0000 (13:59 -0600)
Remove the explicit basename(argv[0]) calls because we already
rely on program_invocation_short_name even before reaching
these lines. Unifies code and slightly reduces binary size.

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

index 434dd049814a197562a5811ad5bb1fabe7444bf5..6a9c996bbc9dc65eaa7567817841aafa640084a6 100644 (file)
@@ -53,7 +53,7 @@ static int kmod_help(int argc, char *argv[])
               "\t-V, --version     show version\n"
               "\t-h, --help        show this help\n\n"
               "Commands:\n",
-              basename(argv[0]));
+              program_invocation_short_name);
 
        for (i = 0; i < ARRAY_SIZE(kmod_cmds); i++) {
                if (kmod_cmds[i]->help != NULL) {
@@ -136,13 +136,10 @@ fail:
 
 static int handle_kmod_compat_commands(int argc, char *argv[])
 {
-       const char *cmd;
        size_t i;
 
-       cmd = basename(argv[0]);
-
        for (i = 0; i < ARRAY_SIZE(kmod_compat_cmds); i++) {
-               if (streq(kmod_compat_cmds[i]->name, cmd))
+               if (streq(kmod_compat_cmds[i]->name, program_invocation_short_name))
                        return kmod_compat_cmds[i]->cmd(argc, argv);
        }