mirror of
https://github.com/AuxXxilium/kmod.git
synced 2025-03-10 07:53:48 +07:00
tools: share function to convert prio to string
No change is expected in the final binary since right now only an inline function is shared. Later we expect to share more code.
This commit is contained in:
parent
4a2e20dfb3
commit
84341fbe01
@ -108,7 +108,7 @@ noinst_SCRIPTS = tools/insmod tools/rmmod tools/lsmod \
|
||||
tools_kmod_SOURCES = tools/kmod.c tools/kmod.h tools/lsmod.c \
|
||||
tools/rmmod.c tools/insmod.c \
|
||||
tools/modinfo.c tools/modprobe.c \
|
||||
tools/depmod.c
|
||||
tools/depmod.c tools/log.h
|
||||
tools_kmod_LDADD = libkmod/libkmod-util.la \
|
||||
libkmod/libkmod.la
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include <getopt.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <limits.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/utsname.h>
|
||||
|
@ -38,3 +38,5 @@ extern const struct kmod_cmd kmod_cmd_list;
|
||||
|
||||
/* kmod.c */
|
||||
extern const char *binname;
|
||||
|
||||
#include "log.h"
|
||||
|
58
tools/log.h
Normal file
58
tools/log.h
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* kmod - log infrastructure
|
||||
*
|
||||
* Copyright (C) 2012 ProFUSION embedded systems
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include "kmod.h"
|
||||
|
||||
_always_inline_ const char *prio_to_str(int prio);
|
||||
|
||||
|
||||
_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;
|
||||
}
|
@ -154,38 +154,6 @@ static inline void _show(const char *fmt, ...)
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static _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;
|
||||
}
|
||||
|
||||
static void log_modprobe(void *data, int priority, const char *file, int line,
|
||||
const char *fn, const char *format, va_list args)
|
||||
{
|
||||
|
@ -62,38 +62,6 @@ static void help(void)
|
||||
binname);
|
||||
}
|
||||
|
||||
static _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;
|
||||
}
|
||||
|
||||
static void log_rmmod(void *data, int priority, const char *file, int line,
|
||||
const char *fn, const char *format, va_list args)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user