lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 8 May 2021 11:59:43 +1000
From:   Stephen Rothwell <sfr@...b.auug.org.au>
To:     Masahiro Yamada <masahiroy@...nel.org>
Cc:     linux-kbuild@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Arnd Bergmann <arnd@...db.de>,
        "Guilherme G. Piccoli" <gpiccoli@...onical.com>,
        Kars Mulder <kerneldev@...smulder.nl>,
        Kees Cook <keescook@...omium.org>,
        Kishon Vijay Abraham I <kishon@...com>,
        Linus Walleij <linus.walleij@...aro.org>,
        Paul Cercueil <paul@...pouillou.net>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>, chao <chao@...o.com>,
        linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-mips@...r.kernel.org
Subject: Re: [PATCH v2] linux/kconfig.h: replace IF_ENABLED() with PTR_IF()
 in <linux/kernel.h>

Hi Masahiro,

On Thu,  6 May 2021 02:45:15 +0900 Masahiro Yamada <masahiroy@...nel.org> wrote:
>
> <linux/kconfig.h> is included from all the kernel-space source files,
> including C, assembly, linker scripts. It is intended to contain a
> minimal set of macros to evaluate CONFIG options.
> 
> IF_ENABLED() is an intruder here because (x ? y : z) is C code, which
> should not be included from assembly files or linker scripts.

Except it doesn't matter unless IF_ENABLED() is used by one of those.

> Also, <linux/kconfig.h> is no longer self-contained because NULL is
> defined in <linux/stddef.h>.

Again, it doesn't matter unless IF_ENABLED() is used.

> Move IF_ENABLED() out to <linux/kernel.h> as PTR_IF(). PTF_IF()
> takes the general boolean expression instead of a CONFIG option
> so that it fits better in <linux/kernel.h>.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>
> ---
> 
> Changes in v2:
>   - Keep PTF_IF macro in pinctrl-ingenic.c
> 
>  drivers/pinctrl/pinctrl-ingenic.c | 2 ++
>  include/linux/kconfig.h           | 6 ------
>  include/linux/kernel.h            | 2 ++
>  3 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
> index 651a36b9dcc0..0ee69f8e20b2 100644
> --- a/drivers/pinctrl/pinctrl-ingenic.c
> +++ b/drivers/pinctrl/pinctrl-ingenic.c
> @@ -3854,6 +3854,8 @@ static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +#define IF_ENABLED(cfg, ptr)	PTR_IF(IS_ENABLED(cfg), (ptr))
> +
>  static const struct of_device_id ingenic_pinctrl_of_match[] = {
>  	{
>  		.compatible = "ingenic,jz4730-pinctrl",

You also need to include linux/kernel.h in
drivers/pinctrl/pinctrl-ingenic.c (for completeness).

Also, I don't understand why the use of IF_ENABLED doesn't produce
"defined but not used" warnings (if the function "ptr" is not marked as
__maybe_unused) ...

Also, if there is only one user of IF_ENABLED (and therefore PTR_IF),
why not just put it in that file and save me rebuilding the world again
every day because kernel.h is changed (again).  I guess that is going
to happen just because kconfig.h is being changed and that is also
included by everything :-(

Also, is anyone else ever going to use PTR_IF() without having to also
use IS_ENABLED()?

So, in case it is not obvious, I consider this patch unnecessary churn
(as was probably the patch that introduced IF_ENABLED in the first
place).

As an aside, this should not have been added to the kbuild tree in
linux-next until after -rc1 was released ...

-- 
Cheers,
Stephen Rothwell

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ