From: Lucas De Marchi Date: Thu, 1 Nov 2012 14:39:18 +0000 (-0200) Subject: modprobe: move log function X-Git-Tag: v11~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=07df56eb2434b04880e3c92be6ab63a4b4c8e4aa;p=thirdparty%2Fkmod.git modprobe: move log function --- diff --git a/tools/modprobe.c b/tools/modprobe.c index 17a8c171..5bfba572 100644 --- a/tools/modprobe.c +++ b/tools/modprobe.c @@ -184,6 +184,35 @@ static _always_inline_ const char *prio_to_str(int prio) return prioname; } +static void log_modprobe(void *data, int priority, const char *file, int line, + const char *fn, const char *format, va_list args) +{ + const char *prioname = prio_to_str(priority); + char *str; + + if (vasprintf(&str, format, args) < 0) + return; + + if (use_syslog) { +#ifdef ENABLE_DEBUG + syslog(priority, "%s: %s:%d %s() %s", prioname, file, line, + fn, str); +#else + syslog(priority, "%s: %s", prioname, str); +#endif + } else { +#ifdef ENABLE_DEBUG + fprintf(stderr, "modprobe: %s: %s:%d %s() %s", prioname, file, + line, fn, str); +#else + fprintf(stderr, "modprobe: %s: %s", prioname, str); +#endif + } + + free(str); + (void)data; +} + static inline void _log(int prio, const char *fmt, ...) { const char *prioname; @@ -796,35 +825,6 @@ static char **prepend_options_from_env(int *p_argc, char **orig_argv) return new_argv; } -static void log_modprobe(void *data, int priority, const char *file, int line, - const char *fn, const char *format, va_list args) -{ - const char *prioname = prio_to_str(priority); - char *str; - - if (vasprintf(&str, format, args) < 0) - return; - - if (use_syslog) { -#ifdef ENABLE_DEBUG - syslog(priority, "%s: %s:%d %s() %s", prioname, file, line, - fn, str); -#else - syslog(priority, "%s: %s", prioname, str); -#endif - } else { -#ifdef ENABLE_DEBUG - fprintf(stderr, "modprobe: %s: %s:%d %s() %s", prioname, file, - line, fn, str); -#else - fprintf(stderr, "modprobe: %s: %s", prioname, str); -#endif - } - - free(str); - (void)data; -} - static int do_modprobe(int argc, char **orig_argv) { struct kmod_ctx *ctx;