]> xenbits.xensource.com Git - libvirt.git/commitdiff
esx: Avoid warnings about breaking strict-aliasing rules on FreeBSD
authorMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 13 Nov 2010 13:32:06 +0000 (14:32 +0100)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Sun, 14 Nov 2010 21:44:04 +0000 (22:44 +0100)
src/esx/esx_vi_generator.py

index c2f7044a3b0c87e32e5edb07a9d1d60160865b95..01636aa6f1f743ffe49b0a0053133888e2a4a1da 100755 (executable)
@@ -699,7 +699,10 @@ class Object:
 
             if self.features & Object.FEATURE__LIST:
                 if self.extends is not None:
-                    source += "    esxVI_%s_Free((esxVI_%s **)&item->_next);\n\n" % (self.extends, self.extends)
+                    # avoid "dereferencing type-punned pointer will break strict-aliasing rules" warnings
+                    source += "    esxVI_%s *next = (esxVI_%s *)item->_next;\n\n" % (self.extends, self.extends)
+                    source += "    esxVI_%s_Free(&next);\n" % self.extends
+                    source += "    item->_next = (esxVI_%s *)next;\n\n" % self.name
                 else:
                     source += "    esxVI_%s_Free(&item->_next);\n\n" % self.name
 
@@ -719,7 +722,10 @@ class Object:
 
             if self.features & Object.FEATURE__LIST:
                 if self.extends is not None:
-                    source += "    esxVI_%s_Free((esxVI_%s **)&item->_next);\n\n" % (self.extends, self.extends)
+                    # avoid "dereferencing type-punned pointer will break strict-aliasing rules" warnings
+                    source += "    esxVI_%s *next = (esxVI_%s *)item->_next;\n\n" % (self.extends, self.extends)
+                    source += "    esxVI_%s_Free(&next);\n" % self.extends
+                    source += "    item->_next = (esxVI_%s *)next;\n\n" % self.name
                 else:
                     source += "    esxVI_%s_Free(&item->_next);\n\n" % self.name