Skip to content

Commit 2b83e5f

Browse files
dyronegitster
authored andcommitted
cocci: allow padding with strbuf_addf()
A convenient way to pad strings is to use something like `strbuf_addf(&buf, "%20s", "Hello, world!")`. However, the Coccinelle rule that forbids a format `"%s"` with a constant string argument cast too wide a net, and also forbade such padding. The original rule was introduced by commit: git@28c23cd Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Teng Long <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c77859b commit 2b83e5f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

contrib/coccinelle/strbuf.cocci

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct strbuf *SBP;
4444

4545
@@
4646
expression E1, E2;
47-
format F =~ "s";
47+
format F =~ "^s$";
4848
@@
4949
- strbuf_addf(E1, "%@F@", E2);
5050
+ strbuf_addstr(E1, E2);

0 commit comments

Comments
 (0)