From bf20fe4ca8c8d2ba2087c9c44b4ee09a1d1467ed Mon Sep 17 00:00:00 2001 From: Ævar Arnfjörð Bjarmason Date: Wed, 13 Apr 2022 22:01:34 +0200 Subject: cocci: add and apply free_commit_list() rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/rev-list.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'builtin') diff --git a/builtin/rev-list.c b/builtin/rev-list.c index 572da1472e..07c0ad11d8 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -213,10 +213,8 @@ static void show_commit(struct commit *commit, void *data) static void finish_commit(struct commit *commit) { - if (commit->parents) { - free_commit_list(commit->parents); - commit->parents = NULL; - } + free_commit_list(commit->parents); + commit->parents = NULL; free_commit_buffer(the_repository->parsed_objects, commit); } -- cgit v1.3-5-g9baa