Skip to content

Commit ae239fc

Browse files
rscharfegitster
authored andcommitted
cocci: simplify check for trivial format strings
353d84c (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>
1 parent 8279ed0 commit ae239fc

1 file changed

Lines changed: 1 addition & 16 deletions

File tree

contrib/coccinelle/strbuf.cocci

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
@ strbuf_addf_with_format_only @
22
expression E;
3-
constant fmt;
4-
@@
5-
strbuf_addf(E,
6-
(
7-
fmt
8-
|
9-
_(fmt)
10-
)
11-
);
12-
13-
@ script:python @
14-
fmt << strbuf_addf_with_format_only.fmt;
15-
@@
16-
cocci.include_match("%" not in fmt)
17-
18-
@ extends strbuf_addf_with_format_only @
3+
constant fmt !~ "%";
194
@@
205
- strbuf_addf
216
+ strbuf_addstr

0 commit comments

Comments
 (0)