]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
build: avoid type-punning in vbox
authorEric Blake <eblake@redhat.com>
Thu, 19 Apr 2012 23:19:32 +0000 (17:19 -0600)
committerEric Blake <eblake@redhat.com>
Thu, 19 Apr 2012 23:19:32 +0000 (17:19 -0600)
Commit 78345c68 makes at least gcc 4.1.2 on RHEL 5 complain:

cc1: warnings being treated as errors
In file included from vbox/vbox_V4_0.c:13:
vbox/vbox_tmpl.c: In function 'vboxDomainUndefineFlags':
vbox/vbox_tmpl.c:5298: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

* src/vbox/vbox_tmpl.c (vboxDomainUndefineFlags): Use union to
avoid compiler warning.

src/vbox/vbox_tmpl.c

index be25828f7bddd017341fa43c7ec8ad47792af54c..57c18a432ec716b1d0ea2059c575f6a6ac6963c9 100644 (file)
@@ -5294,8 +5294,11 @@ vboxDomainUndefineFlags(virDomainPtr dom, unsigned int flags)
 
         ((IMachine_Delete)machine->vtbl->Delete)(machine, &safeArray, &progress);
 # else
-        vboxArray array = VBOX_ARRAY_INITIALIZER;
-        machine->vtbl->Delete(machine, 0, (IMedium**)&array, &progress);
+        union {
+            vboxArray array;
+            IMedium *medium;
+        } u = { .array = VBOX_ARRAY_INITIALIZER };
+        machine->vtbl->Delete(machine, 0, &u.medium, &progress);
 # endif
         if (progress != NULL) {
             progress->vtbl->WaitForCompletion(progress, -1);