linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>
Cc: Quentin Perret <qperret@google.com>,
	Michal Marek <michal.lkml@markovi.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/5] modpost: rename merror() to error()
Date: Wed, 16 Dec 2020 15:27:13 +0900	[thread overview]
Message-ID: <CAK7LNAQQwFY75fqfzU4EFJLbTP1KUmAAnL8iJfSMwV7pjhvF+A@mail.gmail.com> (raw)
In-Reply-To: <20201201103418.675850-1-masahiroy@kernel.org>

On Tue, Dec 1, 2020 at 7:34 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> 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.
>
>     #define error __error
>     void __error(const char *fmt, ...)
>     {
>             <our own implementation>
>     }
>
>     #define warn __warn
>     void __warn(const char *fmt, ...)
>     {
>             <our own 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>

This series, applied to linux-kbuild.


> ---
>
>  scripts/mod/modpost.c | 10 +++++-----
>  scripts/mod/modpost.h |  2 +-
>  2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index f882ce0d9327..337f6ca4bda3 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -403,8 +403,8 @@ static void sym_update_namespace(const char *symname, const char *namespace)
>          * actually an assertion.
>          */
>         if (!s) {
> -               merror("Could not update namespace(%s) for symbol %s\n",
> -                      namespace, symname);
> +               error("Could not update namespace(%s) for symbol %s\n",
> +                     namespace, symname);
>                 return;
>         }
>
> @@ -2226,7 +2226,7 @@ static int check_modname_len(struct module *mod)
>         else
>                 mod_name++;
>         if (strlen(mod_name) >= MODULE_NAME_LEN) {
> -               merror("module name is too long [%s.ko]\n", mod->name);
> +               error("module name is too long [%s.ko]\n", mod->name);
>                 return 1;
>         }
>
> @@ -2319,8 +2319,8 @@ static int add_versions(struct buffer *b, struct module *mod)
>                         continue;
>                 }
>                 if (strlen(s->name) >= MODULE_NAME_LEN) {
> -                       merror("too long symbol \"%s\" [%s.ko]\n",
> -                              s->name, mod->name);
> +                       error("too long symbol \"%s\" [%s.ko]\n",
> +                             s->name, mod->name);
>                         err = 1;
>                         break;
>                 }
> 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)
> --
> 2.27.0
>


-- 
Best Regards
Masahiro Yamada

      parent reply	other threads:[~2020-12-16  6:29 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
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 ` Masahiro Yamada [this message]

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=CAK7LNAQQwFY75fqfzU4EFJLbTP1KUmAAnL8iJfSMwV7pjhvF+A@mail.gmail.com \
    --to=masahiroy@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=qperret@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).