]> git.baikalelectronics.ru Git - kernel.git/commit
modpost: rename merror() to error()
authorMasahiro Yamada <masahiroy@kernel.org>
Tue, 1 Dec 2020 10:34:14 +0000 (19:34 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Mon, 21 Dec 2020 04:57:08 +0000 (13:57 +0900)
commit94a03bf2ebf8ad0d65a978814df85486a3fe15b2
tree5f921ed293ba8c89cbc68ed3c8e1132c836ce882
parent93fb5bf8f1390a0dee689d8c1a1d5b4b7ce40a53
modpost: rename merror() to error()

The log function names, warn(), merror(), fatal() are inconsistent.

Commit 7f9ffc55648a ("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 28f8be4ed7cc ("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>
scripts/mod/modpost.c
scripts/mod/modpost.h