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 --- submodule.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'submodule.c') diff --git a/submodule.c b/submodule.c index 5ace18a7d9..7797e5a4db 100644 --- a/submodule.c +++ b/submodule.c @@ -664,8 +664,7 @@ void show_submodule_diff_summary(struct diff_options *o, const char *path, print_submodule_diff_summary(sub, &rev, o); out: - if (merge_bases) - free_commit_list(merge_bases); + free_commit_list(merge_bases); clear_commit_marks(left, ~0); clear_commit_marks(right, ~0); if (sub) { @@ -754,8 +753,7 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path, done: strbuf_release(&sb); - if (merge_bases) - free_commit_list(merge_bases); + free_commit_list(merge_bases); if (left) clear_commit_marks(left, ~0); if (right) -- cgit 1.2.3-korg