Luis Chamberlain
ad8f74315b
cdrom: simplify subdirectory registration with register_sysctl()
...
There is no need to user boiler plate code to specify a set of base
directories we're going to stuff sysctls under. Simplify this by using
register_sysctl() and specifying the directory path directly.
// pycocci sysctl-subdir-register-sysctl-simplify.cocci PATH
@c1@
expression E1;
identifier subdir, sysctls;
@@
static struct ctl_table subdir[] = {
{
.procname = E1,
.maxlen = 0,
.mode = 0555,
.child = sysctls,
},
{ }
};
@c2@
identifier c1.subdir;
expression E2;
identifier base;
@@
static struct ctl_table base[] = {
{
.procname = E2,
.maxlen = 0,
.mode = 0555,
.child = subdir,
},
{ }
};
@c3@
identifier c2.base;
identifier header;
@@
header = register_sysctl_table(base);
@r1 depends on c1 && c2 && c3@
expression c1.E1;
identifier c1.subdir, c1.sysctls;
@@
-static struct ctl_table subdir[] = {
- {
- .procname = E1,
- .maxlen = 0,
- .mode = 0555,
- .child = sysctls,
- },
- { }
-};
@r2 depends on c1 && c2 && c3@
identifier c1.subdir;
expression c2.E2;
identifier c2.base;
@@
-static struct ctl_table base[] = {
- {
- .procname = E2,
- .maxlen = 0,
- .mode = 0555,
- .child = subdir,
- },
- { }
-};
@initialize:python@
@@
def make_my_fresh_expression(s1, s2):
return '"' + s1.strip('"') + "/" + s2.strip('"') + '"'
@r3 depends on c1 && c2 && c3@
expression c1.E1;
identifier c1.sysctls;
expression c2.E2;
identifier c2.base;
identifier c3.header;
fresh identifier E3 = script:python(E2, E1) { make_my_fresh_expression(E2, E1) };
@@
header =
-register_sysctl_table(base);
+register_sysctl(E3, sysctls);
Generated-by: Coccinelle SmPL
Link: https://lkml.kernel.org/r/20211123202422.819032-8-mcgrof@kernel.org
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Antti Palosaari <crope@iki.fi>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Benjamin LaHaise <bcrl@kvack.org>
Cc: Clemens Ladisch <clemens@ladisch.de>
Cc: David Airlie <airlied@linux.ie>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Iurii Zaikin <yzaikin@google.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Julia Lawall <julia.lawall@inria.fr>
Cc: Kees Cook <keescook@chromium.org>
Cc: Lukas Middendorf <kernel@tuxforce.de>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Paul Turner <pjt@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Phillip Potter <phil@philpotter.co.uk>
Cc: Qing Wang <wangqing@vivo.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Stephen Kitt <steve@sk2.org>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Xiaoming Ni <nixiaoming@huawei.com>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Cc: James E.J. Bottomley <jejb@linux.ibm.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: John Ogness <john.ogness@linutronix.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-01-22 08:33:35 +02:00
..
2022-01-14 16:02:28 +01:00
2022-01-19 11:15:19 +02:00
2022-01-03 13:44:38 +01:00
2022-01-14 15:17:17 +09:00
2022-01-13 12:50:48 +00:00
2022-01-21 13:13:35 +02:00
2022-01-21 16:17:03 +02:00
2022-01-18 10:05:48 +02:00
2022-01-16 08:08:11 +02:00
2022-01-22 08:33:35 +02:00
2022-01-22 08:33:34 +02:00
2022-01-21 09:16:11 +02:00
2022-01-10 13:53:16 +01:00
2022-01-06 15:51:13 +01:00
2022-01-06 18:31:33 +01:00
2022-01-05 18:31:17 +01:00
2022-01-18 10:05:48 +02:00
2022-01-04 17:29:31 -08:00
2022-01-15 20:37:06 +02:00
2022-01-18 14:03:34 +02:00
2022-01-16 06:52:38 +02:00
2022-01-10 11:45:23 -08:00
2022-01-18 10:05:48 +02:00
2022-01-20 17:38:23 +02:00
2022-01-22 08:33:34 +02:00
2022-01-21 15:10:02 +01:00
2022-01-16 15:53:00 +02:00
2022-01-09 17:10:58 -08:00
2022-01-18 10:05:48 +02:00
2022-01-13 02:05:50 +01:00
2022-01-18 09:13:30 +02:00
2022-01-20 10:41:01 +02:00
2022-01-17 08:27:55 +02:00
2022-01-18 10:05:48 +02:00
2022-01-13 09:05:29 -08:00
2021-12-30 12:12:12 -08:00
2022-01-12 16:59:22 -08:00
2022-01-22 08:33:35 +02:00
2022-01-13 11:19:07 -08:00
2022-01-12 15:46:11 -08:00
2022-01-10 15:56:50 +01:00
2022-01-11 11:35:28 -08:00
2022-01-12 11:11:34 -08:00
2022-01-16 08:08:11 +02:00
2022-01-18 09:13:30 +02:00
2022-01-14 15:08:36 +01:00
2022-01-20 10:57:05 +02:00
2022-01-12 14:17:45 +00:00
2022-01-17 08:14:18 +02:00
2022-01-18 10:05:48 +02:00
2022-01-12 10:35:23 -08:00
2022-01-15 20:37:06 +02:00
2022-01-07 01:29:22 +01:00
2022-01-16 08:08:11 +02:00
2022-01-16 08:08:11 +02:00
2022-01-13 09:05:29 -08:00
2022-01-14 16:02:28 +01:00
2022-01-12 10:56:08 -08:00
2022-01-14 15:08:36 +01:00
2022-01-11 11:26:57 -08:00
2021-12-27 16:51:12 +01:00
2022-01-06 12:18:08 +00:00
2022-01-20 13:25:01 +02:00
2022-01-07 13:36:35 +00:00
2022-01-03 11:40:45 -07:00
2022-01-10 08:32:37 -08:00
2022-01-18 10:05:48 +02:00
2022-01-16 23:50:34 +01:00
2022-01-12 15:46:11 -08:00
2022-01-18 10:05:48 +02:00
2022-01-14 16:02:28 +01:00
2022-01-14 16:02:28 +01:00
2022-01-14 14:55:38 +01:00
2022-01-17 05:49:30 +02:00
2022-01-10 08:13:52 -08:00
2022-01-10 20:43:54 -08:00
2021-12-28 10:43:56 +03:00
2022-01-14 14:55:38 +01:00
2021-12-29 10:54:50 +01:00
2022-01-17 05:49:30 +02:00
2022-01-18 10:05:48 +02:00
2022-01-20 13:31:46 +02:00
2022-01-14 18:50:54 -05:00
2022-01-16 06:52:38 +02:00
2022-01-03 13:44:38 +01:00
2022-01-14 18:50:53 -05:00
2022-01-17 08:07:57 +02:00
2022-01-06 09:53:41 +01:00