diff options
| author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2022-07-05 15:46:59 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2022-07-06 12:24:43 -0700 |
| commit | 4f40f6cb7365889b262aa93871964f70c91a9ebc (patch) | |
| tree | 08640c84f6f2f5a86bbe0decd609cb140531d305 /builtin/fetch.c | |
| parent | cocci: have "coccicheck{,-pending}" depend on "coccicheck-test" (diff) | |
| download | git-4f40f6cb7365889b262aa93871964f70c91a9ebc.tar.gz git-4f40f6cb7365889b262aa93871964f70c91a9ebc.zip | |
cocci: add and apply a rule to find "unused" strbufs
Add a coccinelle rule to remove "struct strbuf" initialization
followed by calling "strbuf_release()" function, without any uses of
the strbuf in the same function.
See the tests in contrib/coccinelle/tests/unused.{c,res} for what it's
intended to find and replace.
The inclusion of "contrib/scalar/scalar.c" is because "spatch" was
manually run on it (we don't usually run spatch on contrib).
Per the "buggy code" comment we also match a strbuf_init() before the
xmalloc(), but we're not seeking to be so strict as to make checks
that the compiler will catch for us redundant. Saying we'll match
either "init" or "xmalloc" lines makes the rule simpler.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fetch.c')
| -rw-r--r-- | builtin/fetch.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c index ac29c2b1ae..8a3ae71fed 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1113,7 +1113,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name, struct fetch_head *fetch_head, struct worktree **worktrees) { int url_len, i, rc = 0; - struct strbuf note = STRBUF_INIT, err = STRBUF_INIT; + struct strbuf note = STRBUF_INIT; const char *what, *kind; struct ref *rm; char *url; @@ -1281,7 +1281,6 @@ static int store_updated_refs(const char *raw_url, const char *remote_name, abort: strbuf_release(¬e); - strbuf_release(&err); free(url); return rc; } |
