From 057f0fcbfba3b7c4e4b8730154bad9e5118a3ef8 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 12 Apr 2024 15:56:07 +0100 Subject: [PATCH] gdatetime: Fix a maybe-uninitialized warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scan-build thinks that `tmp` can be dereferenced before it’s all been assigned to. I don’t think that’s the case, because the number of elements in it which have been assigned to is tracked as `i`. But static analysers find that kind of state tracking hard to reason about, so let’s just zero-initialise the array to simplify things. Signed-off-by: Philip Withnall Helps: #1767 --- glib/gdatetime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glib/gdatetime.c b/glib/gdatetime.c index 702a77c51..870edc124 100644 --- a/glib/gdatetime.c +++ b/glib/gdatetime.c @@ -3104,7 +3104,7 @@ format_number (GString *str, "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; const gchar * const *digits = ascii_digits; - const gchar *tmp[10]; + const gchar *tmp[10] = { '\0', }; gint i = 0; #ifdef HAVE_LANGINFO_OUTDIGIT static GMutex alt_digits_mutex;