Clang 18.1.3-2.fc41 throws a warning:
lib/tc.c:3060:25: error: field 'sel' with variable sized type
'struct tc_pedit_sel' not at the end of a struct or class is a
GNU extension [-Werror,-Wgnu-variable-sized-type-not-at-end]
3060 | struct tc_pedit sel;
| ^
Refactor the structure into a proper union to avoid the build failure.
Interestingly, clang 18.1.3-2.fc41 on Fedora throws a warning, but
relatively the same version 18.1.3 (1) on Ubuntu 23.04 does not.
Signed-off-by: Ilya Maximets <[email protected]>
---
lib/tc.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/lib/tc.c b/lib/tc.c
index e9bcae4e4..e55ba3b1b 100644
--- a/lib/tc.c
+++ b/lib/tc.c
@@ -3056,17 +3056,17 @@ nl_msg_put_flower_rewrite_pedits(struct ofpbuf *request,
struct tc_action *action,
uint32_t action_pc)
{
- struct {
+ union {
struct tc_pedit sel;
- struct tc_pedit_key keys[MAX_PEDIT_OFFSETS];
- struct tc_pedit_key_ex keys_ex[MAX_PEDIT_OFFSETS];
- } sel = {
- .sel = {
- .nkeys = 0
- }
- };
+ uint8_t buffer[sizeof(struct tc_pedit)
+ + MAX_PEDIT_OFFSETS * sizeof(struct tc_pedit_key)];
+ } sel;
+ struct tc_pedit_key_ex keys_ex[MAX_PEDIT_OFFSETS];
int i, j, err;
+ memset(&sel, 0, sizeof sel);
+ memset(keys_ex, 0, sizeof keys_ex);
+
for (i = 0; i < ARRAY_SIZE(flower_pedit_map); i++) {
struct flower_key_to_pedit *m = &flower_pedit_map[i];
struct tc_pedit_key *pedit_key = NULL;
@@ -3100,8 +3100,8 @@ nl_msg_put_flower_rewrite_pedits(struct ofpbuf *request,
return EOPNOTSUPP;
}
- pedit_key = &sel.keys[sel.sel.nkeys];
- pedit_key_ex = &sel.keys_ex[sel.sel.nkeys];
+ pedit_key = &sel.sel.keys[sel.sel.nkeys];
+ pedit_key_ex = &keys_ex[sel.sel.nkeys];
pedit_key_ex->cmd = TCA_PEDIT_KEY_EX_CMD_SET;
pedit_key_ex->htype = m->htype;
pedit_key->off = cur_offset;
@@ -3121,7 +3121,7 @@ nl_msg_put_flower_rewrite_pedits(struct ofpbuf *request,
}
}
}
- nl_msg_put_act_pedit(request, &sel.sel, sel.keys_ex,
+ nl_msg_put_act_pedit(request, &sel.sel, keys_ex,
flower->csum_update_flags ? TC_ACT_PIPE : action_pc);
return 0;
--
2.44.0
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev