From b1bafda881d0ddce3ea020975f6ff7c80b55c205 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 12 Apr 2024 17:46:51 +0100 Subject: [PATCH] gvariant: Simplify GVariantType check in g_variant_format_string_scan_type() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rather than returning through `G_VARIANT_TYPE`, which scan-build doesn’t seem to fully understand ownership transfers through, just return `new` directly, and do the `is_valid()` check separately. The new code is equivalent to the old code, but squashes a scan-build false positive around leaking `dest`. (See also: the previous commit.) Signed-off-by: Philip Withnall Helps: #1767 --- glib/gvariant.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/glib/gvariant.c b/glib/gvariant.c index e67132a1a..2475cf2fe 100644 --- a/glib/gvariant.c +++ b/glib/gvariant.c @@ -4639,7 +4639,9 @@ g_variant_format_string_scan_type (const gchar *string, } new[i++] = '\0'; - return (GVariantType *) G_VARIANT_TYPE (new); + g_assert (g_variant_type_string_is_valid (new)); + + return (GVariantType *) new; } static gboolean