Skip to contentSkip to conversation

scsi: qedf: Use designated initializer for struct qed_fcoe_cb_ops

PATCH Applied Kees Cook 3 participants 3 messages May 2, 2025 – May 7, 2025

Subsystems (2)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 scsi: qedf: Use designated initializer for struct qed_fcoe_cb_ops

Recent fixes to the randstruct GCC plugin allowed it to notice that this structure is entirely function pointers and is therefore subject to randomization, but doing so requires that it always use designated initializers. Explicitly specify the "common" member as being initialized. Silences:

drivers/scsi/qedf/qedf_main.c:702:9: error: positional initialization of field in 'struct' declared with 'designated_init' attribute [-Werror=designated-init]

  702 |         {
      |         ^
Fixes c2ea09b193d2 ("randstruct: gcc-plugin: Remove bogus void member")

---
Cc: Saurav Kashyap <[email protected]>
Cc: Javed Hasan <[email protected]>
Cc: <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: <[email protected]>

---
 drivers/scsi/qedf/qedf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qedf/qedf_main.c +1 -1
index 436bd29d5eba..6b1ebab36fa3 100644
@@ -699,7 +699,7 @@ static u32 qedf_get_login_failures(void *cookie)
 }
 
 static struct qed_fcoe_cb_ops qedf_cb_ops = {
-	{
+	.common = {
 		.link_update = qedf_link_update,
 		.bw_update = qedf_bw_update,
 		.schedule_recovery_handler = qedf_schedule_recovery_handler,
Signature · 1 line
2.34.1
#1 lore raw

Kees,

Quoted 5 lines

Recent fixes to the randstruct GCC plugin allowed it to notice that this structure is entirely function pointers and is therefore subject to randomization, but doing so requires that it always use designated initializers. Explicitly specify the "common" member as being initialized.

Applied to 6.16/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen
#2 lore raw
In reply to Kees Cook
Quoted 11 lines · Kees Cook

Recent fixes to the randstruct GCC plugin allowed it to notice that this structure is entirely function pointers and is therefore subject to randomization, but doing so requires that it always use designated initializers. Explicitly specify the "common" member as being initialized. Silences:

drivers/scsi/qedf/qedf_main.c:702:9: error: positional initialization of field in 'struct' declared with 'designated_init' attribute [-Werror=designated-init]

  702 |         {
      |         ^
Fixes c2ea09b193d2 ("randstruct: gcc-plugin: Remove bogus void member")

For the record, this is also needed after your recent change to clang to do the same thing as the plugin:

drivers/scsi/qedf/qedf_main.c:702:2: error: a randomized struct can only be initialized with a designated initializer

  702 |         {
      |         ^

so this should probably have

Fixes 035f7f87b729 ("randstruct: Enable Clang support")
Quoted 28 lines

---
Cc: Saurav Kashyap <[email protected]>
Cc: Javed Hasan <[email protected]>
Cc: <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: <[email protected]>

---
 drivers/scsi/qedf/qedf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qedf/qedf_main.c +1 -1
index 436bd29d5eba..6b1ebab36fa3 100644
@@ -699,7 +699,7 @@ static u32 qedf_get_login_failures(void *cookie)
 }
 
 static struct qed_fcoe_cb_ops qedf_cb_ops = {
-	{
+	.common = {
 		.link_update = qedf_link_update,
 		.bw_update = qedf_bw_update,
 		.schedule_recovery_handler = qedf_schedule_recovery_handler,
Signature · 1 line
2.34.1