[glib: 4/5] gvariant: Factor out type check




commit e0fe616dbc45ebf5270e788b3b344d04a1157a70
Author: Philip Withnall <pwithnall endlessos org>
Date:   Tue May 10 16:29:22 2022 +0100

    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 <pwithnall endlessos org>

 glib/gvariant.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/glib/gvariant.c b/glib/gvariant.c
index 42ffc9a873..6384174ca7 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]);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]