Skip to content

Commit 16a473f

Browse files
committed
modpost: inform compilers that fatal() never returns
The function fatal() never returns because modpost_log() calls exit(1) when LOG_FATAL is passed. Inform compilers of this fact so that unreachable code flow can be identified at compile time. Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]>
1 parent cc87b7c commit 16a473f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

scripts/mod/modpost.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ void modpost_log(enum loglevel loglevel, const char *fmt, ...)
9090
error_occurred = true;
9191
}
9292

93+
void __attribute__((alias("modpost_log")))
94+
modpost_log_noret(enum loglevel loglevel, const char *fmt, ...);
95+
9396
static inline bool strends(const char *str, const char *postfix)
9497
{
9598
if (strlen(str) < strlen(postfix))

scripts/mod/modpost.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ enum loglevel {
200200
void __attribute__((format(printf, 2, 3)))
201201
modpost_log(enum loglevel loglevel, const char *fmt, ...);
202202

203+
void __attribute__((format(printf, 2, 3), noreturn))
204+
modpost_log_noret(enum loglevel loglevel, const char *fmt, ...);
205+
203206
/*
204207
* warn - show the given message, then let modpost continue running, still
205208
* allowing modpost to exit successfully. This should be used when
@@ -215,4 +218,4 @@ modpost_log(enum loglevel loglevel, const char *fmt, ...);
215218
*/
216219
#define warn(fmt, args...) modpost_log(LOG_WARN, fmt, ##args)
217220
#define error(fmt, args...) modpost_log(LOG_ERROR, fmt, ##args)
218-
#define fatal(fmt, args...) modpost_log(LOG_FATAL, fmt, ##args)
221+
#define fatal(fmt, args...) modpost_log_noret(LOG_FATAL, fmt, ##args)

0 commit comments

Comments
 (0)