[glib] gvariant: Avoid anonymous struct and union members



commit d5a16fbd2d5132b3674817a45596a40a8d7bb71d
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Thu Jul 21 12:24:38 2016 +0200

    gvariant: Avoid anonymous struct and union members
    
    C++ does not like them for various reasons.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=766370

 glib/gvariant.c |   12 ++++++------
 glib/gvariant.h |    8 ++++----
 2 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/glib/gvariant.c b/glib/gvariant.c
index 2bca953..40f58c1 100644
--- a/glib/gvariant.c
+++ b/glib/gvariant.c
@@ -3187,17 +3187,17 @@ ensure_valid_builder (GVariantBuilder *builder)
 {
   if (is_valid_builder (builder))
     return TRUE;
-  if (builder->partial_magic == GVSB_MAGIC_PARTIAL)
+  if (builder->u.s.partial_magic == GVSB_MAGIC_PARTIAL)
     {
       static GVariantBuilder cleared_builder;
 
       /* Make sure that only first two fields were set and the rest is
        * zeroed to avoid messing up the builder that had parent
        * address equal to GVSB_MAGIC_PARTIAL. */
-      if (memcmp (cleared_builder.y, builder->y, sizeof cleared_builder.y))
+      if (memcmp (cleared_builder.u.s.y, builder->u.s.y, sizeof cleared_builder.u.s.y))
         return FALSE;
 
-      g_variant_builder_init (builder, builder->type);
+      g_variant_builder_init (builder, builder->u.s.type);
     }
   return is_valid_builder (builder);
 }
@@ -3814,17 +3814,17 @@ ensure_valid_dict (GVariantDict *dict)
 {
   if (is_valid_dict (dict))
     return TRUE;
-  if (dict->partial_magic == GVSD_MAGIC_PARTIAL)
+  if (dict->u.s.partial_magic == GVSD_MAGIC_PARTIAL)
     {
       static GVariantDict cleared_dict;
 
       /* Make sure that only first two fields were set and the rest is
        * zeroed to avoid messing up the builder that had parent
        * address equal to GVSB_MAGIC_PARTIAL. */
-      if (memcmp (cleared_dict.y, dict->y, sizeof cleared_dict.y))
+      if (memcmp (cleared_dict.u.s.y, dict->u.s.y, sizeof cleared_dict.u.s.y))
         return FALSE;
 
-      g_variant_dict_init (dict, dict->asv);
+      g_variant_dict_init (dict, dict->u.s.asv);
     }
   return is_valid_dict (dict);
 }
diff --git a/glib/gvariant.h b/glib/gvariant.h
index ea45466..5ffd8fc 100644
--- a/glib/gvariant.h
+++ b/glib/gvariant.h
@@ -303,9 +303,9 @@ struct _GVariantBuilder {
       gsize partial_magic;
       const GVariantType *type;
       gsize y[14];
-    };
+    } s;
     gsize x[16];
-  };
+  } u;
 };
 
 typedef enum
@@ -442,9 +442,9 @@ struct _GVariantDict {
       GVariant *asv;
       gsize partial_magic;
       gsize y[14];
-    };
+    } s;
     gsize x[16];
-  };
+  } u;
 };
 
 /**


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