Message ID | 20191017182121.103569-2-zenczykowski@gmail.com |
---|---|
State | Accepted |
Delegated to: | John Linville |
Headers | show |
Series | [01/33] fix arithmetic on pointer to void is a GNU extension warning | expand |
On Thu, Oct 17, 2019 at 11:20:50AM -0700, Maciej Żenczykowski wrote: > From: Maciej Żenczykowski <maze@google.com> > > This fixes: > external/ethtool/ethtool.c:473:43: error: unused parameter 'ctx' [-Werror,-Wunused-parameter] > static int do_version(struct cmd_context *ctx) > > external/ethtool/ethtool.c:5392:43: error: unused parameter 'ctx' [-Werror,-Wunused-parameter] > static int show_usage(struct cmd_context *ctx) > > Signed-off-by: Maciej Żenczykowski <maze@google.com> > Change-Id: I0cc52f33bb0e8d7627f5e84bb4e3dfa821d17cc8 > --- > ethtool.c | 4 ++-- > internal.h | 2 ++ > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/ethtool.c b/ethtool.c > index 082e37f..5e0deda 100644 > --- a/ethtool.c > +++ b/ethtool.c > @@ -470,7 +470,7 @@ static int rxflow_str_to_type(const char *str) > return flow_type; > } > > -static int do_version(struct cmd_context *ctx) > +static int do_version(struct cmd_context *ctx maybe_unused) > { Considering how frequent this pattern (a callback where not all instances use all parameters) is, maybe we could consider disabling the warning with -Wno-unused-parameter instead of marking all places where it is issued. Michal Kubecek > fprintf(stdout, > PACKAGE " version " VERSION > @@ -5484,7 +5484,7 @@ static const struct option { > {} > }; > > -static int show_usage(struct cmd_context *ctx) > +static int show_usage(struct cmd_context *ctx maybe_unused) > { > int i; > > diff --git a/internal.h b/internal.h > index aecf1ce..ff52c6e 100644 > --- a/internal.h > +++ b/internal.h > @@ -23,6 +23,8 @@ > #include <sys/ioctl.h> > #include <net/if.h> > > +#define maybe_unused __attribute__((__unused__)) > + > /* ethtool.h expects these to be defined by <linux/types.h> */ > #ifndef HAVE_BE_TYPES > typedef uint16_t __be16; > -- > 2.23.0.866.gb869b98d4c-goog >
> Considering how frequent this pattern (a callback where not all > instances use all parameters) is, maybe we could consider disabling the > warning with -Wno-unused-parameter instead of marking all places where > it is issued. Once you fix it... it stays fixed. There's no cost to carrying around the extra annotation. And the warning still finds other places where you're doing it wrong.
diff --git a/ethtool.c b/ethtool.c index 082e37f..5e0deda 100644 --- a/ethtool.c +++ b/ethtool.c @@ -470,7 +470,7 @@ static int rxflow_str_to_type(const char *str) return flow_type; } -static int do_version(struct cmd_context *ctx) +static int do_version(struct cmd_context *ctx maybe_unused) { fprintf(stdout, PACKAGE " version " VERSION @@ -5484,7 +5484,7 @@ static const struct option { {} }; -static int show_usage(struct cmd_context *ctx) +static int show_usage(struct cmd_context *ctx maybe_unused) { int i; diff --git a/internal.h b/internal.h index aecf1ce..ff52c6e 100644 --- a/internal.h +++ b/internal.h @@ -23,6 +23,8 @@ #include <sys/ioctl.h> #include <net/if.h> +#define maybe_unused __attribute__((__unused__)) + /* ethtool.h expects these to be defined by <linux/types.h> */ #ifndef HAVE_BE_TYPES typedef uint16_t __be16;