Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [PATCH net] net: qede: Initialize qede_ll_ops with designated initializer
@ 2025-05-07 20:47 Nathan Chancellor
  2025-05-08  0:58 ` Kees Cook
  2025-05-09  2:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2025-05-07 20:47 UTC (permalink / raw)
  To: Manish Chopra, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Kees Cook
  Cc: Nick Desaulniers, Bill Wendling, Justin Stitt, netdev,
	linux-kernel, llvm, stable, Nathan Chancellor

After a recent change [1] in clang's randstruct implementation to
randomize structures that only contain function pointers, there is an
error because qede_ll_ops get randomized but does not use a designated
initializer for the first member:

  drivers/net/ethernet/qlogic/qede/qede_main.c:206:2: error: a randomized struct can only be initialized with a designated initializer
    206 |         {
        |         ^

Explicitly initialize the common member using a designated initializer
to fix the build.

Cc: stable@vger.kernel.org
Fixes: 035f7f87b729 ("randstruct: Enable Clang support")
Link: https://github.com/llvm/llvm-project/commit/04364fb888eea6db9811510607bed4b200bcb082 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/net/ethernet/qlogic/qede/qede_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c
index 99df00c30b8c..b5d744d2586f 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_main.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
@@ -203,7 +203,7 @@ static struct pci_driver qede_pci_driver = {
 };
 
 static struct qed_eth_cb_ops qede_ll_ops = {
-	{
+	.common = {
 #ifdef CONFIG_RFS_ACCEL
 		.arfs_filter_op = qede_arfs_filter_op,
 #endif

---
base-commit: 9540984da649d46f699c47f28c68bbd3c9d99e4c
change-id: 20250507-qede-fix-clang-randstruct-13d8c593cb58

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: qede: Initialize qede_ll_ops with designated initializer
  2025-05-07 20:47 [PATCH net] net: qede: Initialize qede_ll_ops with designated initializer Nathan Chancellor
@ 2025-05-08  0:58 ` Kees Cook
  2025-05-09  2:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2025-05-08  0:58 UTC (permalink / raw)
  To: Nathan Chancellor, Manish Chopra, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Nick Desaulniers, Bill Wendling, Justin Stitt, netdev,
	linux-kernel, llvm, stable



On May 7, 2025 1:47:45 PM PDT, Nathan Chancellor <nathan@kernel.org> wrote:
>After a recent change [1] in clang's randstruct implementation to
>randomize structures that only contain function pointers, there is an
>error because qede_ll_ops get randomized but does not use a designated
>initializer for the first member:
>
>  drivers/net/ethernet/qlogic/qede/qede_main.c:206:2: error: a randomized struct can only be initialized with a designated initializer
>    206 |         {
>        |         ^
>
>Explicitly initialize the common member using a designated initializer
>to fix the build.
>
>Cc: stable@vger.kernel.org
>Fixes: 035f7f87b729 ("randstruct: Enable Clang support")
>Link: https://github.com/llvm/llvm-project/commit/04364fb888eea6db9811510607bed4b200bcb082 [1]
>Signed-off-by: Nathan Chancellor <nathan@kernel.org>
>---
> drivers/net/ethernet/qlogic/qede/qede_main.c | 2 +-

Oops, I missed this one with its 1-character different filename. 😅

Reviewed-by: Kees Cook <kees@kernel.org>



> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c
>index 99df00c30b8c..b5d744d2586f 100644
>--- a/drivers/net/ethernet/qlogic/qede/qede_main.c
>+++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
>@@ -203,7 +203,7 @@ static struct pci_driver qede_pci_driver = {
> };
> 
> static struct qed_eth_cb_ops qede_ll_ops = {
>-	{
>+	.common = {
> #ifdef CONFIG_RFS_ACCEL
> 		.arfs_filter_op = qede_arfs_filter_op,
> #endif
>
>---
>base-commit: 9540984da649d46f699c47f28c68bbd3c9d99e4c
>change-id: 20250507-qede-fix-clang-randstruct-13d8c593cb58
>
>Best regards,

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: qede: Initialize qede_ll_ops with designated initializer
  2025-05-07 20:47 [PATCH net] net: qede: Initialize qede_ll_ops with designated initializer Nathan Chancellor
  2025-05-08  0:58 ` Kees Cook
@ 2025-05-09  2:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-05-09  2:30 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: manishc, andrew+netdev, davem, edumazet, kuba, pabeni, kees,
	nick.desaulniers+lkml, morbo, justinstitt, netdev, linux-kernel,
	llvm, stable

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 07 May 2025 21:47:45 +0100 you wrote:
> After a recent change [1] in clang's randstruct implementation to
> randomize structures that only contain function pointers, there is an
> error because qede_ll_ops get randomized but does not use a designated
> initializer for the first member:
> 
>   drivers/net/ethernet/qlogic/qede/qede_main.c:206:2: error: a randomized struct can only be initialized with a designated initializer
>     206 |         {
>         |         ^
> 
> [...]

Here is the summary with links:
  - [net] net: qede: Initialize qede_ll_ops with designated initializer
    https://git.kernel.org/netdev/net/c/6b3ab7f2cbfa

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-09  2:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-07 20:47 [PATCH net] net: qede: Initialize qede_ll_ops with designated initializer Nathan Chancellor
2025-05-08  0:58 ` Kees Cook
2025-05-09  2:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox