Hello,
I became interested in another source code transformation again.
I would like to move a bit of common code to the end of a function
implementation
with the help of the following script for the semantic patch language.
@replacement@
expression info, result;
identifier target, work;
type t != void;
@@
t work(...)
{
<+...
if (...)
(
-{
-result = info;
goto
- target
+ e_nodev
;
-}
|
{
...
-result = info;
goto
- target
+ e_nodev
;
}
)
...+>
target:
...
return result;
+e_nodev:
+result = info;
+goto target;
}
The implementation of the function “megasas_mgmt_ioctl_fw” looks like
an update candidate.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/scsi/megaraid/megaraid_sas_base.c?id=4ae004a9bca8bef118c2b4e76ee31c7df4514f18#n7742
https://elixir.bootlin.com/linux/v5.2-rc5/source/drivers/scsi/megaraid/megaraid_sas_base.c#L7742
* I extracted it into a test source file.
Unfortunately, I stumble on the error message “replacement: already tagged
token:
C code context” then.
* If I delete a bit more source code for this example, the shown transformation
approach can work as expected.
* The complete source file seems to be very challenging for testing
the run time characteristics.
Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci