]> git.ipfire.org Git - thirdparty/git.git/commitdiff
read-cache.c: initialize copy_len to shut up gcc 8
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sat, 3 Nov 2018 08:48:49 +0000 (09:48 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 5 Nov 2018 04:42:11 +0000 (13:42 +0900)
It was reported that when building with NO_PTHREADS=1,
-Wmaybe-uninitialized is triggered. Just initialize the variable from
the beginning to shut the compiler up (because this warning is enabled
in config.dev)

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
read-cache.c

index 00cd416816e7dd291fb8ce7252c919a7228bb7a6..c510f598b1958fd68c94254be4dd1d6667f14af2 100644 (file)
@@ -1746,7 +1746,7 @@ static struct cache_entry *create_from_disk(struct mem_pool *ce_mem_pool,
        size_t len;
        const char *name;
        unsigned int flags;
-       size_t copy_len;
+       size_t copy_len = 0;
        /*
         * Adjacent cache entries tend to share the leading paths, so it makes
         * sense to only store the differences in later entries.  In the v4
@@ -1786,8 +1786,6 @@ static struct cache_entry *create_from_disk(struct mem_pool *ce_mem_pool,
                                die(_("malformed name field in the index, near path '%s'"),
                                        previous_ce->name);
                        copy_len = previous_len - strip_len;
-               } else {
-                       copy_len = 0;
                }
                name = (const char *)cp;
        }