From a80117c371f726545e2dcde8dd63268cd675b26d Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 12 Apr 2018 13:19:21 +0100 Subject: [PATCH] gdatetime: Fix a spurious gcc warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s possible to get a -Wmaybe-uninitialized warning out of this code with some GCC versions. Rework the code to avoid needing the conditional free. Signed-off-by: Philip Withnall https://bugzilla.gnome.org/show_bug.cgi?id=728108 --- glib/gdatetime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glib/gdatetime.c b/glib/gdatetime.c index f3ad02d86..0820e0d8b 100644 --- a/glib/gdatetime.c +++ b/glib/gdatetime.c @@ -3197,6 +3197,7 @@ g_date_time_format_locale (GDateTime *datetime, break; case 'Z': tz = g_date_time_get_timezone_abbreviation (datetime); + tmp = NULL; tmp_len = strlen (tz); if (!locale_is_utf8) { @@ -3205,8 +3206,7 @@ g_date_time_format_locale (GDateTime *datetime, return FALSE; } g_string_append_len (outstr, tz, tmp_len); - if (!locale_is_utf8) - g_free (tmp); + g_free (tmp); break; case '%': g_string_append_c (outstr, '%');