From: Lucas De Marchi Date: Tue, 6 Nov 2012 21:20:09 +0000 (-0200) Subject: tools: use program_invocation_short_name provided by libc X-Git-Tag: v11~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c04aeee40e9cced2656e286b2dc4bfbe8008a9f;p=thirdparty%2Fkmod.git tools: use program_invocation_short_name provided by libc Thanks to Dave Reisner for pointing this out. --- diff --git a/tools/depmod.c b/tools/depmod.c index 7d36a509..cc9346fe 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -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, ...) diff --git a/tools/insmod.c b/tools/insmod.c index f358b937..427495af 100644 --- a/tools/insmod.c +++ b/tools/insmod.c @@ -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) diff --git a/tools/kmod.c b/tools/kmod.c index 7de95111..5a6bc14c 100644 --- a/tools/kmod.c +++ b/tools/kmod.c @@ -25,9 +25,6 @@ #include #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); diff --git a/tools/kmod.h b/tools/kmod.h index ceff8610..59a87e0b 100644 --- a/tools/kmod.h +++ b/tools/kmod.h @@ -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" diff --git a/tools/log.c b/tools/log.c index 745f5b3d..a28cebf7 100644 --- a/tools/log.c +++ b/tools/log.c @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +#include #include #include #include @@ -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) diff --git a/tools/modinfo.c b/tools/modinfo.c index 8cfe381f..aec2608d 100644 --- a/tools/modinfo.c +++ b/tools/modinfo.c @@ -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) diff --git a/tools/modprobe.c b/tools/modprobe.c index 4b30759e..437dea32 100644 --- a/tools/modprobe.c +++ b/tools/modprobe.c @@ -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, ...) diff --git a/tools/rmmod.c b/tools/rmmod.c index 7be46041..04954639 100644 --- a/tools/rmmod.c +++ b/tools/rmmod.c @@ -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) {