Skip to content

Commit 3f49edf

Browse files
GustavoARSilvakuba-moo
authored andcommitted
net/fungible: Avoid -Wflex-array-member-not-at-end warning
Use the `DEFINE_RAW_FLEX()` helper for an on-stack definition of a flexible structure where the size of the flexible-array member is known at compile-time, and refactor the rest of the code, accordingly. So, with these changes, fix the following warning: drivers/net/ethernet/fungible/funcore/fun_dev.c:550:43: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] Signed-off-by: Gustavo A. R. Silva <[email protected]> Link: https://patch.msgid.link/ZrDwEugW7DR/FlP5@cute Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e66f33b commit 3f49edf

File tree

1 file changed

+7
-10
lines changed
  • drivers/net/ethernet/fungible/funcore

1 file changed

+7
-10
lines changed

drivers/net/ethernet/fungible/funcore/fun_dev.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -546,17 +546,14 @@ int fun_bind(struct fun_dev *fdev, enum fun_admin_bind_type type0,
546546
unsigned int id0, enum fun_admin_bind_type type1,
547547
unsigned int id1)
548548
{
549-
struct {
550-
struct fun_admin_bind_req req;
551-
struct fun_admin_bind_entry entry[2];
552-
} cmd = {
553-
.req.common = FUN_ADMIN_REQ_COMMON_INIT2(FUN_ADMIN_OP_BIND,
554-
sizeof(cmd)),
555-
.entry[0] = FUN_ADMIN_BIND_ENTRY_INIT(type0, id0),
556-
.entry[1] = FUN_ADMIN_BIND_ENTRY_INIT(type1, id1),
557-
};
549+
DEFINE_RAW_FLEX(struct fun_admin_bind_req, cmd, entry, 2);
550+
551+
cmd->common = FUN_ADMIN_REQ_COMMON_INIT2(FUN_ADMIN_OP_BIND,
552+
__struct_size(cmd));
553+
cmd->entry[0] = FUN_ADMIN_BIND_ENTRY_INIT(type0, id0);
554+
cmd->entry[1] = FUN_ADMIN_BIND_ENTRY_INIT(type1, id1);
558555

559-
return fun_submit_admin_sync_cmd(fdev, &cmd.req.common, NULL, 0, 0);
556+
return fun_submit_admin_sync_cmd(fdev, &cmd->common, NULL, 0, 0);
560557
}
561558
EXPORT_SYMBOL_GPL(fun_bind);
562559

0 commit comments

Comments
 (0)