]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
mood.c: Silence gcc warning.
authorAndre Noll <maan@systemlinux.org>
Sun, 25 Mar 2012 12:51:25 +0000 (14:51 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 25 Mar 2012 15:12:55 +0000 (17:12 +0200)
The newly released gcc-4.7.0 complains about "m" being used
uninitialized in change_current_mood(). gcc is wrong, but this is
not obvious to see: In change_current_mood(), "m" is only going to
be used if load_mood() returns non-negative. This happens only on
success, when load_mood() returns 1. In this case "m" was previously
set to mlpd.m which was initialized to NULL at the top of load_mood()
and later set to the newly allocated mood structure.

This patch makes it easier for gcc by initializing "m" to NULL
upfront. This causes the warning to go away.

mood.c

diff --git a/mood.c b/mood.c
index 1a572cfa8f1859a946ea34708b48e990a036f5b2..f580400dd52bfe4d129f7526034745929b0cdf7e 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -364,8 +364,10 @@ static int load_mood(const struct osl_row *mood_row, struct mood **m)
        char *mood_name;
        struct osl_object mood_def;
        struct mood_line_parser_data mlpd = {.line_num = 0};
        char *mood_name;
        struct osl_object mood_def;
        struct mood_line_parser_data mlpd = {.line_num = 0};
-       int ret = mood_get_name_and_def_by_row(mood_row, &mood_name, &mood_def);
+       int ret;
 
 
+       *m = NULL;
+       ret = mood_get_name_and_def_by_row(mood_row, &mood_name, &mood_def);
        if (ret < 0)
                return ret;
        if (!*mood_name)
        if (ret < 0)
                return ret;
        if (!*mood_name)