Skip to contentSkip to conversation

sysctl: quiet unused variable warning in fs/proc/proc_sysctl.c:init_header()

PATCH In review Ethan Nelson-Moore 2 participants 4 messages Sep 18 – Sep 25

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

PATCH 1/1 sysctl: quiet unused variable warning in fs/proc/proc_sysctl.c:init_header()

The init_header() function uses list_for_each_table_entry() without using the entry argument. This causes a warning when building with W=1. Since the code is correct, mark the associated variable as __maybe_unused.

---
 fs/proc/proc_sysctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc/proc_sysctl.c +1 -1
index 04a382178c65..d0d76c31d330 100644
@@ -206,7 +206,7 @@ static void init_header(struct ctl_table_header *head,
 	head->node = node;
 	INIT_HLIST_HEAD(&head->inodes);
 	if (node) {
-		const struct ctl_table *entry;
+		const struct ctl_table *entry __maybe_unused;
 
 		list_for_each_table_entry(entry, head) {
 			node->header = head;
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 4 lines · Ethan Nelson-Moore

The init_header() function uses list_for_each_table_entry() without using the entry argument. This causes a warning when building with W=1. Since the code is correct, mark the associated variable as __maybe_unused.

I'm probably compiling in a different way but I don't see that warning. Can you please tell me how you compile, what are you are in. What version of compiler are you running?

Thx

Quoted 22 lines
---
 fs/proc/proc_sysctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc/proc_sysctl.c +1 -1
index 04a382178c65..d0d76c31d330 100644
@@ -206,7 +206,7 @@ static void init_header(struct ctl_table_header *head,
 	head->node = node;
 	INIT_HLIST_HEAD(&head->inodes);
 	if (node) {
-		const struct ctl_table *entry;
+		const struct ctl_table *entry __maybe_unused;
 
 		list_for_each_table_entry(entry, head) {
 			node->header = head;
Signature · 1 line
2.43.0
#2 lore raw

Hi, Joel,

Quoted 3 lines · Joel Granados

I'm probably compiling in a different way but I don't see that warning. Can you please tell me how you compile, what are you are in. What version of compiler are you running?

I'm using GCC 16.2, which probably explains it, since newer GCC versions have gotten more clever at detecting unused variables.

Ethan

maintainer
#3 lore raw
Quoted 9 lines · Ethan Nelson-Moore

Hi, Joel,

Quoted 3 lines · Joel Granados

I'm probably compiling in a different way but I don't see that warning. Can you please tell me how you compile, what are you are in. What version of compiler are you running?

I'm using GCC 16.2, which probably explains it, since newer GCC versions have gotten more clever at detecting unused variables.

I'll add it to sysctl-next

best