Skip to contentSkip to conversation

cpufeature: avoid warning when compiling with clang

PATCH In review Stefan Agner 3 participants 5 messages Sep 16, 2018 – Sep 21, 2018

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

PATCH 1/2 cpufeature: avoid warning when compiling with clang

The table id (second) argument to MODULE_DEVICE_TABLE is often referenced otherwise. This is not the case for CPU features. This leads to warnings when building the kernel with Clang:
arch/arm/crypto/aes-ce-glue.c:450:1: warning: variable
'cpu_feature_match_AES' is not needed and will not be emitted [-Wunneeded-internal-declaration]
module_cpu_feature_match(AES, aes_init);
^

Avoid warnings by using __maybe_unused, similar to commit 1f318a8bafcf ("modules: mark __inittest/__exittest as __maybe_unused").

Fixes 67bad2fdb754 ("cpu: add generic support for CPU feature based module autoloading")
---
 include/linux/cpufeature.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/cpufeature.h +1 -1
index 986c06c88d81..84d3c81b5978 100644
@@ -45,7 +45,7 @@
  * 'asm/cpufeature.h' of your favorite architecture.
  */
 #define module_cpu_feature_match(x, __initfunc)			\
-static struct cpu_feature const cpu_feature_match_ ## x[] =	\
+static struct cpu_feature const __maybe_unused cpu_feature_match_ ## x[] = \
 	{ { .feature = cpu_feature(x) }, { } };			\
 MODULE_DEVICE_TABLE(cpu, cpu_feature_match_ ## x);		\
 								\
Signature · 1 line
2.19.0
#1 lore raw

PATCH 2/2 crypto: arm/crc32 - avoid warning when compiling with Clang

The table id (second) argument to MODULE_DEVICE_TABLE is often referenced otherwise. This is not the case for CPU features. This leads to a warning when building the kernel with Clang:
arch/arm/crypto/crc32-ce-glue.c:239:33: warning: variable
'crc32_cpu_feature' is not needed and will not be emitted [-Wunneeded-internal-declaration]

  static const struct cpu_feature crc32_cpu_feature[] = {
                                  ^

Avoid warnings by using __maybe_unused, similar to commit 1f318a8bafcf ("modules: mark __inittest/__exittest as __maybe_unused").

Fixes 2a9faf8b7e43 ("crypto: arm/crc32 - enable module autoloading based on CPU feature bits")
---
 arch/arm/crypto/crc32-ce-glue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/crypto/crc32-ce-glue.c +1 -1
index 96e62ec105d0..cd9e93b46c2d 100644
@@ -236,7 +236,7 @@ static void __exit crc32_pmull_mod_exit(void)
 				  ARRAY_SIZE(crc32_pmull_algs));
 }
 
-static const struct cpu_feature crc32_cpu_feature[] = {
+static const struct cpu_feature __maybe_unused crc32_cpu_feature[] = {
 	{ cpu_feature(CRC32) }, { cpu_feature(PMULL) }, { }
 };
 MODULE_DEVICE_TABLE(cpu, crc32_cpu_feature);
Signature · 1 line
2.19.0
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] crypto: arm/crc32 - avoid warning when compiling with Clang

Quoted 6 lines · Stefan Agner

The table id (second) argument to MODULE_DEVICE_TABLE is often referenced otherwise. This is not the case for CPU features. This leads to a warning when building the kernel with Clang:
arch/arm/crypto/crc32-ce-glue.c:239:33: warning: variable
'crc32_cpu_feature' is not needed and will not be emitted [-Wunneeded-internal-declaration]

Quoted 8 lines
  static const struct cpu_feature crc32_cpu_feature[] = {
                                  ^

Avoid warnings by using __maybe_unused, similar to commit 1f318a8bafcf ("modules: mark __inittest/__exittest as __maybe_unused").

Fixes 2a9faf8b7e43 ("crypto: arm/crc32 - enable module autoloading based on CPU feature bits")
Quoted 20 lines
---
 arch/arm/crypto/crc32-ce-glue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/crypto/crc32-ce-glue.c +1 -2
index 96e62ec105d0..cd9e93b46c2d 100644
@@ -236,7 +236,7 @@ static void __exit crc32_pmull_mod_exit(void)
                                  ARRAY_SIZE(crc32_pmull_algs));
 }
 
-static const struct cpu_feature crc32_cpu_feature[] = {
+static const struct cpu_feature __maybe_unused crc32_cpu_feature[] = {
        { cpu_feature(CRC32) }, { cpu_feature(PMULL) }, { }
 };
 MODULE_DEVICE_TABLE(cpu, crc32_cpu_feature);
--

2.19.0

Acked-by on v1 1/2
#3 lore raw
In reply to Stefan Agner
Quoted 9 lines · Stefan Agner

The table id (second) argument to MODULE_DEVICE_TABLE is often referenced otherwise. This is not the case for CPU features. This leads to warnings when building the kernel with Clang:
arch/arm/crypto/aes-ce-glue.c:450:1: warning: variable
'cpu_feature_match_AES' is not needed and will not be emitted [-Wunneeded-internal-declaration]
module_cpu_feature_match(AES, aes_init);
^

Quoted 5 lines

Avoid warnings by using __maybe_unused, similar to commit 1f318a8bafcf ("modules: mark __inittest/__exittest as __maybe_unused").

Fixes 67bad2fdb754 ("cpu: add generic support for CPU feature based module autoloading")
Quoted 20 lines
---
 include/linux/cpufeature.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/cpufeature.h +1 -2
index 986c06c88d81..84d3c81b5978 100644
@@ -45,7 +45,7 @@
  * 'asm/cpufeature.h' of your favorite architecture.
  */
 #define module_cpu_feature_match(x, __initfunc)                        \
-static struct cpu_feature const cpu_feature_match_ ## x[] =    \
+static struct cpu_feature const __maybe_unused cpu_feature_match_ ## x[] = \
        { { .feature = cpu_feature(x) }, { } };                 \
 MODULE_DEVICE_TABLE(cpu, cpu_feature_match_ ## x);             \
                                                                \
--

2.19.0

maintainer
#4 lore raw
In reply to Stefan Agner
Quoted 9 lines · Stefan Agner

The table id (second) argument to MODULE_DEVICE_TABLE is often referenced otherwise. This is not the case for CPU features. This leads to warnings when building the kernel with Clang:
arch/arm/crypto/aes-ce-glue.c:450:1: warning: variable
'cpu_feature_match_AES' is not needed and will not be emitted [-Wunneeded-internal-declaration]
module_cpu_feature_match(AES, aes_init);
^

Quoted 8 lines

Avoid warnings by using __maybe_unused, similar to commit 1f318a8bafcf ("modules: mark __inittest/__exittest as __maybe_unused").

Fixes 67bad2fdb754 ("cpu: add generic support for CPU feature based module autoloading")
---
 include/linux/cpufeature.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

All applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt