Skip to content

Commit cda5f94

Browse files
committed
modpost: avoid using the alias attribute
Aiden Leong reported modpost fails to build on macOS since commit 16a473f ("modpost: inform compilers that fatal() never returns"): scripts/mod/modpost.c:93:21: error: aliases are not supported on darwin Nathan's research indicates that Darwin seems to support weak aliases at least [1]. Although the situation might be improved in future Clang versions, we can achieve a similar outcome without relying on it. This commit makes fatal() a macro of error() + exit(1) in modpost.h, as compilers recognize that exit() never returns. [1]: llvm/llvm-project#71001 Fixes: 16a473f ("modpost: inform compilers that fatal() never returns") Reported-by: Aiden Leong <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 8987617 commit cda5f94

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

scripts/mod/modpost.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ void modpost_log(enum loglevel loglevel, const char *fmt, ...)
7070
break;
7171
case LOG_ERROR:
7272
fprintf(stderr, "ERROR: ");
73-
break;
74-
case LOG_FATAL:
75-
fprintf(stderr, "FATAL: ");
73+
error_occurred = true;
7674
break;
7775
default: /* invalid loglevel, ignore */
7876
break;
@@ -83,16 +81,8 @@ void modpost_log(enum loglevel loglevel, const char *fmt, ...)
8381
va_start(arglist, fmt);
8482
vfprintf(stderr, fmt, arglist);
8583
va_end(arglist);
86-
87-
if (loglevel == LOG_FATAL)
88-
exit(1);
89-
if (loglevel == LOG_ERROR)
90-
error_occurred = true;
9184
}
9285

93-
void __attribute__((alias("modpost_log")))
94-
modpost_log_noret(enum loglevel loglevel, const char *fmt, ...);
95-
9686
static inline bool strends(const char *str, const char *postfix)
9787
{
9888
if (strlen(str) < strlen(postfix))

scripts/mod/modpost.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,11 @@ void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym);
194194
enum loglevel {
195195
LOG_WARN,
196196
LOG_ERROR,
197-
LOG_FATAL
198197
};
199198

200199
void __attribute__((format(printf, 2, 3)))
201200
modpost_log(enum loglevel loglevel, const char *fmt, ...);
202201

203-
void __attribute__((format(printf, 2, 3), noreturn))
204-
modpost_log_noret(enum loglevel loglevel, const char *fmt, ...);
205-
206202
/*
207203
* warn - show the given message, then let modpost continue running, still
208204
* allowing modpost to exit successfully. This should be used when
@@ -218,4 +214,4 @@ modpost_log_noret(enum loglevel loglevel, const char *fmt, ...);
218214
*/
219215
#define warn(fmt, args...) modpost_log(LOG_WARN, fmt, ##args)
220216
#define error(fmt, args...) modpost_log(LOG_ERROR, fmt, ##args)
221-
#define fatal(fmt, args...) modpost_log_noret(LOG_FATAL, fmt, ##args)
217+
#define fatal(fmt, args...) do { error(fmt, ##args); exit(1); } while (1)

0 commit comments

Comments
 (0)