diff options
author | Masahiro Yamada <masahiroy@kernel.org> | 2020-12-01 13:34:14 +0300 |
---|---|---|
committer | Masahiro Yamada <masahiroy@kernel.org> | 2020-12-21 07:57:08 +0300 |
commit | bc72d723ec6b75c53e935e819682c3e67b83e9c1 (patch) | |
tree | 5f921ed293ba8c89cbc68ed3c8e1132c836ce882 /scripts/mod/modpost.h | |
parent | 436e980e2ed526832de822cbf13c317a458b78e1 (diff) | |
download | linux-bc72d723ec6b75c53e935e819682c3e67b83e9c1.tar.xz |
modpost: rename merror() to error()
The log function names, warn(), merror(), fatal() are inconsistent.
Commit 2a11665945d5 ("kbuild: distinguish between errors and warnings
in modpost") intentionally chose merror() to avoid the conflict with
the library function error(). See man page of error(3).
But, we are already causing the conflict with warn() because it is also
a library function. See man page of warn(3). err() would be a problem
for the same reason.
The common technique to work around name conflicts is to use macros.
For example:
/* in a header */
#define error(fmt, ...) __error(fmt, ##__VA_ARGS__)
#define warn(fmt, ...) __warn(fmt, ##__VA_ARGS__)
/* function definition */
void __error(const char *fmt, ...)
{
<our implementation>
}
void __warn(const char *fmt, ...)
{
<our implementation>
}
In this way, we can implement our own warn() and error(), still we can
include <error.h> and <err.h> with no problem.
And, commit 93c95e526a4e ("modpost: rework and consolidate logging
interface") already did that.
Since the log functions are all macros, we can use error() without
causing "conflicting types" errors.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Diffstat (limited to 'scripts/mod/modpost.h')
-rw-r--r-- | scripts/mod/modpost.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 3aa052722233..f453504ad4df 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -202,5 +202,5 @@ enum loglevel { void modpost_log(enum loglevel loglevel, const char *fmt, ...); #define warn(fmt, args...) modpost_log(LOG_WARN, fmt, ##args) -#define merror(fmt, args...) modpost_log(LOG_ERROR, fmt, ##args) +#define error(fmt, args...) modpost_log(LOG_ERROR, fmt, ##args) #define fatal(fmt, args...) modpost_log(LOG_FATAL, fmt, ##args) |