cocci: simplify check for trivial format strings
authorRené Scharfe <l.s.r@web.de>
Thu, 1 Feb 2018 18:56:34 +0000 (19:56 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 2 Feb 2018 22:30:12 +0000 (14:30 -0800)
353d84c537 (coccicheck: make transformation for strbuf_addf(sb, "...")
more precise) added a check to avoid transforming calls with format
strings which contain percent signs, as that would change the result.
It uses embedded Python code for that. Simplify this rule by using the
regular expression matching operator instead.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/coccinelle/strbuf.cocci
index 1d580e49b0ca3304ad7b3be62664df47ea84757d..ce2e92c6e95d90d490e958ddf820f44d1f51061e 100644 (file)
@@ -1,21 +1,6 @@
 @ strbuf_addf_with_format_only @
 expression E;
-constant fmt;
-@@
-  strbuf_addf(E,
-(
-  fmt
-|
-  _(fmt)
-)
-  );
-
-@ script:python @
-fmt << strbuf_addf_with_format_only.fmt;
-@@
-cocci.include_match("%" not in fmt)
-
-@ extends strbuf_addf_with_format_only @
+constant fmt !~ "%";
 @@
 - strbuf_addf
 + strbuf_addstr