Re: [PATCH v2] char: misc: add missing #ifdef CONFIG_PROC_FS

0 views
Skip to first unread message

zhangjiao2

unread,
4:37 AM (4 hours ago) 4:37 AM
to ar...@arndb.de, gre...@linuxfoundation.org, linux-...@vger.kernel.org, tri...@kernel.org, Zhang Jiao
From: Zhang Jiao <zhang...@cmss.chinamobile.com>

Since misc_seq_ops is defined under CONFIG_PROC_FS in this file,
it also need under CONFIG_PROC_FS when use.

v1->v2: not check proc_creat_seq returns

Signed-off-by: Zhang Jiao <zhang...@cmss.chinamobile.com>
---
drivers/char/misc.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 541edc26ec89..e1e8cd09c34a 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -286,9 +286,11 @@ EXPORT_SYMBOL(misc_deregister);
static int __init misc_init(void)
{
int err;
+#ifdef CONFIG_PROC_FS
struct proc_dir_entry *ret;

ret = proc_create_seq("misc", 0, NULL, &misc_seq_ops);
+#endif
err = class_register(&misc_class);
if (err)
goto fail_remove;
@@ -302,8 +304,10 @@ static int __init misc_init(void)
pr_err("unable to get major %d for misc devices\n", MISC_MAJOR);
class_unregister(&misc_class);
fail_remove:
+#ifdef CONFIG_PROC_FS
if (ret)
remove_proc_entry("misc", NULL);
+#endif
return err;
}
subsys_initcall(misc_init);
--
2.33.0




zhangjiao2

unread,
5:04 AM (3 hours ago) 5:04 AM
to gre...@linuxfoundation.org, ar...@arndb.de, linux-...@vger.kernel.org, tri...@kernel.org, Zhang Jiao
From: Zhang Jiao <zhang...@cmss.chinamobile.com>

Since misc_seq_ops is defined under CONFIG_PROC_FS in this file,
it also need under CONFIG_PROC_FS when use.

>Again, why is a #ifdef ok in this .c file? What changed to suddenly
>require this?
There is another #ifdef in this file, in there "misc_seq_ops" is defined.
If CONFIG_PROC_FS is not defined, proc_create_seq is using an
undefined variable "misc_seq_ops", this may cause compile error.
Reply all
Reply to author
Forward
0 new messages