Use of enum types for struct fields is generally avoided since it causes warnings if the compiler assumes the enum is unsigned. For example commit 8e2982b5767a25e5da6533c65bfdc648c95b3c69 Author: Cole Robinson <crobinso@xxxxxxxxxx> Date: Tue Jul 24 16:27:54 2018 -0400 conf: Clean up virDomainDefParseCaps Introduced a line: if ((def->virtType = virDomainVirtTypeFromString(virttype)) < 0) { which causes a build failure with CLang conf/domain_conf.c:19143:65: error: comparison of unsigned enum expression < 0 is always false [-Werror,-Wtautological-compare] as the compiler is free to optimize away the "< 0" check due to the assumption that the enum type is unsigned and always in range. Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> --- src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 2 +- src/qemu/qemu_command.c | 2 +- src/qemu/qemu_process.c | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) Pushing as a build fix for CLang diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c27c874d9e..f94a90fbcc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15075,7 +15075,7 @@ virDomainVideoDefaultRAM(const virDomainDef *def, int virDomainVideoDefaultType(const virDomainDef *def) { - switch (def->virtType) { + switch ((virDomainVirtType)def->virtType) { case VIR_DOMAIN_VIRT_TEST: case VIR_DOMAIN_VIRT_XEN: if (def->os.type == VIR_DOMAIN_OSTYPE_XEN || diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a804e86f6c..c1dfa37fdf 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2386,7 +2386,7 @@ struct _virDomainVirtioOptions { typedef struct _virDomainDef virDomainDef; typedef virDomainDef *virDomainDefPtr; struct _virDomainDef { - virDomainVirtType virtType; + int virtType; /* enum virDomainVirtType */ int id; unsigned char uuid[VIR_UUID_BUFLEN]; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ae45c45b7f..d148db90fa 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7163,7 +7163,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, virCommandAddArg(cmd, "-machine"); virBufferAdd(&buf, def->os.machine, -1); - switch (def->virtType) { + switch ((virDomainVirtType)def->virtType) { case VIR_DOMAIN_VIRT_QEMU: virBufferAddLit(&buf, ",accel=tcg"); break; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 27bd8b9465..c4e33723d1 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7191,6 +7191,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); virCapsPtr caps = NULL; bool active = false; + virDomainVirtType virtType; VIR_DEBUG("Beginning VM attach process"); @@ -7342,8 +7343,9 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, goto exit_monitor; if (qemuMonitorGetStatus(priv->mon, &running, &reason) < 0) goto exit_monitor; - if (qemuMonitorGetVirtType(priv->mon, &vm->def->virtType) < 0) + if (qemuMonitorGetVirtType(priv->mon, &virtType) < 0) goto exit_monitor; + vm->def->virtType = virtType; if (qemuDomainObjExitMonitor(driver, vm) < 0) goto error; -- 2.17.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list