Add and apply coccinelle rules to remove "if (E)" before
"free_commit_list(E)", the function can accept NULL, and further
change cases where "E = NULL" followed to also be unconditionally.
The code changes in this commit were entirely made by the coccinelle
rule being added here, and applied with:
make contrib/coccinelle/free.cocci.patch
patch -p1 <contrib/coccinelle/free.cocci.patch
The only manual intervention here is that the the relevant code in
commit.c has been manually re-indented.
Suggested-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
46 lines
362 B
Plaintext
46 lines
362 B
Plaintext
@@
|
|
expression E;
|
|
@@
|
|
- if (E)
|
|
(
|
|
free(E);
|
|
|
|
|
free_commit_list(E);
|
|
)
|
|
|
|
@@
|
|
expression E;
|
|
@@
|
|
- if (!E)
|
|
(
|
|
free(E);
|
|
|
|
|
free_commit_list(E);
|
|
)
|
|
|
|
@@
|
|
expression E;
|
|
@@
|
|
- free(E);
|
|
+ FREE_AND_NULL(E);
|
|
- E = NULL;
|
|
|
|
@@
|
|
expression E;
|
|
@@
|
|
- if (E)
|
|
- {
|
|
free_commit_list(E);
|
|
E = NULL;
|
|
- }
|
|
|
|
@@
|
|
expression E;
|
|
statement S;
|
|
@@
|
|
- if (E) {
|
|
+ if (E)
|
|
S
|
|
free_commit_list(E);
|
|
- }
|