[libvirt] [PATCH v2] qemu: Fix compilation error when enum variable size differs from 'int'

Since commit bcd9a564b631aa virDomainNumatuneGetMode returns the value via a pointer rather than in the return value. The change triggered problems with platforms where the compiler decides to use a data type of size different than integer at the point where we typecast it. Work around the issue by using an intermediate variable of the correct type that gets casted back by the default typecasting rules. --- Version 2: - removed block from the case statement - added ignore value section to silence coverity and initialized the temp variable src/qemu/qemu_driver.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index aa0acde..1233d8f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10524,6 +10524,7 @@ qemuDomainGetNumaParameters(virDomainPtr dom, size_t i; virDomainObjPtr vm = NULL; virDomainDefPtr persistentDef = NULL; + virDomainNumatuneMemMode tmpmode = VIR_DOMAIN_NUMATUNE_MEM_STRICT; char *nodeset = NULL; int ret = -1; virCapsPtr caps = NULL; @@ -10567,12 +10568,12 @@ qemuDomainGetNumaParameters(virDomainPtr dom, switch (i) { case 0: /* fill numa mode here */ + ignore_value(virDomainNumatuneGetMode(def->numa, -1, &tmpmode)); + if (virTypedParameterAssign(param, VIR_DOMAIN_NUMA_MODE, - VIR_TYPED_PARAM_INT, 0) < 0) + VIR_TYPED_PARAM_INT, tmpmode) < 0) goto cleanup; - virDomainNumatuneGetMode(def->numa, -1, - (virDomainNumatuneMemMode *) ¶m->value.i); break; case 1: /* fill numa nodeset here */ -- 2.4.1

On 05/26/2015 02:31 AM, Peter Krempa wrote:
Since commit bcd9a564b631aa virDomainNumatuneGetMode returns the value via a pointer rather than in the return value. The change triggered problems with platforms where the compiler decides to use a data type of size different than integer at the point where we typecast it.
Work around the issue by using an intermediate variable of the correct type that gets casted back by the default typecasting rules. --- Version 2: - removed block from the case statement - added ignore value section to silence coverity and initialized the temp variable
src/qemu/qemu_driver.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
ACK -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Tue, May 26, 2015 at 09:04:09 -0600, Eric Blake wrote:
On 05/26/2015 02:31 AM, Peter Krempa wrote:
Since commit bcd9a564b631aa virDomainNumatuneGetMode returns the value via a pointer rather than in the return value. The change triggered problems with platforms where the compiler decides to use a data type of size different than integer at the point where we typecast it.
Work around the issue by using an intermediate variable of the correct type that gets casted back by the default typecasting rules. --- Version 2: - removed block from the case statement - added ignore value section to silence coverity and initialized the temp variable
src/qemu/qemu_driver.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
ACK
Pushed; Thanks. Peter
participants (2)
-
Eric Blake
-
Peter Krempa