d1ed09
From 64b76c7ca5cf5b4ede2f4b423114f46141890e1e Mon Sep 17 00:00:00 2001
d1ed09
From: Robert Ancell <robert.ancell@canonical.com>
d1ed09
Date: Fri, 7 Sep 2018 10:19:05 +1200
d1ed09
Subject: [PATCH] codegen: Change pointer casting to remove type-punning
d1ed09
 warnings
d1ed09
d1ed09
The existing code was generating code with undefined results that modern compilers warn about:
d1ed09
d1ed09
accounts-generated.c:204:23: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
d1ed09
     (GDBusArgInfo **) &_accounts_accounts_method_info_list_cached_users_OUT_ARG_pointers,
d1ed09
---
d1ed09
 gio/gdbus-2.0/codegen/codegen.py | 22 +++++++++++-----------
d1ed09
 1 file changed, 11 insertions(+), 11 deletions(-)
d1ed09
d1ed09
diff --git a/gio/gdbus-2.0/codegen/codegen.py b/gio/gdbus-2.0/codegen/codegen.py
d1ed09
index e74131cdb..0d95cdcda 100644
d1ed09
--- a/gio/gdbus-2.0/codegen/codegen.py
d1ed09
+++ b/gio/gdbus-2.0/codegen/codegen.py
d1ed09
@@ -1129,10 +1129,10 @@ class CodeGenerator:
d1ed09
                                '\n')
d1ed09
 
d1ed09
         if len(args) > 0:
d1ed09
-            self.outfile.write('static const _ExtendedGDBusArgInfo * const %s_pointers[] =\n'
d1ed09
+            self.outfile.write('static const GDBusArgInfo * const %s_pointers[] =\n'
d1ed09
                              '{\n'%(prefix))
d1ed09
             for a in args:
d1ed09
-                self.outfile.write('  &%s_%s,\n'%(prefix, a.name))
d1ed09
+                self.outfile.write('  &%s_%s.parent_struct,\n'%(prefix, a.name))
d1ed09
             self.outfile.write('  NULL\n'
d1ed09
                                '};\n'
d1ed09
                                '\n')
d1ed09
@@ -1175,10 +1175,10 @@ class CodeGenerator:
d1ed09
                     self.outfile.write('};\n'
d1ed09
                                        '\n')
d1ed09
 
d1ed09
-                self.outfile.write('static const _ExtendedGDBusMethodInfo * const _%s_method_info_pointers[] =\n'
d1ed09
+                self.outfile.write('static const GDBusMethodInfo * const _%s_method_info_pointers[] =\n'
d1ed09
                                    '{\n'%(i.name_lower))
d1ed09
                 for m in i.methods:
d1ed09
-                    self.outfile.write('  &_%s_method_info_%s,\n'%(i.name_lower, m.name_lower))
d1ed09
+                    self.outfile.write('  &_%s_method_info_%s.parent_struct,\n'%(i.name_lower, m.name_lower))
d1ed09
                 self.outfile.write('  NULL\n'
d1ed09
                                    '};\n'
d1ed09
                                    '\n')
d1ed09
@@ -1209,10 +1209,10 @@ class CodeGenerator:
d1ed09
                     self.outfile.write('};\n'
d1ed09
                                        '\n')
d1ed09
 
d1ed09
-                self.outfile.write('static const _ExtendedGDBusSignalInfo * const _%s_signal_info_pointers[] =\n'
d1ed09
+                self.outfile.write('static const GDBusSignalInfo * const _%s_signal_info_pointers[] =\n'
d1ed09
                                    '{\n'%(i.name_lower))
d1ed09
                 for s in i.signals:
d1ed09
-                    self.outfile.write('  &_%s_signal_info_%s,\n'%(i.name_lower, s.name_lower))
d1ed09
+                    self.outfile.write('  &_%s_signal_info_%s.parent_struct,\n'%(i.name_lower, s.name_lower))
d1ed09
                 self.outfile.write('  NULL\n'
d1ed09
                                    '};\n'
d1ed09
                                    '\n')
d1ed09
@@ -1251,10 +1251,10 @@ class CodeGenerator:
d1ed09
                     self.outfile.write('};\n'
d1ed09
                                        '\n')
d1ed09
 
d1ed09
-                self.outfile.write('static const _ExtendedGDBusPropertyInfo * const _%s_property_info_pointers[] =\n'
d1ed09
+                self.outfile.write('static const GDBusPropertyInfo * const _%s_property_info_pointers[] =\n'
d1ed09
                                    '{\n'%(i.name_lower))
d1ed09
                 for p in i.properties:
d1ed09
-                    self.outfile.write('  &_%s_property_info_%s,\n'%(i.name_lower, p.name_lower))
d1ed09
+                    self.outfile.write('  &_%s_property_info_%s.parent_struct,\n'%(i.name_lower, p.name_lower))
d1ed09
                 self.outfile.write('  NULL\n'
d1ed09
                                    '};\n'
d1ed09
                                    '\n')
d1ed09
@@ -1948,7 +1948,7 @@ class CodeGenerator:
d1ed09
             self.outfile.write('  const _ExtendedGDBusPropertyInfo *info;\n'
d1ed09
                                '  GVariant *variant;\n'
d1ed09
                                '  g_assert (prop_id != 0 && prop_id - 1 < %d);\n'
d1ed09
-                               '  info = _%s_property_info_pointers[prop_id - 1];\n'
d1ed09
+                               '  info = (const _ExtendedGDBusPropertyInfo *) _%s_property_info_pointers[prop_id - 1];\n'
d1ed09
                                '  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name);\n'
d1ed09
                                '  if (info->use_gvariant)\n'
d1ed09
                                '    {\n'
d1ed09
@@ -2001,7 +2001,7 @@ class CodeGenerator:
d1ed09
             self.outfile.write('  const _ExtendedGDBusPropertyInfo *info;\n'
d1ed09
                                '  GVariant *variant;\n'
d1ed09
                                '  g_assert (prop_id != 0 && prop_id - 1 < %d);\n'
d1ed09
-                               '  info = _%s_property_info_pointers[prop_id - 1];\n'
d1ed09
+                               '  info = (const _ExtendedGDBusPropertyInfo *) _%s_property_info_pointers[prop_id - 1];\n'
d1ed09
                                '  variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature));\n'
d1ed09
                                '  g_dbus_proxy_call (G_DBUS_PROXY (object),\n'
d1ed09
                                '    "org.freedesktop.DBus.Properties.Set",\n'
d1ed09
@@ -2887,7 +2887,7 @@ class CodeGenerator:
d1ed09
                                '  if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1]))\n'
d1ed09
                                '    {\n'
d1ed09
                                '      if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL)\n'
d1ed09
-                               '        _%s_schedule_emit_changed (skeleton, _%s_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]);\n'
d1ed09
+                               '        _%s_schedule_emit_changed (skeleton, (const _ExtendedGDBusPropertyInfo *) _%s_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]);\n'
d1ed09
                                '      g_value_copy (value, &skeleton->priv->properties[prop_id - 1]);\n'
d1ed09
                                '      g_object_notify_by_pspec (object, pspec);\n'
d1ed09
                                '    }\n'
d1ed09
-- 
d1ed09
2.19.1
d1ed09