[<prev] [next>] [day] [month] [year] [list]
Message-ID: <481faa1d-7171-4657-8dc0-c37b153e6eaa@web.de>
Date: Mon, 23 Jun 2025 10:05:15 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: cocci@...ia.fr, kernel-janitors@...r.kernel.org
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: Re: Passing code replacements by APIs (for SmPL)?
> Desirable source code adjustments can also be generated into SmPL script variants.
Will any more software users get further development ideas from an SmPL script
like the following?
// See also:
// https://elixir.bootlin.com/linux/v6.16-rc2/source/include/uapi/linux/usb/ch9.h#L472-L678
@initialize:python@
@@
import sys
x = {}
def store_data(action, input, code):
"""Add information to an internal data structure."""
x[code] = (action, input)
@find@
expression e;
identifier action, input;
type input_type, return_type != void;
@@
static inline return_type action(input_type input)
{
return e;
}
@script:python collection@
action << find.action;
input << find.input;
code << find.e;
@@
store_data(action, input, code)
@finalize:python@
@@
if x:
sys.stdout.write("@replacements@\nconst struct usb_endpoint_descriptor *epd;\n@@\n(\n")
sys.stdout.write("|\n".join("-{}\n+{}({})\n".format(key, value[0], value[1])
for key, value in x.items()))
sys.stdout.write(")\n")
else:
sys.stderr.write("No result for this analysis!\n")
Would you become interested to convert contents from any header (or source) files
into more advanced transformation approaches?
Regards,
Markus
Powered by blists - more mailing lists