All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs/proc: avoid unused ctl_table entry in init_header
@ 2026-09-09 16:32 Safety 1
  2026-09-15 11:53 ` Joel Granados
  0 siblings, 1 reply; 2+ messages in thread
From: Safety 1 @ 2026-09-09 16:32 UTC (permalink / raw)
  To: kees; +Cc: joel.granados, linux-kernel, linux-fsdevel, Safety 1

The entry variable in init_header() is only used by
list_for_each_table_entry() for iteration and is never read. With
-Werror=unused-but-set-variable, this causes the build to fail.

Use the table size directly for the loop since the entry value is
not needed here.

Tested with: make -j$(nproc)
Signed-off-by: Safety 1 <176830914+JokerPython3@users.noreply.github.com>
---
 fs/proc/proc_sysctl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 04a382178..ddc510def 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -206,9 +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;
-
-		list_for_each_table_entry(entry, head) {
+		for (size_t i = 0; i < head->ctl_table_size; i++) {
 			node->header = head;
 			node++;
 		}

base-commit: 893e11787f78e43b534e252249ac3fff4d1333f8
-- 
2.55.0


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

* Re: [PATCH] fs/proc: avoid unused ctl_table entry in init_header
  2026-09-09 16:32 [PATCH] fs/proc: avoid unused ctl_table entry in init_header Safety 1
@ 2026-09-15 11:53 ` Joel Granados
  0 siblings, 0 replies; 2+ messages in thread
From: Joel Granados @ 2026-09-15 11:53 UTC (permalink / raw)
  To: Safety 1; +Cc: kees, linux-kernel, linux-fsdevel, Safety 1

[-- Attachment #1: Type: text/plain, Size: 1331 bytes --]

On Wed, Sep 09, 2026 at 07:32:14PM +0300, Safety 1 wrote:
> The entry variable in init_header() is only used by
> list_for_each_table_entry() for iteration and is never read. With
> -Werror=unused-but-set-variable, this causes the build to fail.
That makes no sense. entry++ implies a read. Additionally that entry should be
removed once the code is optimized compiled. So there is no need for this.

> 
> Use the table size directly for the loop since the entry value is
> not needed here.
> 
> Tested with: make -j$(nproc)
> Signed-off-by: Safety 1 <176830914+JokerPython3@users.noreply.github.com>
This is just wrong.

> ---
>  fs/proc/proc_sysctl.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> index 04a382178..ddc510def 100644
> --- a/fs/proc/proc_sysctl.c
> +++ b/fs/proc/proc_sysctl.c
> @@ -206,9 +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;
> -
> -		list_for_each_table_entry(entry, head) {
> +		for (size_t i = 0; i < head->ctl_table_size; i++) {
>  			node->header = head;
>  			node++;
>  		}
> 
> base-commit: 893e11787f78e43b534e252249ac3fff4d1333f8
> -- 
> 2.55.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

end of thread, other threads:[~2026-09-15 11:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-09 16:32 [PATCH] fs/proc: avoid unused ctl_table entry in init_header Safety 1
2026-09-15 11:53 ` Joel Granados

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.