]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
tools: use program_invocation_short_name provided by libc
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 6 Nov 2012 21:20:09 +0000 (19:20 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 6 Nov 2012 21:30:16 +0000 (19:30 -0200)
Thanks to Dave Reisner for pointing this out.

tools/depmod.c
tools/insmod.c
tools/kmod.c
tools/kmod.h
tools/log.c
tools/modinfo.c
tools/modprobe.c
tools/rmmod.c

index 7d36a50945dc48d93c13ec6b0a843f71c00dbde0..cc9346fe69c64ffa0ecd5c2ee094387d62d88e38 100644 (file)
@@ -114,7 +114,7 @@ static void help(void)
                "\t                     current kernel symbols.\n"
                "\t-E, --symvers=FILE   Use Module.symvers file to check\n"
                "\t                     symbol versions.\n",
-               binname);
+               program_invocation_short_name);
 }
 
 static inline void _show(const char *fmt, ...)
index f358b93774bd47b219ffa240ab3195cc08dc5e74..427495afae79ce00f6dbba2a0125fbcafe8cc51f 100644 (file)
@@ -40,7 +40,7 @@ static void help(void)
                "Options:\n"
                "\t-V, --version     show version\n"
                "\t-h, --help        show this help\n",
-               binname);
+               program_invocation_short_name);
 }
 
 static const char *mod_strerror(int err)
index 7de951112233053caa866c33f0b5d508e696cae3..5a6bc14ce6ec0a7adff4bcbe0bf5cc0949e37a16 100644 (file)
@@ -25,9 +25,6 @@
 #include <libkmod.h>
 #include "kmod.h"
 
-/* visible to all tools, compat or otherwise */
-const char *binname;
-
 static const char options_s[] = "+hV";
 static const struct option options[] = {
        { "help", no_argument, NULL, 'h' },
@@ -162,9 +159,7 @@ int main(int argc, char *argv[])
 {
        int err;
 
-       binname = basename(argv[0]);
-
-       if (strcmp(binname, "kmod") == 0)
+       if (strcmp(program_invocation_short_name, "kmod") == 0)
                err = handle_kmod_commands(argc, argv);
        else
                err = handle_kmod_compat_commands(argc, argv);
index ceff8610f1a7df53bcfcdb44655c525fcfe8414f..59a87e0b08ee30d620e96a4d780de4bc32eb5bbe 100644 (file)
@@ -36,7 +36,4 @@ extern const struct kmod_cmd kmod_cmd_compat_depmod;
 
 extern const struct kmod_cmd kmod_cmd_list;
 
-/* kmod.c */
-extern const char *binname;
-
 #include "log.h"
index 745f5b3d3f7cf317bd46aed57ad19256095e0c1b..a28cebf770822d517dc8dcea5b753ac5482bf8d4 100644 (file)
@@ -17,6 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <syslog.h>
@@ -77,10 +78,12 @@ static void log_kmod(void *data, int priority, const char *file, int line,
 #endif
        } else {
 #ifdef ENABLE_DEBUG
-               fprintf(stderr, "%s: %s: %s:%d %s() %s", binname, prioname,
-                       file, line, fn, str);
+               fprintf(stderr, "%s: %s: %s:%d %s() %s",
+                       program_invocation_short_name, prioname, file, line,
+                       fn, str);
 #else
-               fprintf(stderr, "%s: %s: %s", binname, prioname, str);
+               fprintf(stderr, "%s: %s: %s", program_invocation_short_name,
+                       prioname, str);
 #endif
        }
 
@@ -92,7 +95,7 @@ void log_open(bool use_syslog)
        log_use_syslog = use_syslog;
 
        if (log_use_syslog)
-               openlog(binname, LOG_CONS, LOG_DAEMON);
+               openlog(program_invocation_short_name, LOG_CONS, LOG_DAEMON);
 }
 
 void log_close(void)
@@ -122,7 +125,8 @@ void log_printf(int prio, const char *fmt, ...)
        if (log_use_syslog)
                syslog(prio, "%s: %s", prioname, msg);
        else
-               fprintf(stderr, "%s: %s: %s", binname, prioname, msg);
+               fprintf(stderr, "%s: %s: %s", program_invocation_short_name,
+                       prioname, msg);
        free(msg);
 
        if (prio <= LOG_CRIT)
index 8cfe381ff1f5ee043c404d2a1b8683a6229f711f..aec2608d5c1b349e6dde77b299eb69b7c6f289b0 100644 (file)
@@ -341,7 +341,7 @@ static void help(void)
                "\t-b, --basedir=DIR           Use DIR as filesystem root for /lib/modules\n"
                "\t-V, --version               Show version\n"
                "\t-h, --help                  Show this help\n",
-               binname);
+               program_invocation_short_name);
 }
 
 static bool is_module_filename(const char *name)
index 4b30759ef0ef9e632bb971757d263052e691651d..437dea32acd0e4a87d0c34c175c0a0ea11edb015 100644 (file)
@@ -137,7 +137,9 @@ static void help(void)
                "\t-v, --verbose               enables more messages\n"
                "\t-V, --version               show version\n"
                "\t-h, --help                  show this help\n",
-               binname, binname, binname, binname, binname, binname);
+               program_invocation_short_name, program_invocation_short_name,
+               program_invocation_short_name, program_invocation_short_name,
+               program_invocation_short_name, program_invocation_short_name);
 }
 
 static inline void _show(const char *fmt, ...)
index 7be460417e60da8ef514d56effa20414f9b083bc..0495463918009abeb2f11859d8886e22e41f3376 100644 (file)
@@ -57,7 +57,7 @@ static void help(void)
                "\t-v, --verbose     enables more messages\n"
                "\t-V, --version     show version\n"
                "\t-h, --help        show this help\n",
-               binname);
+               program_invocation_short_name);
 }
 
 static int check_module_inuse(struct kmod_module *mod) {