compiler warnings cleanup, part 1
Subsystems (3)
cover compiler warnings cleanup, part 1
Maciej Żenczykowski recently cleaned up many "unused parameter" compiler warnings but some new occurences appeared since (mostly in netlink code).
This series gets rid of all currently found "unused parameter" warnings and also one zero length array access warning (gcc10). There are still some compiler warnings left (signed/unsigned comparison and missing struct field initializers); these will be handled in next cycle as the fixes are more intrusive.
This series should not affect resulting code; checked by comparing resulting binary against unpatched source.
Michal Kubecek (7):
rename maybe_unused macro to __maybe_unused
cable_test: clean up unused parameters
igc: mark unused callback parameter
netlink: mark unused callback parameter
netlink: mark unused parameters of bitset walker callbacks
netlink: mark unused parameters of parser callbacks
ioctl: avoid zero length array warning in get_stringset()
amd8111e.c | 2 +- at76c50x-usb.c | 2 +- de2104x.c | 4 ++-- dsa.c | 2 +- e100.c | 2 +- e1000.c | 2 +- et131x.c | 2 +- ethtool.c | 10 ++++++---- fec.c | 2 +- fec_8xx.c | 2 +- fjes.c | 2 +- ibm_emac.c | 2 +- igb.c | 2 +- igc.c | 3 ++- internal.h | 2 +- ixgb.c | 2 +- ixgbe.c | 2 +- ixgbevf.c | 2 +- lan78xx.c | 2 +- marvell.c | 4 ++-- natsemi.c | 4 ++-- netlink/cable_test.c | 21 ++++++++------------- netlink/netlink.c | 2 +- netlink/parser.c | 28 ++++++++++++++++------------ netlink/pause.c | 3 ++- netlink/privflags.c | 2 +- netlink/settings.c | 9 ++++++--- netlink/tsinfo.c | 2 +- realtek.c | 2 +- sfc.c | 3 ++- smsc911x.c | 2 +- stmmac.c | 4 ++-- tg3.c | 4 ++-- tse.c | 2 +- vioc.c | 2 +- vmxnet3.c | 2 +- 36 files changed, 76 insertions(+), 69 deletions(-)
Signature · 1 line
2.28.0
PATCH 1/7 rename maybe_unused macro to __maybe_unused
This makes the code consistent with kernel and also makes it a bit more apparent that it is an attribute.
--- amd8111e.c | 2 +- at76c50x-usb.c | 2 +- de2104x.c | 4 ++-- dsa.c | 2 +- e100.c | 2 +- e1000.c | 2 +- et131x.c | 2 +- ethtool.c | 6 +++--- fec.c | 2 +- fec_8xx.c | 2 +- fjes.c | 2 +- ibm_emac.c | 2 +- igb.c | 2 +- internal.h | 2 +- ixgb.c | 2 +- ixgbe.c | 2 +- ixgbevf.c | 2 +- lan78xx.c | 2 +- marvell.c | 4 ++-- natsemi.c | 4 ++-- realtek.c | 2 +- sfc.c | 3 ++- smsc911x.c | 2 +- stmmac.c | 4 ++-- tg3.c | 4 ++-- tse.c | 2 +- vioc.c | 2 +- vmxnet3.c | 2 +- 28 files changed, 36 insertions(+), 35 deletions(-)
amd8111e.c +1 -1
@@ -152,7 +152,7 @@ typedef enum {#define PHY_SPEED_100 0x3 -int amd8111e_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int amd8111e_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {
at76c50x-usb.c +1 -1
@@ -12,7 +12,7 @@ static char *hw_versions[] = { " 505AMX", }; -int at76c50x_usb_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int at76c50x_usb_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {u8 version = (u8)(regs->version >>24 );
de2104x.c +2 -2
@@ -111,7 +111,7 @@ print_rx_missed(u32 csr8) } } -static void de21040_dump_regs(struct ethtool_drvinfo *info maybe_unused, +static void de21040_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {u32 tmp, v, *data = (u32 *)regs->data;
@@ -417,7 +417,7 @@ static void de21040_dump_regs(struct ethtool_drvinfo *info maybe_unused, v & (1<<0) ? " Jabber disable\n" : ""); } -static void de21041_dump_regs(struct ethtool_drvinfo *info maybe_unused, +static void de21041_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {u32 tmp, v, *data = (u32 *)regs->data;
dsa.c +1 -1
@@ -870,7 +870,7 @@ static int dsa_mv88e6xxx_dump_regs(struct ethtool_regs *regs)#undef FIELD#undef REG -int dsa_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int dsa_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {/* DSA per-driver register dump */
e100.c +1 -1
@@ -36,7 +36,7 @@#define CU_CMD 0x00F0#define RU_CMD 0x0007 -int e100_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int e100_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {u32 *regs_buff = (u32 *)regs->data;
e1000.c +1 -1
@@ -363,7 +363,7 @@ static enum e1000_mac_type e1000_get_mac_type(u16 device_id)return mac_type; } -int e1000_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int e1000_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {u32 *regs_buff = (u32 *)regs->data;
et131x.c +1 -1
@@ -2,7 +2,7 @@#include <string.h> #include "internal.h" -int et131x_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int et131x_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {u8 version = (u8)(regs->version >>24 );
ethtool.c +3 -3
@@ -366,7 +366,7 @@ static int rxflow_str_to_type(const char *str)return flow_type; } -static int do_version(struct cmd_context *ctx maybe_unused) +static int do_version (struct cmd_context *ctx__maybe_unused ) {fprintf (stdout, PACKAGE " version " VERSION
@@ -1106,7 +1106,7 @@ nested: }static int dump_eeprom (int geeprom_dump_raw, - struct ethtool_drvinfo *info maybe_unused, +struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_eeprom *ee) {if (geeprom_dump_raw) {
@@ -5708,7 +5708,7 @@ static const struct option args[] = { {} }; -static int show_usage(struct cmd_context *ctx maybe_unused) +static int show_usage (struct cmd_context *ctx__maybe_unused ) {int i;
fec.c +1 -1
@@ -194,7 +194,7 @@ static void fec_dump_reg_v2(int reg, u32 val)#undef FIELD#undef REG -int fec_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int fec_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {const u32 *data = (u32 *)regs->data;
fec_8xx.c +1 -1
@@ -47,7 +47,7 @@ struct fec { (unsigned long)(offsetof(struct fec, x)), \#x , f->x) -int fec_8xx_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int fec_8xx_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {struct fec *f = (struct fec *)regs->data;
fjes.c +1 -1
@@ -2,7 +2,7 @@#include <stdio.h> #include "internal.h" -int fjes_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int fjes_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {u32 *regs_buff = (u32 *)regs->data;
ibm_emac.c +1 -1
@@ -314,7 +314,7 @@ static void *print_tah_regs(void *buf)return p +1 ; } -int ibm_emac_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int ibm_emac_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) { struct emac_ethtool_regs_hdr *hdr =
igb.c +1 -1
@@ -88,7 +88,7 @@#define E1000_TCTL_RTLC 0x01000000/* Re-transmit on late collision */ #define E1000_TCTL_NRTU 0x02000000/* No Re-transmit on underrun */ -int igb_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int igb_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {u32 *regs_buff = (u32 *)regs->data;
internal.h +1 -1
@@ -26,7 +26,7 @@#include "json_writer.h" #include "json_print.h" -#define maybe_unused __attribute__((__unused__)) +#define __maybe_unused __attribute__((__unused__))/* internal for netlink interface */ #ifdef ETHTOOL_ENABLE_NETLINK
ixgb.c +1 -1
@@ -38,7 +38,7 @@#define IXGB_RAH_ASEL_SRC 0x00010000#define IXGB_RAH_AV 0x80000000 -int ixgb_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int ixgb_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {u32 *regs_buff = (u32 *)regs->data;
ixgbe.c +1 -1
@@ -168,7 +168,7 @@ ixgbe_get_mac_type(u16 device_id) }int -ixgbe_dump_regs(struct ethtool_drvinfo *info maybe_unused, +ixgbe_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {u32 *regs_buff = (u32 *)regs->data;
ixgbevf.c +1 -1
@@ -3,7 +3,7 @@#include "internal.h" int -ixgbevf_dump_regs(struct ethtool_drvinfo *info maybe_unused, +ixgbevf_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {u32 *regs_buff = (u32 *)regs->data;
lan78xx.c +1 -1
@@ -2,7 +2,7 @@#include <string.h> #include "internal.h" -int lan78xx_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int lan78xx_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {unsigned int *lan78xx_reg = (unsigned int *)regs->data;
marvell.c +2 -2
@@ -259,7 +259,7 @@ static void dump_control(u8 *r)printf ("General Purpose I/O 0x%08X\n" , *(u32 *) (r +0x15c )); } -int skge_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int skge_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {const u32 *r = (const u32 *) regs->data;
@@ -380,7 +380,7 @@ static void dump_prefetch(const char *name, const void *r) } } -int sky2_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int sky2_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {const u16 *r16 = (const u16 *) regs->data;
natsemi.c +2 -2
@@ -323,7 +323,7 @@ static void __print_intr(int d, int intr, const char *name, }while (0 ) int -natsemi_dump_regs(struct ethtool_drvinfo *info maybe_unused, +natsemi_dump_regs(struct ethtool_drvinfo *info __maybe_unused, struct ethtool_regs *regs) { u32 *data = (u32 *)regs->data;
@@ -964,7 +964,7 @@ natsemi_dump_regs(struct ethtool_drvinfo *info maybe_unused, }int -natsemi_dump_eeprom(struct ethtool_drvinfo *info maybe_unused, +natsemi_dump_eeprom (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_eeprom *ee) {int i;
realtek.c +1 -1
@@ -241,7 +241,7 @@ print_intr_bits(u16 mask) }int -realtek_dump_regs(struct ethtool_drvinfo *info maybe_unused, +realtek_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {u32 *data = (u32 *) regs->data;
sfc.c +2 -1
@@ -3890,7 +3890,8 @@ print_complex_table(unsigned revision, const struct efx_nic_reg_table *table, }int -sfc_dump_regs(struct ethtool_drvinfo *info maybe_unused, struct ethtool_regs *regs) +sfc_dump_regs (struct ethtool_drvinfo *info__maybe_unused , +struct ethtool_regs *regs) {const struct efx_nic_reg *reg;const struct efx_nic_reg_table *table;
smsc911x.c +1 -1
@@ -2,7 +2,7 @@#include <string.h> #include "internal.h" -int smsc911x_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int smsc911x_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {unsigned int *smsc_reg = (unsigned int *)regs->data;
stmmac.c +2 -2
@@ -18,7 +18,7 @@#define GMAC_REG_NUM 55#define GMAC_DMA_REG_NUM 23 -int st_mac100_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int st_mac100_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {int i;
@@ -51,7 +51,7 @@ int st_mac100_dump_regs(struct ethtool_drvinfo *info maybe_unused,return 0 ; } -int st_gmac_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int st_gmac_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {int i;
tg3.c +2 -2
@@ -4,7 +4,7 @@#define TG3_MAGIC 0x669955aa -int tg3_dump_eeprom(struct ethtool_drvinfo *info maybe_unused, +int tg3_dump_eeprom (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_eeprom *ee) {int i;
@@ -23,7 +23,7 @@ int tg3_dump_eeprom(struct ethtool_drvinfo *info maybe_unused,return 0 ; } -int tg3_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int tg3_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {int i;
tse.c +1 -1
@@ -25,7 +25,7 @@ bitset(u32 val, int bit)return 0 ; } -int altera_tse_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int altera_tse_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {int i;
vioc.c +1 -1
@@ -11,7 +11,7 @@ struct regs_line {#define VIOC_REGS_LINE_SIZE sizeof(struct regs_line) -int vioc_dump_regs(struct ethtool_drvinfo *info maybe_unused, +int vioc_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {unsigned int i;
vmxnet3.c +1 -1
@@ -3,7 +3,7 @@#include "internal.h" int -vmxnet3_dump_regs(struct ethtool_drvinfo *info maybe_unused, +vmxnet3_dump_regs (struct ethtool_drvinfo *info__maybe_unused ,struct ethtool_regs *regs) {u32 *regs_buff = (u32 *)regs->data;
Signature · 1 line
2.28.0
PATCH 2/7 cable_test: clean up unused parameters
In reply to Michal KubecekFunctions nl_cable_test_ntf_attr() and nl_cable_test_tdr_ntf_attr() do not use nlctx parameter and as they are not callbacks with fixed signature, we can simply drop it. Once we do, the same is true for cable_test_ntf_nest() and cable_test_tdr_ntf_nest().
--- netlink/cable_test.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
netlink/cable_test.c +8 -13
@@ -88,8 +88,7 @@ static char *nl_pair2txt(uint8_t pair) } } -static int nl_cable_test_ntf_attr (struct nlattr *evattr, -struct nl_context *nlctx) +static int nl_cable_test_ntf_attr (struct nlattr *evattr) {unsigned int cm;uint16_t code;
@@ -122,14 +121,13 @@ static int nl_cable_test_ntf_attr(struct nlattr *evattr,return 0 ; } -static void cable_test_ntf_nest (const struct nlattr *nest, -struct nl_context *nlctx) +static void cable_test_ntf_nest (const struct nlattr *nest) {struct nlattr *pos;int ret;mnl_attr_for_each_nested (pos, nest) { - ret =nl_cable_test_ntf_attr (pos, nlctx); + ret =nl_cable_test_ntf_attr (pos);if (ret <0 )return ; }
@@ -180,7 +178,7 @@ static int cable_test_ntf_stop_cb(const struct nlmsghdr *nlhdr, void *data) }if (tb[ETHTOOL_A_CABLE_TEST_NTF_NEST ]) -cable_test_ntf_nest (tb[ETHTOOL_A_CABLE_TEST_NTF_NEST ], nlctx); +cable_test_ntf_nest (tb[ETHTOOL_A_CABLE_TEST_NTF_NEST ]);if (status ==ETHTOOL_A_CABLE_TEST_NTF_STATUS_COMPLETED ) {if (ctctx)
@@ -339,8 +337,7 @@ static int nl_get_cable_test_tdr_step(const struct nlattr *nest,return 0 ; } -static int nl_cable_test_tdr_ntf_attr (struct nlattr *evattr, -struct nl_context *nlctx) +static int nl_cable_test_tdr_ntf_attr (struct nlattr *evattr) {uint32_t first, last, step;uint8_t pair;
@@ -391,14 +388,13 @@ static int nl_cable_test_tdr_ntf_attr(struct nlattr *evattr,return 0 ; } -static void cable_test_tdr_ntf_nest (const struct nlattr *nest, -struct nl_context *nlctx) +static void cable_test_tdr_ntf_nest (const struct nlattr *nest) {struct nlattr *pos;int ret;mnl_attr_for_each_nested (pos, nest) { - ret =nl_cable_test_tdr_ntf_attr (pos, nlctx); + ret =nl_cable_test_tdr_ntf_attr (pos);if (ret <0 )return ; }
@@ -450,8 +446,7 @@ int cable_test_tdr_ntf_stop_cb(const struct nlmsghdr *nlhdr, void *data) }if (tb[ETHTOOL_A_CABLE_TEST_TDR_NTF_NEST ]) -cable_test_tdr_ntf_nest (tb[ETHTOOL_A_CABLE_TEST_TDR_NTF_NEST ], - nlctx); +cable_test_tdr_ntf_nest (tb[ETHTOOL_A_CABLE_TEST_TDR_NTF_NEST ]);if (status ==ETHTOOL_A_CABLE_TEST_NTF_STATUS_COMPLETED ) {if (ctctx)
Signature · 1 line
2.28.0
Re: [PATCH ethtool 2/7] cable_test: clean up unused parameters
Quoted 6 lines · Michal Kubecek
Functions
nl_cable_test_ntf_attr()andnl_cable_test_tdr_ntf_attr()do not use nlctx parameter and as they are not callbacks with fixed signature, we can simply drop it. Once we do, the same is true forcable_test_ntf_nest()andcable_test_tdr_ntf_nest().Signed-off-by Michal Kubecek <[email protected]>
Andrew
PATCH 3/7 igc: mark unused callback parameter
In reply to Michal KubecekMark info parameter of igc_dump_regs() as unused to get rid of gcc warning.
--- igc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
igc.c +2 -1
@@ -94,7 +94,8 @@ static const char *bit_to_prio(u32 val)return val ?"low" :"high" ; } -int igc_dump_regs (struct ethtool_drvinfo *info,struct ethtool_regs *regs) +int igc_dump_regs (struct ethtool_drvinfo *info__maybe_unused , +struct ethtool_regs *regs) {u32 reg;int offset, i;
Signature · 1 line
2.28.0
PATCH 4/7 netlink: mark unused callback parameter
In reply to Michal KubecekFunction nomsg_reply_cb() is used as a callback for mnl_cb_run() but it does not use its data parameter; mark it as unused to get rid of compiler warning.
--- netlink/netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
netlink/netlink.c +1 -1
@@ -16,7 +16,7 @@/* Used as reply callback for requests where no reply is expected (e.g. most * "set" type commands) */ -int nomsg_reply_cb (const struct nlmsghdr *nlhdr,void *data) +int nomsg_reply_cb (const struct nlmsghdr *nlhdr,void *data__maybe_unused ) {const struct genlmsghdr *ghdr = (const struct genlmsghdr *)(nlhdr +1 );
Signature · 1 line
2.28.0
PATCH 5/7 netlink: mark unused parameters of bitset walker callbacks
In reply to Michal KubecekSome callbacks used with walk_bitset() do not use all parameters passed to them. Mark unused parameters explicitly to get rid of compiler warnings.
--- netlink/pause.c | 3 ++- netlink/privflags.c | 2 +- netlink/settings.c | 9 ++++++--- netlink/tsinfo.c | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-)
netlink/pause.c +2 -1
@@ -21,7 +21,8 @@ struct pause_autoneg_status {bool asym_pause; }; -static void pause_autoneg_walker (unsigned int idx,const char *name,bool val, +static void pause_autoneg_walker (unsigned int idx, +const char *name__maybe_unused ,bool val,void *data) {struct pause_autoneg_status *status = data;
netlink/privflags.c +1 -1
@@ -19,7 +19,7 @@/* PRIVFLAGS_GET */ static void privflags_maxlen_walk_cb (unsigned int idx,const char *name, -bool val,void *data) +bool val__maybe_unused ,void *data) {unsigned int *maxlen = data;unsigned int len, n;
netlink/settings.c +6 -3
@@ -656,7 +656,8 @@ int linkstate_reply_cb(const struct nlmsghdr *nlhdr, void *data)return MNL_CB_OK ; } -void wol_modes_cb (unsigned int idx,const char *name,bool val,void *data) +void wol_modes_cb (unsigned int idx,const char *name__maybe_unused ,bool val, +void *data) {struct ethtool_wolinfo *wol = data;
@@ -704,7 +705,8 @@ int wol_reply_cb(const struct nlmsghdr *nlhdr, void *data)return MNL_CB_OK ; } -void msgmask_cb (unsigned int idx,const char *name,bool val,void *data) +void msgmask_cb (unsigned int idx,const char *name__maybe_unused ,bool val, +void *data) {u32 *msg_mask = data;
@@ -714,7 +716,8 @@ void msgmask_cb(unsigned int idx, const char *name, bool val, void *data) *msg_mask |= (1U << idx); } -void msgmask_cb2 (unsigned int idx,const char *name,bool val,void *data) +void msgmask_cb2 (unsigned int idx__maybe_unused ,const char *name, +bool val,void *data__maybe_unused ) {if (val)printf (" %s" , name);
netlink/tsinfo.c +1 -1
@@ -16,7 +16,7 @@/* TSINFO_GET */ static void tsinfo_dump_cb (unsigned int idx,const char *name,bool val, -void *data) +void *data__maybe_unused ) {if (!val)return ;
Signature · 1 line
2.28.0
PATCH 6/7 netlink: mark unused parameters of parser callbacks
In reply to Michal KubecekSome calbacks used with nl_parser() do not use all parameters passed to them. Mark unused parameters explicitly to get rid of compiler warnings.
--- netlink/parser.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
netlink/parser.c +16 -12
@@ -155,8 +155,9 @@ static int lookup_u8(const char *arg, uint8_t *result,/* Parser handler for a flag. Expects a name (with no additional argument), * generates NLA_FLAG or sets a bool (if the name was present). */ -int nl_parse_flag (struct nl_context *nlctx,uint16_t type,const void *data, -struct nl_msg_buff *msgbuff,void *dest) +int nl_parse_flag (struct nl_context *nlctx__maybe_unused ,uint16_t type, +const void *data__maybe_unused ,struct nl_msg_buff *msgbuff, +void *dest) {if (dest) *(bool *)dest = true;
@@ -166,7 +167,8 @@ int nl_parse_flag(struct nl_context *nlctx, uint16_t type, const void *data,/* Parser handler for null terminated string. Expects a string argument, * generates NLA_NUL_STRING or fills const char * */ -int nl_parse_string (struct nl_context *nlctx,uint16_t type,const void *data, +int nl_parse_string (struct nl_context *nlctx,uint16_t type, +const void *data__maybe_unused ,struct nl_msg_buff *msgbuff,void *dest) {const char *arg = *nlctx->argp;
@@ -183,8 +185,8 @@ int nl_parse_string(struct nl_context *nlctx, uint16_t type, const void *data,* (may use 0x prefix), generates NLA_U32 or fills an uint32_t. */ int nl_parse_direct_u32 (struct nl_context *nlctx,uint16_t type, -const void *data,struct nl_msg_buff *msgbuff, -void *dest) +const void *data__maybe_unused , +struct nl_msg_buff *msgbuff,void *dest) {const char *arg = *nlctx->argp;uint32_t val;
@@ -207,8 +209,8 @@ int nl_parse_direct_u32(struct nl_context *nlctx, uint16_t type,* (may use 0x prefix), generates NLA_U32 or fills an uint32_t. */ int nl_parse_direct_u8 (struct nl_context *nlctx,uint16_t type, -const void *data,struct nl_msg_buff *msgbuff, -void *dest) +const void *data__maybe_unused , +struct nl_msg_buff *msgbuff,void *dest) {const char *arg = *nlctx->argp;uint8_t val;
@@ -231,8 +233,8 @@ int nl_parse_direct_u8(struct nl_context *nlctx, uint16_t type,* NLA_U32 or fills an uint32_t. */ int nl_parse_direct_m2cm (struct nl_context *nlctx,uint16_t type, -const void *data,struct nl_msg_buff *msgbuff, -void *dest) +const void *data__maybe_unused , +struct nl_msg_buff *msgbuff,void *dest) {const char *arg = *nlctx->argp;float meters;
@@ -256,7 +258,8 @@ int nl_parse_direct_m2cm(struct nl_context *nlctx, uint16_t type,/* Parser handler for (tri-state) bool. Expects "name on|off", generates * NLA_U8 which is 1 for "on" and 0 for "off". */ -int nl_parse_u8bool (struct nl_context *nlctx,uint16_t type,const void *data, +int nl_parse_u8bool (struct nl_context *nlctx,uint16_t type, +const void *data__maybe_unused ,struct nl_msg_buff *msgbuff,void *dest) {const char *arg = *nlctx->argp;
@@ -463,8 +466,9 @@ err:* error_parser_params (error message, return value and number of extra * arguments to skip). */ -int nl_parse_error (struct nl_context *nlctx,uint16_t type,const void *data, -struct nl_msg_buff *msgbuff,void *dest) +int nl_parse_error (struct nl_context *nlctx,uint16_t type__maybe_unused , +const void *data,struct nl_msg_buff *msgbuff__maybe_unused , +void *dest__maybe_unused ) {const struct error_parser_data *parser_data = data;unsigned int skip = parser_data->extra_args;
Signature · 1 line
2.28.0
PATCH 7/7 ioctl: avoid zero length array warning in get_stringset()
In reply to Michal KubecekStarting with gcc10, gcc issues a warning about accessing elements of zero leghth arrays. This is usually fixed by using C99 variable length arrays but struct ethtool_sset_info is part of kernel UAPI so use an auxiliary pointer instead.
--- ethtool.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
ethtool.c +3 -1
@@ -1632,7 +1632,9 @@ get_stringset(struct cmd_context *ctx, enum ethtool_stringset set_id, sset_info.hdr.reserved =0 ; sset_info.hdr.sset_mask =1ULL << set_id;if (send_ioctl (ctx, &sset_info) ==0 ) { - len = sset_info.hdr.sset_mask ? sset_info.hdr.data[0 ] :0 ; +const u32 *sset_lengths = sset_info.hdr.data; + + len = sset_info.hdr.sset_mask ? sset_lengths[0 ] :0 ; }else if (errno ==EOPNOTSUPP && drvinfo_offset !=0 ) {/* Fallback for old kernel versions */ drvinfo.cmd =ETHTOOL_GDRVINFO ;
Signature · 1 line
2.28.0
Quoted 2 lines · Michal Kubecek
Maciej Żenczykowski recently cleaned up many "unused parameter" compiler warnings but some new occurences appeared since (mostly in netlink code).
Hi Michal
Could you modify the compiler flags to get gcc to warn about these? Otherwise they will just come back again.
Andrew
Quoted 8 lines · Andrew Lunn
Quoted 2 lines · Michal Kubecek
Maciej Żenczykowski recently cleaned up many "unused parameter" compiler warnings but some new occurences appeared since (mostly in netlink code).
Hi Michal
Could you modify the compiler flags to get gcc to warn about these? Otherwise they will just come back again.
Good point. I'll add "-Wextra" to default CFLAGS in Makefile.am with the second part of the cleanup (shortly after 5.8 release). At that point there will be no warnings so that it will be easy to spot any new ones.
Michal