From: Quentin Perret <qperret@google.com>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org,
Michal Marek <michal.lkml@markovi.net>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] modpost: refactor error handling and clarify error/fatal difference
Date: Tue, 1 Dec 2020 16:47:12 +0000 [thread overview]
Message-ID: <20201201164712.GA1949321@google.com> (raw)
In-Reply-To: <20201201103418.675850-2-masahiroy@kernel.org>
On Tuesday 01 Dec 2020 at 19:34:15 (+0900), Masahiro Yamada wrote:
> 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:").
>
> The intended usage of error() is probably to propagate the return code
> from the function to the exit code of modpost, as check_exports() etc.
> already does. This is a good manner because we should display as many
> issues 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()."
Indeed :-)
> One of the reasons is probably it is tedious to manually carry the error
> code back to the main() function.
And yes, that was the reason.
> 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().
>
> Again, 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>
I gave it a go and the error is propagated correctly, so FWIW:
Tested-by: Quentin Perret <qperret@google.com>
Thanks,
Quentin
next prev parent reply other threads:[~2020-12-01 16:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-01 10:34 [PATCH 1/5] modpost: rename merror() to error() Masahiro Yamada
2020-12-01 10:34 ` [PATCH 2/5] modpost: refactor error handling and clarify error/fatal difference Masahiro Yamada
2020-12-01 16:47 ` Quentin Perret [this message]
2020-12-01 10:34 ` [PATCH 3/5] modpost: turn missing MODULE_LICENSE() into error Masahiro Yamada
2020-12-01 10:34 ` [PATCH 4/5] modpost: change license incompatibility to error() from fatal() Masahiro Yamada
2020-12-01 10:34 ` [PATCH 5/5] modpost: turn section mismatches to error " Masahiro Yamada
2020-12-16 6:27 ` [PATCH 1/5] modpost: rename merror() to error() Masahiro Yamada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201201164712.GA1949321@google.com \
--to=qperret@google.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=michal.lkml@markovi.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox