Skip to contentSkip to conversation

tpm: aovid -Wunused-but-set-variable

PATCH In review Arnd Bergmann 3 participants 3 messages Mar 22, 2024 – Apr 15

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

PATCH 1/1 tpm: aovid -Wunused-but-set-variable

From: Arnd Bergmann <[email protected]>

Outside of the EFI tpm code, the TPM_MEMREMAP()/TPM_MEMUNMAP functions are defined as trivial macros, leading to the mapping_size variable ending up unused:

In file included from drivers/char/tpm/tpm-sysfs.c:16:
In file included from drivers/char/tpm/tpm.h:28:
include/linux/tpm_eventlog.h:167:6: error: variable 'mapping_size' set but not used [-Werror,-Wunused-but-set-variable]
167 | int mapping_size;

Turn the stubs into inline functions to avoid this warning.

Fixes c46f3405692d ("tpm: Reserve the TPM final events table")
---
 include/linux/tpm_eventlog.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
include/linux/tpm_eventlog.h +7 -2
index 7d68a5cc5881..6e5be15029fb 100644
@@ -131,11 +131,16 @@ struct tcg_algorithm_info {
 };
 
 #ifndef TPM_MEMREMAP
-#define TPM_MEMREMAP(start, size) NULL
+static inline void *TPM_MEMREMAP(unsigned long start, size_t size)
+{
+	return NULL;
+}
 #endif
 
 #ifndef TPM_MEMUNMAP
-#define TPM_MEMUNMAP(start, size) do{} while(0)
+static inline void TPM_MEMUNMAP(void *mapping, size_t size)
+{
+}
 #endif
 
 /**
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 32 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Outside of the EFI tpm code, the TPM_MEMREMAP()/TPM_MEMUNMAP functions are defined as trivial macros, leading to the mapping_size variable ending up unused:

In file included from drivers/char/tpm/tpm-sysfs.c:16:
In file included from drivers/char/tpm/tpm.h:28:
include/linux/tpm_eventlog.h:167:6: error: variable 'mapping_size' set but not used [-Werror,-Wunused-but-set-variable]
167 | int mapping_size;

Turn the stubs into inline functions to avoid this warning.

Fixes c46f3405692d ("tpm: Reserve the TPM final events table")
---
 include/linux/tpm_eventlog.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
include/linux/tpm_eventlog.h +4 -1
index 7d68a5cc5881..6e5be15029fb 100644
@@ -131,11 +131,16 @@ struct tcg_algorithm_info {
 };
 
 #ifndef TPM_MEMREMAP
-#define TPM_MEMREMAP(start, size) NULL
+static inline void *TPM_MEMREMAP(unsigned long start, size_t size)
+{
+	return NULL;
+}

include/linux/tpm_eventlog.h struct tcg_algorithm_info { · line 146

Quoted 10 lines
include/linux/tpm_eventlog.h +3 -1
 #endif
 
 #ifndef TPM_MEMUNMAP
-#define TPM_MEMUNMAP(start, size) do{} while(0)
+static inline void TPM_MEMUNMAP(void *mapping, size_t size)
+{
+}
 #endif
 
 /**

I just stumbled upon the same problem and found this patch from 2024, which still applies. I cc'ed the current maintainers - maybe someone can pick this up? Thanks!

maintainer
#2 lore raw
Quoted 42 lines · Thorsten Blum
Quoted 41 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Outside of the EFI tpm code, the TPM_MEMREMAP()/TPM_MEMUNMAP functions are defined as trivial macros, leading to the mapping_size variable ending up unused:

In file included from drivers/char/tpm/tpm-sysfs.c:16:
In file included from drivers/char/tpm/tpm.h:28:
include/linux/tpm_eventlog.h:167:6: error: variable 'mapping_size' set but not used [-Werror,-Wunused-but-set-variable]
167 | int mapping_size;

Turn the stubs into inline functions to avoid this warning.

Fixes c46f3405692d ("tpm: Reserve the TPM final events table")
---
 include/linux/tpm_eventlog.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
include/linux/tpm_eventlog.h +7 -2
index 7d68a5cc5881..6e5be15029fb 100644
@@ -131,11 +131,16 @@ struct tcg_algorithm_info {
 };
 
 #ifndef TPM_MEMREMAP
-#define TPM_MEMREMAP(start, size) NULL
+static inline void *TPM_MEMREMAP(unsigned long start, size_t size)
+{
+	return NULL;
+}
 #endif
 
 #ifndef TPM_MEMUNMAP
-#define TPM_MEMUNMAP(start, size) do{} while(0)
+static inline void TPM_MEMUNMAP(void *mapping, size_t size)
+{
+}
 #endif
 
Quoted 7 lines

include/linux/tpm_eventlog.h struct tcg_algorithm_info { · line 146

Quoted 1 line
include/linux/tpm_eventlog.h +0 -0
 /**

I just stumbled upon the same problem and found this patch from 2024, which still applies. I cc'ed the current maintainers - maybe someone can pick this up? Thanks!

Thanks.

Arnd, I fixed typo in short summary and applied with that modification.

BR, Jarkko