* Re: Passing code replacements by APIs (for SmPL)? [not found] <2dc257b4-d310-47dd-90ea-9b081727be2a@web.de> @ 2025-06-23 8:05 ` Markus Elfring 2025-06-26 11:18 ` Markus Elfring 0 siblings, 1 reply; 2+ messages in thread From: Markus Elfring @ 2025-06-23 8:05 UTC (permalink / raw) To: cocci, kernel-janitors; +Cc: LKML > 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 ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Passing code replacements by APIs (for SmPL)? 2025-06-23 8:05 ` Passing code replacements by APIs (for SmPL)? Markus Elfring @ 2025-06-26 11:18 ` Markus Elfring 0 siblings, 0 replies; 2+ messages in thread From: Markus Elfring @ 2025-06-26 11:18 UTC (permalink / raw) To: cocci, kernel-janitors; +Cc: LKML > Would you become interested to convert contents from any header (or source) files > into more advanced transformation approaches? I demonstrated that expressions can be extracted from selected function implementations also by the means of the semantic patch language. https://lore.kernel.org/cocci/481faa1d-7171-4657-8dc0-c37b153e6eaa@web.de/ https://sympa.inria.fr/sympa/arc/cocci/2025-06/msg00044.html Now I am looking again for further software extension possibilities. 1. I would like to sort found expressions by decreasing complexity. 2. Some expressions will probably refer to known function (or macro) calls. How can corresponding identifiers be replaced by previously determined source code? Regards, Markus ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-26 11:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <2dc257b4-d310-47dd-90ea-9b081727be2a@web.de>
2025-06-23 8:05 ` Passing code replacements by APIs (for SmPL)? Markus Elfring
2025-06-26 11:18 ` Markus Elfring
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox