Code

notes: Initialise variable to appease gcc
authorRamsay Jones <ramsay@ramsay1.demon.co.uk>
Mon, 21 Jun 2010 18:52:29 +0000 (19:52 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 28 Jun 2010 17:01:26 +0000 (10:01 -0700)
gcc version 3.4.4 thinks that the 'cmp' variable could be used
while uninitialised and complains thus:

    notes.c: In function `write_each_non_note_until':
    notes.c:719: warning: 'cmp' might be used uninitialized in \
        this function

Note that gcc versions 4.1.2 and 4.4.0 do not issue this warning.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
notes.c

diff --git a/notes.c b/notes.c
index e425e198278bfb5c6a039dc88825568f1518e875..cc92cf351a5d8abb7ad2890660d484644c359dfb 100644 (file)
--- a/notes.c
+++ b/notes.c
@@ -716,7 +716,7 @@ static int write_each_non_note_until(const char *note_path,
                struct write_each_note_data *d)
 {
        struct non_note *n = d->next_non_note;
-       int cmp, ret;
+       int cmp = 0, ret;
        while (n && (!note_path || (cmp = strcmp(n->path, note_path)) <= 0)) {
                if (note_path && cmp == 0)
                        ; /* do nothing, prefer note to non-note */