Commit 4079fe8e authored by Masahiro Yamada's avatar Masahiro Yamada

modpost: simplify modpost_log()

With commit cda5f94e ("modpost: avoid using the alias attribute"),
only two log levels remain: LOG_WARN and LOG_ERROR. Simplify this by
making it a boolean variable.
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
Reviewed-by: default avatarNathan Chancellor <nathan@kernel.org>
parent 5b000f3c
...@@ -67,20 +67,15 @@ static unsigned int nr_unresolved; ...@@ -67,20 +67,15 @@ static unsigned int nr_unresolved;
#define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) #define MODULE_NAME_LEN (64 - sizeof(Elf_Addr))
void modpost_log(enum loglevel loglevel, const char *fmt, ...) void modpost_log(bool is_error, const char *fmt, ...)
{ {
va_list arglist; va_list arglist;
switch (loglevel) { if (is_error) {
case LOG_WARN:
fprintf(stderr, "WARNING: ");
break;
case LOG_ERROR:
fprintf(stderr, "ERROR: "); fprintf(stderr, "ERROR: ");
error_occurred = true; error_occurred = true;
break; } else {
default: /* invalid loglevel, ignore */ fprintf(stderr, "WARNING: ");
break;
} }
fprintf(stderr, "modpost: "); fprintf(stderr, "modpost: ");
...@@ -1689,7 +1684,7 @@ static void check_exports(struct module *mod) ...@@ -1689,7 +1684,7 @@ static void check_exports(struct module *mod)
exp = find_symbol(s->name); exp = find_symbol(s->name);
if (!exp) { if (!exp) {
if (!s->weak && nr_unresolved++ < MAX_UNRESOLVED_REPORTS) if (!s->weak && nr_unresolved++ < MAX_UNRESOLVED_REPORTS)
modpost_log(warn_unresolved ? LOG_WARN : LOG_ERROR, modpost_log(!warn_unresolved,
"\"%s\" [%s.ko] undefined!\n", "\"%s\" [%s.ko] undefined!\n",
s->name, mod->name); s->name, mod->name);
continue; continue;
...@@ -1712,7 +1707,7 @@ static void check_exports(struct module *mod) ...@@ -1712,7 +1707,7 @@ static void check_exports(struct module *mod)
basename = mod->name; basename = mod->name;
if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) { if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) {
modpost_log(allow_missing_ns_imports ? LOG_WARN : LOG_ERROR, modpost_log(!allow_missing_ns_imports,
"module %s uses symbol %s from namespace %s, but does not import it.\n", "module %s uses symbol %s from namespace %s, but does not import it.\n",
basename, exp->name, exp->namespace); basename, exp->name, exp->namespace);
add_namespace(&mod->missing_namespaces, exp->namespace); add_namespace(&mod->missing_namespaces, exp->namespace);
......
...@@ -182,13 +182,8 @@ char *read_text_file(const char *filename); ...@@ -182,13 +182,8 @@ char *read_text_file(const char *filename);
char *get_line(char **stringp); char *get_line(char **stringp);
void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym); void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym);
enum loglevel {
LOG_WARN,
LOG_ERROR,
};
void __attribute__((format(printf, 2, 3))) void __attribute__((format(printf, 2, 3)))
modpost_log(enum loglevel loglevel, const char *fmt, ...); modpost_log(bool is_error, const char *fmt, ...);
/* /*
* warn - show the given message, then let modpost continue running, still * warn - show the given message, then let modpost continue running, still
...@@ -203,6 +198,6 @@ modpost_log(enum loglevel loglevel, const char *fmt, ...); ...@@ -203,6 +198,6 @@ modpost_log(enum loglevel loglevel, const char *fmt, ...);
* fatal - show the given message, and bail out immediately. This should be * fatal - show the given message, and bail out immediately. This should be
* used when there is no point to continue running modpost. * used when there is no point to continue running modpost.
*/ */
#define warn(fmt, args...) modpost_log(LOG_WARN, fmt, ##args) #define warn(fmt, args...) modpost_log(false, fmt, ##args)
#define error(fmt, args...) modpost_log(LOG_ERROR, fmt, ##args) #define error(fmt, args...) modpost_log(true, fmt, ##args)
#define fatal(fmt, args...) do { error(fmt, ##args); exit(1); } while (1) #define fatal(fmt, args...) do { error(fmt, ##args); exit(1); } while (1)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment