lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <vksfx7stglvc7dvdsbu6b6eflmacg5eexnmzu47tdkak4uwscm@rm2ilr5ntriy>
Date: Wed, 9 Jul 2025 12:35:40 +0900
From: Sergey Senozhatsky <senozhatsky@...omium.org>
To: Feng Tang <feng.tang@...ux.alibaba.com>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>, 
	Andrew Morton <akpm@...ux-foundation.org>, linux-kernel@...r.kernel.org, 
	Nathan Chancellor <nathan@...nel.org>
Subject: Re: [PATCH 3/5] panic: add 'panic_sys_info' sysctl to take human
 readable string parameter

On (25/07/09 11:27), Feng Tang wrote:
> > >+#ifdef CONFIG_SYSCTL
> > > +
> > > +static const char sys_info_avail[] = "tasks,mem,timers,locks,ftrace,all_bt,blocked_tasks";
> > > +
> > > +int sysctl_sys_info_handler(const struct ctl_table *ro_table, int write,
> > > +                                         void *buffer, size_t *lenp,
> > > +                                         loff_t *ppos)
> > > +{
> > > +       char names[sizeof(sys_info_avail) + 1];
> > > +       struct ctl_table table;
> > > +       unsigned long *si_bits_global;
> > > +
> > > +       si_bits_global = ro_table->data;
> > [..]
> > 
> > Somehow this breaks the build with:
> > 
> > lib/sys_info.c:52:19: error: variable 'sys_info_avail' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]
> >    52 | static const char sys_info_avail[] = "tasks,mem,timers,locks,ftrace,all_bt,blocked_tasks";
> >       |                   ^~~~~~~~~~~~~~
> > 
> > Moving sys_info_avail[] inside sysctl_sys_info_handler() seems to help.
> 
> Sorry for the trouble. I assume this is clang?  I locally used gcc v10.2.1

No worries.  Yes, clang.

> Nathan Chancellor has helped to post a fix here https://lore.kernel.org/lkml/20250708-fix-clang-sys_info_avail-warning-v1-1-60d239eacd64@kernel.org/

Great.
Would __maybe_unused be better than something simpler:

---

diff --git a/lib/sys_info.c b/lib/sys_info.c
index 46d6f4f1ad2a..3bd789fe29d2 100644
--- a/lib/sys_info.c
+++ b/lib/sys_info.c
@@ -48,13 +48,11 @@ unsigned long sys_info_parse_param(char *str)
 }
 
 #ifdef CONFIG_SYSCTL
-
-static const char sys_info_avail[] = "tasks,mem,timers,locks,ftrace,all_bt,blocked_tasks";
-
 int sysctl_sys_info_handler(const struct ctl_table *ro_table, int write,
 					  void *buffer, size_t *lenp,
 					  loff_t *ppos)
 {
+	static const char sys_info_avail[] = "tasks,mem,timers,locks,ftrace,all_bt,blocked_tasks";
 	char names[sizeof(sys_info_avail) + 1];
 	struct ctl_table table;
 	unsigned long *si_bits_global;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ