Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

modpost: simplify modpost_log()

With commit cda5f94e88b4 ("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: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>

+9 -19
+6 -11
scripts/mod/modpost.c
··· 67 67 68 68 #define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) 69 69 70 - void modpost_log(enum loglevel loglevel, const char *fmt, ...) 70 + void modpost_log(bool is_error, const char *fmt, ...) 71 71 { 72 72 va_list arglist; 73 73 74 - switch (loglevel) { 75 - case LOG_WARN: 76 - fprintf(stderr, "WARNING: "); 77 - break; 78 - case LOG_ERROR: 74 + if (is_error) { 79 75 fprintf(stderr, "ERROR: "); 80 76 error_occurred = true; 81 - break; 82 - default: /* invalid loglevel, ignore */ 83 - break; 77 + } else { 78 + fprintf(stderr, "WARNING: "); 84 79 } 85 80 86 81 fprintf(stderr, "modpost: "); ··· 1684 1689 exp = find_symbol(s->name); 1685 1690 if (!exp) { 1686 1691 if (!s->weak && nr_unresolved++ < MAX_UNRESOLVED_REPORTS) 1687 - modpost_log(warn_unresolved ? LOG_WARN : LOG_ERROR, 1692 + modpost_log(!warn_unresolved, 1688 1693 "\"%s\" [%s.ko] undefined!\n", 1689 1694 s->name, mod->name); 1690 1695 continue; ··· 1707 1712 basename = mod->name; 1708 1713 1709 1714 if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) { 1710 - modpost_log(allow_missing_ns_imports ? LOG_WARN : LOG_ERROR, 1715 + modpost_log(!allow_missing_ns_imports, 1711 1716 "module %s uses symbol %s from namespace %s, but does not import it.\n", 1712 1717 basename, exp->name, exp->namespace); 1713 1718 add_namespace(&mod->missing_namespaces, exp->namespace);
+3 -8
scripts/mod/modpost.h
··· 182 182 char *get_line(char **stringp); 183 183 void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym); 184 184 185 - enum loglevel { 186 - LOG_WARN, 187 - LOG_ERROR, 188 - }; 189 - 190 185 void __attribute__((format(printf, 2, 3))) 191 - modpost_log(enum loglevel loglevel, const char *fmt, ...); 186 + modpost_log(bool is_error, const char *fmt, ...); 192 187 193 188 /* 194 189 * warn - show the given message, then let modpost continue running, still ··· 198 203 * fatal - show the given message, and bail out immediately. This should be 199 204 * used when there is no point to continue running modpost. 200 205 */ 201 - #define warn(fmt, args...) modpost_log(LOG_WARN, fmt, ##args) 202 - #define error(fmt, args...) modpost_log(LOG_ERROR, fmt, ##args) 206 + #define warn(fmt, args...) modpost_log(false, fmt, ##args) 207 + #define error(fmt, args...) modpost_log(true, fmt, ##args) 203 208 #define fatal(fmt, args...) do { error(fmt, ##args); exit(1); } while (1)