mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-22 06:32:08 +00:00
modpost: refactor error handling and clarify error/fatal difference
We have 3 log functions. fatal() is special because it lets modpost bail out immediately. The difference between warn() and error() is the only prefix parts ("WARNING:" vs "ERROR:"). In my understanding, the expected handling of error() is to propagate the return code of the function to the exit code of modpost, as check_exports() etc. already does. This is a good manner in general because we should display as many error messages as possible in a single run of modpost. What is annoying about fatal() is that it kills modpost at the first error. People would need to run Kbuild again and again until they fix all errors. But, unfortunately, people tend to do: "This case should not be allowed. Let's replace warn() with fatal()." One of the reasons is probably it is tedious to manually hoist the error code to the main() function. This commit refactors error() so any single call for it automatically makes modpost return the error code. I also added comments in modpost.h for warn(), error(), and fatal(). Please use fatal() only when you have a strong reason to do so. For example: - Memory shortage (i.e. malloc() etc. has failed) - The ELF file is broken, and there is no point to continue parsing - Something really odd has happened For general coding errors, please use error(). Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Tested-by: Quentin Perret <qperret@google.com>
This commit is contained in:
parent
bc72d723ec
commit
0fd3fbadd9
2 changed files with 27 additions and 29 deletions
|
@ -201,6 +201,19 @@ enum loglevel {
|
|||
|
||||
void modpost_log(enum loglevel loglevel, const char *fmt, ...);
|
||||
|
||||
/*
|
||||
* warn - show the given message, then let modpost continue running, still
|
||||
* allowing modpost to exit successfully. This should be used when
|
||||
* we still allow to generate vmlinux and modules.
|
||||
*
|
||||
* error - show the given message, then let modpost continue running, but fail
|
||||
* in the end. This should be used when we should stop building vmlinux
|
||||
* or modules, but we can continue running modpost to catch as many
|
||||
* issues as possible.
|
||||
*
|
||||
* fatal - show the given message, and bail out immediately. This should be
|
||||
* used when there is no point to continue running modpost.
|
||||
*/
|
||||
#define warn(fmt, args...) modpost_log(LOG_WARN, fmt, ##args)
|
||||
#define error(fmt, args...) modpost_log(LOG_ERROR, fmt, ##args)
|
||||
#define fatal(fmt, args...) modpost_log(LOG_FATAL, fmt, ##args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue