fetch: don't redundantly NULL something calloc() gave us
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 9 Feb 2018 20:32:00 +0000 (20:32 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Feb 2018 21:10:11 +0000 (13:10 -0800)
Stop redundantly NULL-ing the last element of the refs structure,
which was retrieved via calloc(), and is thus guaranteed to be
pre-NULL'd.

This code dates back to b888d61c83 ("Make fetch a builtin",
2007-09-10), where wasn't any reason to do this back then either, it's
just boilerplate left over from when git-fetch was initially
introduced.

The motivation for this change was to make a subsequent change which
would also modify the refs variable smaller, since it won't have to
copy this redundant "NULL the last + 1 item" pattern.

We may not end up keeping that change, but as this pattern is still
pointless, so let's fix it.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c
index 7bbcd26faf1fe650ccc7dbbd526db5114aac0c8f..b34665db9e407ec3cdc8ecd9badda068927dcd20 100644 (file)
@@ -1302,7 +1302,6 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
                        } else
                                refs[j++] = argv[i];
                }
-               refs[j] = NULL;
                ref_nr = j;
        }