Skip to contentSkip to conversation

Clang warning in drivers/net/ethernet/intel/igc/igc_ethtool.c

DISCUSSION Nathan Chancellor 3 participants 4 messages Feb 8, 2019 – Mar 1, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 5 lines · Nathan Chancellor

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]

Quoted 8 lines
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

#2 lore raw
Quoted 16 lines · Michal Kubecek
Quoted 5 lines · Nathan Chancellor

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]

Quoted 8 lines
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?

Quoted 4 lines

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)?

Signature · 2 lines
Thanks,
~Nick Desaulniers
#3 lore raw
Quoted 17 lines · Nick Desaulniers
Quoted 16 lines · Michal Kubecek
Quoted 13 lines · Nathan Chancellor

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?

Quoted 7 lines
Quoted 4 lines

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