cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] Moving exception handling code to the end of a function implementation with SmPL?
@ 2019-06-21 17:45 Markus Elfring
  2019-06-27  8:33 ` Markus Elfring
  2019-10-31 12:27 ` Markus Elfring
  0 siblings, 2 replies; 17+ messages in thread
From: Markus Elfring @ 2019-06-21 17:45 UTC (permalink / raw)
  To: Coccinelle

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
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2019-11-01 16:12 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-21 17:45 [Cocci] Moving exception handling code to the end of a function implementation with SmPL? Markus Elfring
2019-06-27  8:33 ` Markus Elfring
2019-06-27 11:33   ` Julia Lawall
2019-06-27 12:18     ` Markus Elfring
     [not found]       ` <alpine.DEB.2.21.1906271427250.2627@hadrien>
2019-06-27 12:45         ` Markus Elfring
2019-06-27 14:12         ` Markus Elfring
2019-06-27 14:54           ` Julia Lawall
2019-06-27 15:01             ` Markus Elfring
2019-10-31 12:27 ` Markus Elfring
2019-10-31 12:42   ` Julia Lawall
2019-10-31 13:50     ` Markus Elfring
2019-11-01  9:12   ` [Cocci] Checking the occurrence of trailing spaces in a semantic patch Markus Elfring
2019-11-01  9:38     ` Julia Lawall
2019-11-01  9:56       ` Markus Elfring
2019-11-01 11:50       ` Markus Elfring
2019-11-01 16:03       ` [Cocci] Checking code layout for adding jump targets with SmPL Markus Elfring
2019-11-01 16:12         ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).