interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / tools / coccinelle / strbuf.cocci

86 lines · 1167 bytes Raw Blame History
1@@
2expression E;
3constant fmt !~ "%";
4@@
5- strbuf_addf
6+ strbuf_addstr
7 (E,
8(
9 fmt
10|
11 _(fmt)
12)
13 );
14
15@@
16expression E;
17struct strbuf SB;
18format F =~ "^s$";
19@@
20- strbuf_addf(E, "%@F@", SB.buf);
21+ strbuf_addbuf(E, &SB);
22
23@@
24expression E;
25struct strbuf *SBP;
26format F =~ "^s$";
27@@
28- strbuf_addf(E, "%@F@", SBP->buf);
29+ strbuf_addbuf(E, SBP);
30
31@@
32expression E;
33struct strbuf SB;
34@@
35- strbuf_addstr(E, SB.buf);
36+ strbuf_addbuf(E, &SB);
37
38@@
39expression E;
40struct strbuf *SBP;
41@@
42- strbuf_addstr(E, SBP->buf);
43+ strbuf_addbuf(E, SBP);
44
45@@
46expression E1, E2;
47format F =~ "^s$";
48@@
49- strbuf_addf(E1, "%@F@", E2);
50+ strbuf_addstr(E1, E2);
51
52@@
53expression E1, E2, E3;
54@@
55- strbuf_addstr(E1, find_unique_abbrev(E2, E3));
56+ strbuf_add_unique_abbrev(E1, E2, E3);
57
58@@
59expression E1, E2;
60@@
61- strbuf_addstr(E1, real_path(E2));
62+ strbuf_add_real_path(E1, E2);
63
64@@
65identifier fn, param;
66@@
67 fn(...,
68- struct strbuf param
69+ struct strbuf *param
70 ,...)
71 {
72 ...
73 }
74
75// In modern codebase, .buf member of an empty strbuf is not NULL.
76@@
77struct strbuf SB;
78@@
79- SB.buf ? SB.buf : ""
80+ SB.buf
81
82@@
83expression SB, OID;
84@@
85- strbuf_addstr(SB, oid_to_hex(OID))
86+ strbuf_add_oid_hex(SB, OID)