fs: quota: avoid unused function warning for !CONFIG_SYSCTL
PATCH 1/1 fs: quota: avoid unused function warning for !CONFIG_SYSCTL
From: Arnd Bergmann <[email protected]>
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.
---
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(-)
fs/quota/dquot.c +4 -6
@@ -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_SYSCTLstatic 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,
Signature · 1 line
2.39.2
fs/quota/dquot.c static int __init dquot_init(void) · line 2959
Quoted 10 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Note: it may be better to just revert the63d00e08515bpatch, as thefs/quota/dquot.c +4
-4-#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
Quoted 14 lines · Luis Chamberlain
fs/quota/dquot.c static int __init dquot_init(void) · line 2959
Quoted 10 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Note: it may be better to just revert the63d00e08515bpatch, as thefs/quota/dquot.c +4
-4-#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
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR