* [PATCH] fs: quota: avoid unused function warning for !CONFIG_SYSCTL
@ 2023-03-28 12:22 Arnd Bergmann
2023-03-28 17:48 ` Luis Chamberlain
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2023-03-28 12:22 UTC (permalink / raw)
To: Jan Kara, Yangtao Li
Cc: Arnd Bergmann, Christian Brauner, Seth Forshee, Dave Chinner,
Roman Gushchin, Baokun Li, Matthew Wilcox (Oracle),
Luis Chamberlain, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
Having fs_dqstats_table[] inside of an #ifdef causes a build time
warning:
fs/quota/dquot.c:2864:12: error: 'do_proc_dqstats' defined but not used [-Werror=unused-function]
2864 | static int do_proc_dqstats(struct ctl_table *table, int write,
Avoid this by using an IS_ENABLED() check in place of the #ifdef,
giving the compiler a better idea of how it is used.
Fixes: 63d00e08515b ("quota: check for register_sysctl() failure")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Note: it may be better to just revert the 63d00e08515b patch, as the
additional pr_notice() does not seem to add much value after
the pr_err() printed by register_sysctl() that tells us exactly what
went wrong.
---
fs/quota/dquot.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 05bed02b257f..6e9109c6218e 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -2877,7 +2877,6 @@ static int do_proc_dqstats(struct ctl_table *table, int write,
return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
}
-#ifdef CONFIG_SYSCTL
static struct ctl_table fs_dqstats_table[] = {
{
.procname = "lookups",
@@ -2946,7 +2945,6 @@ static struct ctl_table fs_dqstats_table[] = {
#endif
{ },
};
-#endif
static int __init dquot_init(void)
{
@@ -2955,10 +2953,10 @@ static int __init dquot_init(void)
printk(KERN_NOTICE "VFS: Disk quotas %s\n", __DQUOT_VERSION__);
-#ifdef CONFIG_SYSCTL
- if (!register_sysctl("fs/quota", fs_dqstats_table))
- pr_notice("quota sysctl registration failed!\n");
-#endif
+ if (IS_ENABLED(CONFIG_SYSCTL)) {
+ if (!register_sysctl("fs/quota", fs_dqstats_table))
+ pr_notice("quota sysctl registration failed!\n");
+ }
dquot_cachep = kmem_cache_create("dquot",
sizeof(struct dquot), sizeof(unsigned long) * 4,
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fs: quota: avoid unused function warning for !CONFIG_SYSCTL
2023-03-28 12:22 [PATCH] fs: quota: avoid unused function warning for !CONFIG_SYSCTL Arnd Bergmann
@ 2023-03-28 17:48 ` Luis Chamberlain
2023-03-29 9:44 ` Jan Kara
0 siblings, 1 reply; 3+ messages in thread
From: Luis Chamberlain @ 2023-03-28 17:48 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Jan Kara, Yangtao Li, Arnd Bergmann, Christian Brauner,
Seth Forshee, Dave Chinner, Roman Gushchin, Baokun Li,
Matthew Wilcox (Oracle),
linux-kernel
On Tue, Mar 28, 2023 at 02:22:31PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> Note: it may be better to just revert the 63d00e08515b patch, as the
> -#ifdef CONFIG_SYSCTL
> - if (!register_sysctl("fs/quota", fs_dqstats_table))
> - pr_notice("quota sysctl registration failed!\n");
> -#endif
> + if (IS_ENABLED(CONFIG_SYSCTL)) {
> + if (!register_sysctl("fs/quota", fs_dqstats_table))
> + pr_notice("quota sysctl registration failed!\n");
> + }
I'd agree to drop that patch and instead just use register_sysctl_init()
iwht Arnd's strategy.
Luis
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs: quota: avoid unused function warning for !CONFIG_SYSCTL
2023-03-28 17:48 ` Luis Chamberlain
@ 2023-03-29 9:44 ` Jan Kara
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kara @ 2023-03-29 9:44 UTC (permalink / raw)
To: Luis Chamberlain
Cc: Arnd Bergmann, Jan Kara, Yangtao Li, Arnd Bergmann,
Christian Brauner, Seth Forshee, Dave Chinner, Roman Gushchin,
Baokun Li, Matthew Wilcox (Oracle),
linux-kernel
On Tue 28-03-23 10:48:20, Luis Chamberlain wrote:
> On Tue, Mar 28, 2023 at 02:22:31PM +0200, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@arndb.de>
> > Note: it may be better to just revert the 63d00e08515b patch, as the
> > -#ifdef CONFIG_SYSCTL
> > - if (!register_sysctl("fs/quota", fs_dqstats_table))
> > - pr_notice("quota sysctl registration failed!\n");
> > -#endif
> > + if (IS_ENABLED(CONFIG_SYSCTL)) {
> > + if (!register_sysctl("fs/quota", fs_dqstats_table))
> > + pr_notice("quota sysctl registration failed!\n");
> > + }
>
> I'd agree to drop that patch and instead just use register_sysctl_init()
> iwht Arnd's strategy.
Ah, indeed, register_sysctl_init() is exactly what we need here. I didn't
know about that helper. Thanks for letting me know.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-29 9:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-28 12:22 [PATCH] fs: quota: avoid unused function warning for !CONFIG_SYSCTL Arnd Bergmann
2023-03-28 17:48 ` Luis Chamberlain
2023-03-29 9:44 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).