diff options
author | Lucas De Marchi <lucas.demarchi@profusion.mobi> | 2012-11-06 19:06:11 -0200 |
---|---|---|
committer | Lucas De Marchi <lucas.demarchi@profusion.mobi> | 2012-11-06 19:06:11 -0200 |
commit | c84127372112642464fe3d266ffe58bbc1bc37f3 (patch) | |
tree | f8e25a51dc9b7099d2108b111b86b96b9669d872 | |
parent | fcb0ce9475509f22031e77456c1075c891cbcd2e (diff) | |
download | kmod-c84127372112642464fe3d266ffe58bbc1bc37f3.tar.gz |
tools: staticize functions that are now only used in log.c
-rw-r--r-- | tools/log.c | 55 | ||||
-rw-r--r-- | tools/log.h | 39 |
2 files changed, 43 insertions, 51 deletions
diff --git a/tools/log.c b/tools/log.c index c6887bd..745f5b3 100644 --- a/tools/log.c +++ b/tools/log.c @@ -27,22 +27,40 @@ static bool log_use_syslog; static int log_priority = LOG_ERR; -void log_open(bool use_syslog) +static _always_inline_ const char *prio_to_str(int prio) { - log_use_syslog = use_syslog; - - if (log_use_syslog) - openlog(binname, LOG_CONS, LOG_DAEMON); -} + const char *prioname; + char buf[32]; + + switch (prio) { + case LOG_CRIT: + prioname = "FATAL"; + break; + case LOG_ERR: + prioname = "ERROR"; + break; + case LOG_WARNING: + prioname = "WARNING"; + break; + case LOG_NOTICE: + prioname = "NOTICE"; + break; + case LOG_INFO: + prioname = "INFO"; + break; + case LOG_DEBUG: + prioname = "DEBUG"; + break; + default: + snprintf(buf, sizeof(buf), "LOG-%03d", prio); + prioname = buf; + } -void log_close(void) -{ - if (log_use_syslog) - closelog(); + return prioname; } -void log_kmod(void *data, int priority, const char *file, int line, - const char *fn, const char *format, va_list args) +static void log_kmod(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; @@ -69,6 +87,19 @@ void log_kmod(void *data, int priority, const char *file, int line, free(str); (void)data; } +void log_open(bool use_syslog) +{ + log_use_syslog = use_syslog; + + if (log_use_syslog) + openlog(binname, LOG_CONS, LOG_DAEMON); +} + +void log_close(void) +{ + if (log_use_syslog) + closelog(); +} void log_printf(int prio, const char *fmt, ...) { diff --git a/tools/log.h b/tools/log.h index 90817a3..fcd930a 100644 --- a/tools/log.h +++ b/tools/log.h @@ -26,8 +26,6 @@ void log_open(bool use_syslog); void log_close(void); -void log_kmod(void *data, int priority, const char *file, int line, - const char *fn, const char *format, va_list args); void log_printf(int prio, const char *fmt, ...); #define CRIT(...) log_printf(LOG_CRIT, __VA_ARGS__) #define ERR(...) log_printf(LOG_ERR, __VA_ARGS__) @@ -37,40 +35,3 @@ void log_printf(int prio, const char *fmt, ...); struct kmod_ctx; void log_setup_kmod_log(struct kmod_ctx *ctx, int priority); - -_always_inline_ const char *prio_to_str(int prio); - - -/* inline functions */ - -_always_inline_ const char *prio_to_str(int prio) -{ - const char *prioname; - char buf[32]; - - switch (prio) { - case LOG_CRIT: - prioname = "FATAL"; - break; - case LOG_ERR: - prioname = "ERROR"; - break; - case LOG_WARNING: - prioname = "WARNING"; - break; - case LOG_NOTICE: - prioname = "NOTICE"; - break; - case LOG_INFO: - prioname = "INFO"; - break; - case LOG_DEBUG: - prioname = "DEBUG"; - break; - default: - snprintf(buf, sizeof(buf), "LOG-%03d", prio); - prioname = buf; - } - - return prioname; -} |