Skip to content

Commit f64c50e

Browse files
committed
cocci: strbuf.buf is never NULL
We recently noticed one old code from 19 years ago protecting against an ancient strbuf convention that the .buf member can be NULL for an empty strbuf. As that is no longer the case in the modern codebase, let's catch such a construct. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 753c810 commit f64c50e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

contrib/coccinelle/strbuf.cocci

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,10 @@ expression E1, E2;
6060
@@
6161
- strbuf_addstr(E1, real_path(E2));
6262
+ strbuf_add_real_path(E1, E2);
63+
64+
// In modern codebase, .buf member of an empty strbuf is not NULL.
65+
@@
66+
struct strbuf SB;
67+
@@
68+
- SB.buf ? SB.buf : ""
69+
+ SB.buf

0 commit comments

Comments
 (0)