[PATCH] fs: quota: avoid unused function warning for !CONFIG_SYSCTL

From: Arnd Bergmann
Date: Tue Mar 28 2023 - 08:22:56 EST


From: Arnd Bergmann <arnd@xxxxxxxx>

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@xxxxxxxx>
---
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