OSDN Git Service

coccinelle: make use of the "expression" FREE_AND_NULL() rule
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Thu, 15 Jun 2017 23:15:48 +0000 (23:15 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Jun 2017 19:44:07 +0000 (12:44 -0700)
A follow-up to the existing "expression" rule added in an earlier
change. This manually excludes a few occurrences, mostly things that
resulted in many FREE_AND_NULL() on one line, that'll be manually
fixed in a subsequent change.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
blame.c
ll-merge.c

diff --git a/blame.c b/blame.c
index 843c845..1183943 100644 (file)
--- a/blame.c
+++ b/blame.c
@@ -314,8 +314,7 @@ static void fill_origin_blob(struct diff_options *opt,
 static void drop_origin_blob(struct blame_origin *o)
 {
        if (o->file.ptr) {
-               free(o->file.ptr);
-               o->file.ptr = NULL;
+               FREE_AND_NULL(o->file.ptr);
        }
 }
 
index ac0d4a5..91ff519 100644 (file)
@@ -209,8 +209,7 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
        result->size = st.st_size;
        result->ptr = xmallocz(result->size);
        if (read_in_full(fd, result->ptr, result->size) != result->size) {
-               free(result->ptr);
-               result->ptr = NULL;
+               FREE_AND_NULL(result->ptr);
                result->size = 0;
        }
  close_bad: