All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Liya Huang <1425075683@qq.com>, Rob Herring <robh@kernel.org>,
	Saravana Kannan <saravanak@google.com>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] of: Build warn for missing fn() in _OF_DECLARE
Date: Wed, 23 Apr 2025 13:18:34 +0100	[thread overview]
Message-ID: <a4277fb4-c982-43c7-9f02-e0050eff417a@arm.com> (raw)
In-Reply-To: <tencent_BA80A2305727877DEE7BE20655D9CA825B09@qq.com>

On 2025-04-17 2:23 pm, Liya Huang wrote:
> The function pointer fn() in _OF_DECLARE macro might be NULL. For example,
> in __reserved_mem_init_node(), only non-NULL cases are handled, and NULL
> function pointers are ignored.
> 
> This patch introduces a check to handle cases where fn() is NULL. If fn()
> is found to be NULL, a warning is issued during compilation to notify
> developers about the missing function pointer.
> 
> ---
> The function pointer fn() in _OF_DECLARE macro might be NULL. For example,
> in __reserved_mem_init_node(), only non-NULL cases are handled, and NULL
> function pointers are ignored.
> 
> This patch introduces a check to handle cases where fn() is NULL. If fn()
> is found to be NULL, a warning is issued during compilation to notify
> developers about the missing function pointer.

This patch in -next appears to be responsible for syzbot complaining 
about build errors for some configs:

"
kernel/dma/coherent.c:410:1: error: static assertion expression is not 
an integral constant expression
kernel/dma/contiguous.c:497:1: error: static assertion expression is not 
an integral constant expression
"

https://lore.kernel.org/linux-iommu/6808d00a.050a0220.7184a.0010.GAE@google.com/

Also on closer inspection, just outside the diff context we still seem 
to be explicitly anticipating fn being NULL with:

	.data = (fn == (fn_type)NULL) ? fn : fn

so something doesn't seem quite right...

Thanks,
Robin.

> Link: https://lore.kernel.org/all/CAL_JsqK733Q9bbxC0Wz5uxyZ9m7bs+bci5kUJF9GJMv73-dO4w@mail.gmail.com/
> 
> Signed-off-by: Liya Huang <1425075683@qq.com>
> ---
>   include/linux/of.h | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/include/linux/of.h b/include/linux/of.h
> index a62154aeda1b6a600c2b155ac486c0e0b56e0bf2..99d1d553e65b7970a3ecb5158774ca5185f297a0 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -1523,6 +1523,7 @@ static inline int of_get_available_child_count(const struct device_node *np)
>   }
>   
>   #define _OF_DECLARE_STUB(table, name, compat, fn, fn_type)		\
> +	static_assert((fn) != NULL);	\
>   	static const struct of_device_id __of_table_##name		\
>   		__attribute__((unused))					\
>   		 = { .compatible = compat,				\
> @@ -1530,6 +1531,7 @@ static inline int of_get_available_child_count(const struct device_node *np)
>   
>   #if defined(CONFIG_OF) && !defined(MODULE)
>   #define _OF_DECLARE(table, name, compat, fn, fn_type)			\
> +	static_assert((fn) != NULL);	\
>   	static const struct of_device_id __of_table_##name		\
>   		__used __section("__" #table "_of_table")		\
>   		__aligned(__alignof__(struct of_device_id))		\
> 
> ---
> base-commit: 8ffd015db85fea3e15a77027fda6c02ced4d2444
> change-id: 20250417-_of_declare-ac80b59d952d
> 
> Best regards,


  parent reply	other threads:[~2025-04-23 12:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-17 13:23 [PATCH] of: Build warn for missing fn() in _OF_DECLARE Liya Huang
2025-04-22 12:48 ` Rob Herring (Arm)
2025-04-23 12:18 ` Robin Murphy [this message]
2025-04-23 14:48   ` 1425075683
2025-04-23 22:10   ` Rob Herring

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=a4277fb4-c982-43c7-9f02-e0050eff417a@arm.com \
    --to=robin.murphy@arm.com \
    --cc=1425075683@qq.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=saravanak@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.