Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wimax: fix duplicate initializer warning

gcc -Wextra points out multiple fields that use the same index '1'
in the wimax_gnl_policy definition:

net/wimax/stack.c:393:29: warning: initialized field overwritten [-Woverride-init]
net/wimax/stack.c:397:28: warning: initialized field overwritten [-Woverride-init]
net/wimax/stack.c:398:26: warning: initialized field overwritten [-Woverride-init]

This seems to work since all four use the same NLA_U32 value, but it
still appears to be wrong. In addition, there is no intializer for
WIMAX_GNL_MSG_PIPE_NAME, which uses the same index '2' as
WIMAX_GNL_RFKILL_STATE.

Johannes already changed this twice to improve it, but I don't think
there is a good solution, so try to work around it by using a
numeric index and adding comments.

Fixes: 3b0f31f2b8c9 ("genetlink: make policy common to family")
Fixes: b61a5eea5904 ("wimax: use genl_register_family_with_ops()")
Acked-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+17 -10
+17 -10
net/wimax/stack.c
··· 388 388 } 389 389 EXPORT_SYMBOL_GPL(wimax_dev_init); 390 390 391 + /* 392 + * There are multiple enums reusing the same values, adding 393 + * others is only possible if they use a compatible policy. 394 + */ 391 395 static const struct nla_policy wimax_gnl_policy[WIMAX_GNL_ATTR_MAX + 1] = { 392 - [WIMAX_GNL_RESET_IFIDX] = { .type = NLA_U32, }, 393 - [WIMAX_GNL_RFKILL_IFIDX] = { .type = NLA_U32, }, 394 - [WIMAX_GNL_RFKILL_STATE] = { 395 - .type = NLA_U32 /* enum wimax_rf_state */ 396 - }, 397 - [WIMAX_GNL_STGET_IFIDX] = { .type = NLA_U32, }, 398 - [WIMAX_GNL_MSG_IFIDX] = { .type = NLA_U32, }, 399 - [WIMAX_GNL_MSG_DATA] = { 400 - .type = NLA_UNSPEC, /* libnl doesn't grok BINARY yet */ 401 - }, 396 + /* 397 + * WIMAX_GNL_RESET_IFIDX, WIMAX_GNL_RFKILL_IFIDX, 398 + * WIMAX_GNL_STGET_IFIDX, WIMAX_GNL_MSG_IFIDX 399 + */ 400 + [1] = { .type = NLA_U32, }, 401 + /* 402 + * WIMAX_GNL_RFKILL_STATE, WIMAX_GNL_MSG_PIPE_NAME 403 + */ 404 + [2] = { .type = NLA_U32, }, /* enum wimax_rf_state */ 405 + /* 406 + * WIMAX_GNL_MSG_DATA 407 + */ 408 + [3] = { .type = NLA_UNSPEC, }, /* libnl doesn't grok BINARY yet */ 402 409 }; 403 410 404 411 static const struct genl_small_ops wimax_gnl_ops[] = {