From a98faf997d14e5178a97bd420c4f686b570bd651 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 25 Mar 2012 14:51:25 +0200 Subject: [PATCH] mood.c: Silence gcc warning. 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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mood.c b/mood.c index 1a572cfa..f580400d 100644 --- 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}; - 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) -- 2.39.5