linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Clang warning in drivers/net/ethernet/intel/igc/igc_ethtool.c
@ 2019-02-08  5:09 Nathan Chancellor
  2019-02-08 14:34 ` Michal Kubecek
  0 siblings, 1 reply; 4+ messages in thread
From: Nathan Chancellor @ 2019-02-08  5:09 UTC (permalink / raw)
  To: Sasha Neftin, Jeff Kirsher
  Cc: Aaron Brown, intel-wired-lan, netdev, linux-kernel, Nick Desaulniers

Hi all,

After commit 8c5ad0dae93c ("igc: Add ethtool support"), Clang warns:

drivers/net/ethernet/intel/igc/igc_ethtool.c:9:19: warning: variable 'igc_priv_flags_strings' is not needed and will not be emitted [-Wunneeded-internal-declaration]
static const char igc_priv_flags_strings[][ETH_GSTRING_LEN] = {
                  ^
1 warning generated.

igc_priv_flags_strings is only used in an ARRAY_SIZE macro, which is a
compile time evaluation, so no reference to it is being emitted in the
final assembly. Is it actually needed and was forgotten to be used
somewhere or could it be eliminated so that Clang no longer warns?

Thanks,
Nathan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Clang warning in drivers/net/ethernet/intel/igc/igc_ethtool.c
  2019-02-08  5:09 Clang warning in drivers/net/ethernet/intel/igc/igc_ethtool.c Nathan Chancellor
@ 2019-02-08 14:34 ` Michal Kubecek
  2019-03-01 18:28   ` Nick Desaulniers
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Kubecek @ 2019-02-08 14:34 UTC (permalink / raw)
  To: netdev
  Cc: Nathan Chancellor, Sasha Neftin, Jeff Kirsher, Aaron Brown,
	intel-wired-lan, linux-kernel, Nick Desaulniers

On Thu, Feb 07, 2019 at 10:09:21PM -0700, Nathan Chancellor wrote:
> Hi all,
> 
> After commit 8c5ad0dae93c ("igc: Add ethtool support"), Clang warns:
> 
> drivers/net/ethernet/intel/igc/igc_ethtool.c:9:19: warning: variable 'igc_priv_flags_strings' is not needed and will not be emitted [-Wunneeded-internal-declaration]
> static const char igc_priv_flags_strings[][ETH_GSTRING_LEN] = {
>                   ^
> 1 warning generated.
> 
> igc_priv_flags_strings is only used in an ARRAY_SIZE macro, which is a
> compile time evaluation, so no reference to it is being emitted in the
> final assembly. Is it actually needed and was forgotten to be used
> somewhere or could it be eliminated so that Clang no longer warns?

That's because the driver provides get_priv_flags() and set_priv_flags()
callbacks in its ethtool_ops to allow querying and setting legacy-rx
private flag but it does not provide get_sset_count() and get_strings()
to provide list of private flags to userspace ethtool.

Michal Kubecek

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Clang warning in drivers/net/ethernet/intel/igc/igc_ethtool.c
  2019-02-08 14:34 ` Michal Kubecek
@ 2019-03-01 18:28   ` Nick Desaulniers
  2019-03-01 20:40     ` Michal Kubecek
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Desaulniers @ 2019-03-01 18:28 UTC (permalink / raw)
  To: Michal Kubecek
  Cc: netdev, Nathan Chancellor, Sasha Neftin, Jeff Kirsher,
	Aaron Brown, intel-wired-lan, LKML

On Fri, Feb 8, 2019 at 6:34 AM Michal Kubecek <mkubecek@suse.cz> wrote:
>
> On Thu, Feb 07, 2019 at 10:09:21PM -0700, Nathan Chancellor wrote:
> > Hi all,
> >
> > After commit 8c5ad0dae93c ("igc: Add ethtool support"), Clang warns:
> >
> > drivers/net/ethernet/intel/igc/igc_ethtool.c:9:19: warning: variable 'igc_priv_flags_strings' is not needed and will not be emitted [-Wunneeded-internal-declaration]
> > static const char igc_priv_flags_strings[][ETH_GSTRING_LEN] = {
> >                   ^
> > 1 warning generated.
> >
> > igc_priv_flags_strings is only used in an ARRAY_SIZE macro, which is a
> > compile time evaluation, so no reference to it is being emitted in the
> > final assembly. Is it actually needed and was forgotten to be used
> > somewhere or could it be eliminated so that Clang no longer warns?
>
> That's because the driver provides get_priv_flags() and set_priv_flags()
> callbacks in its ethtool_ops to allow querying and setting legacy-rx
> private flag but it does not provide get_sset_count() and get_strings()
> to provide list of private flags to userspace ethtool.

So the variable declaration should get a `__unused` annotation then
(and maybe a comment)?

-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Clang warning in drivers/net/ethernet/intel/igc/igc_ethtool.c
  2019-03-01 18:28   ` Nick Desaulniers
@ 2019-03-01 20:40     ` Michal Kubecek
  0 siblings, 0 replies; 4+ messages in thread
From: Michal Kubecek @ 2019-03-01 20:40 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: netdev, Nathan Chancellor, Sasha Neftin, Jeff Kirsher,
	Aaron Brown, intel-wired-lan, LKML

On Fri, Mar 01, 2019 at 10:28:35AM -0800, Nick Desaulniers wrote:
> On Fri, Feb 8, 2019 at 6:34 AM Michal Kubecek <mkubecek@suse.cz> wrote:
> >
> > On Thu, Feb 07, 2019 at 10:09:21PM -0700, Nathan Chancellor wrote:
> > > Hi all,
> > >
> > > After commit 8c5ad0dae93c ("igc: Add ethtool support"), Clang warns:
> > >
> > > drivers/net/ethernet/intel/igc/igc_ethtool.c:9:19: warning: variable 'igc_priv_flags_strings' is not needed and will not be emitted [-Wunneeded-internal-declaration]
> > > static const char igc_priv_flags_strings[][ETH_GSTRING_LEN] = {
> > >                   ^
> > > 1 warning generated.
> > >
> > > igc_priv_flags_strings is only used in an ARRAY_SIZE macro, which is a
> > > compile time evaluation, so no reference to it is being emitted in the
> > > final assembly. Is it actually needed and was forgotten to be used
> > > somewhere or could it be eliminated so that Clang no longer warns?
> >
> > That's because the driver provides get_priv_flags() and set_priv_flags()
> > callbacks in its ethtool_ops to allow querying and setting legacy-rx
> > private flag but it does not provide get_sset_count() and get_strings()
> > to provide list of private flags to userspace ethtool.
> 
> So the variable declaration should get a `__unused` annotation then
> (and maybe a comment)?

I would rather suggest to add missing ethtool_ops handlers so that the
flag can be actually shown and set using ethtool.

Michal Kubecek

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-03-01 20:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-08  5:09 Clang warning in drivers/net/ethernet/intel/igc/igc_ethtool.c Nathan Chancellor
2019-02-08 14:34 ` Michal Kubecek
2019-03-01 18:28   ` Nick Desaulniers
2019-03-01 20:40     ` Michal Kubecek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).