[PATCH] coccinelle: merge eight rules from strbuf.cocci

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 12 Nov 2019 17:50:13 +0100

This script contained transformation rules for the semantic patch language
which used similar code.
Combine these rules by using two SmPL disjunctions so that the run time
characteristics can be nicer because of common usage of a few metavariables.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
 contrib/coccinelle/strbuf.cocci | 49 +++++++++++----------------------
 1 file changed, 16 insertions(+), 33 deletions(-)

diff --git a/contrib/coccinelle/strbuf.cocci b/contrib/coccinelle/strbuf.cocci
index d9ada69b43..b66c9bf8e3 100644
--- a/contrib/coccinelle/strbuf.cocci
+++ b/contrib/coccinelle/strbuf.cocci
@@ -1,7 +1,11 @@
-@ strbuf_addf_with_format_only @
+@replacement1@
 expression E;
 constant fmt !~ "%";
+struct strbuf SB;
+struct strbuf *SBP;
+format F =~ "s";
 @@
+(
 - strbuf_addf
 + strbuf_addstr
   (E,
@@ -11,52 +15,31 @@ constant fmt !~ "%";
   _(fmt)
 )
   );
-
-@@
-expression E;
-struct strbuf SB;
-format F =~ "s";
-@@
+|
 - strbuf_addf(E, "%@F@", SB.buf);
 + strbuf_addbuf(E, &SB);
-
-@@
-expression E;
-struct strbuf *SBP;
-format F =~ "s";
-@@
+|
 - strbuf_addf(E, "%@F@", SBP->buf);
 + strbuf_addbuf(E, SBP);
-
-@@
-expression E;
-struct strbuf SB;
-@@
+|
 - strbuf_addstr(E, SB.buf);
 + strbuf_addbuf(E, &SB);
-
-@@
-expression E;
-struct strbuf *SBP;
-@@
+|
 - strbuf_addstr(E, SBP->buf);
 + strbuf_addbuf(E, SBP);
+)

-@@
-expression E1, E2;
+@replacement2@
+expression E1, E2, E3;
 format F =~ "s";
 @@
+(
 - strbuf_addf(E1, "%@F@", E2);
 + strbuf_addstr(E1, E2);
-
-@@
-expression E1, E2, E3;
-@@
+|
 - strbuf_addstr(E1, find_unique_abbrev(E2, E3));
 + strbuf_add_unique_abbrev(E1, E2, E3);
-
-@@
-expression E1, E2;
-@@
+|
 - strbuf_addstr(E1, real_path(E2));
 + strbuf_add_real_path(E1, E2);
+)
--
2.24.0





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux