[PATCH] esx: Avoid warnings about breaking strict-aliasing rules on FreeBSD

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

 



---
 src/esx/esx_vi_generator.py |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index c2f7044..01636aa 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -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
 
-- 
1.7.0.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]