Fix some "variable might be used uninitialized" warnings
authorRamsay Jones <ramsay@ramsay1.demon.co.uk>
Sun, 11 Sep 2011 19:39:32 +0000 (20:39 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sun, 9 Oct 2011 20:28:04 +0000 (13:28 -0700)
In particular, gcc complains as follows:

        CC tree-walk.o
    tree-walk.c: In function `traverse_trees':
    tree-walk.c:347: warning: 'e' might be used uninitialized in this \
        function

        CC builtin/revert.o
    builtin/revert.c: In function `verify_opt_mutually_compatible':
    builtin/revert.c:113: warning: 'opt2' might be used uninitialized in \
        this function

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/revert.c
tree-walk.c

index ba27cf15ee5478981a0a9a53493f41b67fcf9440..200149e2e78525d34f04eb29752453561faf5d88 100644 (file)
@@ -110,7 +110,7 @@ static void verify_opt_compatible(const char *me, const char *base_opt, ...)
 
 static void verify_opt_mutually_compatible(const char *me, ...)
 {
-       const char *opt1, *opt2;
+       const char *opt1, *opt2 = NULL;
        va_list ap;
 
        va_start(ap, me);
index 808bb55ba3f21d113e6358f6874e2e20cb33bbea..a8d8a66d597f54e3a99a4c3e9615330eb7a7fe1a 100644 (file)
@@ -344,7 +344,7 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
                unsigned long mask, dirmask;
                const char *first = NULL;
                int first_len = 0;
-               struct name_entry *e;
+               struct name_entry *e = NULL;
                int len;
 
                for (i = 0; i < n; i++) {