From e0fe616dbc45ebf5270e788b3b344d04a1157a70 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 10 May 2022 16:29:22 +0100 Subject: [PATCH] gvariant: Factor out type check This will help static analysers, similarly to with the previous commit. This introduces no functional changes. Signed-off-by: Philip Withnall --- glib/gvariant.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/glib/gvariant.c b/glib/gvariant.c index 42ffc9a87..6384174ca 100644 --- a/glib/gvariant.c +++ b/glib/gvariant.c @@ -800,12 +800,13 @@ g_variant_new_array (const GVariantType *child_type, for (i = 0; i < n_children; i++) { - if G_UNLIKELY (!g_variant_is_of_type (children[i], child_type)) + gboolean is_of_child_type = g_variant_is_of_type (children[i], child_type); + if G_UNLIKELY (!is_of_child_type) { while (i != 0) g_variant_unref (my_children[--i]); g_free (my_children); - g_return_val_if_fail (g_variant_is_of_type (children[i], child_type), NULL); + g_return_val_if_fail (is_of_child_type, NULL); } my_children[i] = g_variant_ref_sink (children[i]); trusted &= g_variant_is_trusted (children[i]);