[PATCH] scsi: qedf: Use designated initializer for struct qed_fcoe_cb_ops

From: Kees Cook
Date: Fri May 02 2025 - 18:42:10 EST


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")
Signed-off-by: Kees Cook <kees@xxxxxxxxxx>
---
Cc: Saurav Kashyap <skashyap@xxxxxxxxxxx>
Cc: Javed Hasan <jhasan@xxxxxxxxxxx>
Cc: <GR-QLogic-Storage-Upstream@xxxxxxxxxxx>
Cc: "James E.J. Bottomley" <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx>
Cc: "Martin K. Petersen" <martin.petersen@xxxxxxxxxx>
Cc: <linux-scsi@xxxxxxxxxxxxxxx>
---
drivers/scsi/qedf/qedf_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 436bd29d5eba..6b1ebab36fa3 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -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,
--
2.34.1