virDomainDefMaybeAddInput() function returns an invariant result, so turn it to void. Remove all redundant check which depends on it returning value. Fixes: 98f6f2081d ("util: alloc: Reimplement VIR_APPEND_ELEMENT using virAppendElement") Signed-off-by: Artem Chernyshev <artem.chernyshev@xxxxxxxxxxx> --- src/conf/domain_conf.c | 6 ++---- src/conf/domain_conf.h | 2 +- src/libxl/libxl_domain.c | 3 +-- src/libxl/xen_common.c | 18 +++++++----------- src/libxl/xen_common.h | 2 +- src/qemu/qemu_domain.c | 33 ++++++++++++--------------------- src/vz/vz_driver.c | 23 +++++++++-------------- src/vz/vz_sdk.c | 14 ++++++-------- 8 files changed, 39 insertions(+), 62 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1ab1caba58..3a73a3ae83 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16179,7 +16179,7 @@ virDomainDefMaybeAddController(virDomainDef *def, } -int +void virDomainDefMaybeAddInput(virDomainDef *def, int type, int bus) @@ -16190,7 +16190,7 @@ virDomainDefMaybeAddInput(virDomainDef *def, for (i = 0; i < def->ninputs; i++) { if (def->inputs[i]->type == type && def->inputs[i]->bus == bus) - return 0; + return; } input = g_new0(virDomainInputDef, 1); @@ -16199,8 +16199,6 @@ virDomainDefMaybeAddInput(virDomainDef *def, input->bus = bus; VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input); - - return 0; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ffa9f74a72..cd582c19b1 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -4273,7 +4273,7 @@ virDomainDefMaybeAddController(virDomainDef *def, virDomainControllerType type, int idx, int model); -int +void virDomainDefMaybeAddInput(virDomainDef *def, int type, int bus); diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 69bac7d0ae..f8f474ebdb 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -257,8 +257,7 @@ libxlDomainDefPostParse(virDomainDef *def, } /* add implicit input devices */ - if (xenDomainDefAddImplicitInputDevice(def) < 0) - return -1; + xenDomainDefAddImplicitInputDevice(def); /* For x86_64 HVM */ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM && diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index c7bc51b926..d67a14b7df 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -2382,7 +2382,7 @@ xenFormatConfigCommon(virConf *conf, } -int +void xenDomainDefAddImplicitInputDevice(virDomainDef *def) { virDomainInputBus implicitInputBus = VIR_DOMAIN_INPUT_BUS_XEN; @@ -2390,15 +2390,11 @@ xenDomainDefAddImplicitInputDevice(virDomainDef *def) if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) implicitInputBus = VIR_DOMAIN_INPUT_BUS_PS2; - if (virDomainDefMaybeAddInput(def, - VIR_DOMAIN_INPUT_TYPE_MOUSE, - implicitInputBus) < 0) - return -1; + virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_MOUSE, + implicitInputBus); - if (virDomainDefMaybeAddInput(def, - VIR_DOMAIN_INPUT_TYPE_KBD, - implicitInputBus) < 0) - return -1; - - return 0; + virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_KBD, + implicitInputBus); } diff --git a/src/libxl/xen_common.h b/src/libxl/xen_common.h index b21046e959..86c2c337c1 100644 --- a/src/libxl/xen_common.h +++ b/src/libxl/xen_common.h @@ -66,4 +66,4 @@ int xenFormatConfigCommon(virConf *conf, char *xenMakeIPList(virNetDevIPInfo *guestIP); -int xenDomainDefAddImplicitInputDevice(virDomainDef *def); +void xenDomainDefAddImplicitInputDevice(virDomainDef *def); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ac5aefeb43..31b10afaed 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3917,22 +3917,18 @@ virXMLNamespace virQEMUDriverDomainXMLNamespace = { }; -static int +static void qemuDomainDefAddImplicitInputDevice(virDomainDef *def) { if (ARCH_IS_X86(def->os.arch)) { - if (virDomainDefMaybeAddInput(def, - VIR_DOMAIN_INPUT_TYPE_MOUSE, - VIR_DOMAIN_INPUT_BUS_PS2) < 0) - return -1; + virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_MOUSE, + VIR_DOMAIN_INPUT_BUS_PS2); - if (virDomainDefMaybeAddInput(def, - VIR_DOMAIN_INPUT_TYPE_KBD, - VIR_DOMAIN_INPUT_BUS_PS2) < 0) - return -1; + virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_KBD, + VIR_DOMAIN_INPUT_BUS_PS2); } - - return 0; } static int @@ -4122,8 +4118,7 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver, bool addITCOWatchdog = false; /* add implicit input devices */ - if (qemuDomainDefAddImplicitInputDevice(def) < 0) - return -1; + qemuDomainDefAddImplicitInputDevice(def); /* Add implicit PCI root controller if the machine has one */ switch (def->os.arch) { @@ -4320,19 +4315,15 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver, addDefaultUSBMouse = false; } - if (addDefaultUSBKBD && - def->ngraphics > 0 && + if (addDefaultUSBKBD && def->ngraphics > 0) virDomainDefMaybeAddInput(def, VIR_DOMAIN_INPUT_TYPE_KBD, - VIR_DOMAIN_INPUT_BUS_USB) < 0) - return -1; + VIR_DOMAIN_INPUT_BUS_USB); - if (addDefaultUSBMouse && - def->ngraphics > 0 && + if (addDefaultUSBMouse && def->ngraphics > 0) virDomainDefMaybeAddInput(def, VIR_DOMAIN_INPUT_TYPE_MOUSE, - VIR_DOMAIN_INPUT_BUS_USB) < 0) - return -1; + VIR_DOMAIN_INPUT_BUS_USB); if (addPanicDevice) { size_t j; diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 93f0e1bbb4..55b39d2200 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -210,26 +210,22 @@ vzConnectGetCapabilities(virConnectPtr conn) return virCapabilitiesFormatXML(privconn->driver->caps); } -static int +static void vzDomainDefAddDefaultInputDevices(virDomainDef *def) { int bus = IS_CT(def) ? VIR_DOMAIN_INPUT_BUS_PARALLELS : VIR_DOMAIN_INPUT_BUS_PS2; if (def->ngraphics == 0) - return 0; - - if (virDomainDefMaybeAddInput(def, - VIR_DOMAIN_INPUT_TYPE_MOUSE, - bus) < 0) - return -1; + return; - if (virDomainDefMaybeAddInput(def, - VIR_DOMAIN_INPUT_TYPE_KBD, - bus) < 0) - return -1; + virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_MOUSE, + bus); - return 0; + virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_KBD, + bus); } static int @@ -244,8 +240,7 @@ vzDomainDefPostParse(virDomainDef *def, def->virtType)) return -1; - if (vzDomainDefAddDefaultInputDevices(def) < 0) - return -1; + vzDomainDefAddDefaultInputDevices(def); return 0; } diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 6a15d60577..080beac351 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -1849,15 +1849,13 @@ prlsdkLoadDomain(struct _vzDriver *driver, int bus = IS_CT(def) ? VIR_DOMAIN_INPUT_BUS_PARALLELS : VIR_DOMAIN_INPUT_BUS_PS2; - if (virDomainDefMaybeAddInput(def, - VIR_DOMAIN_INPUT_TYPE_MOUSE, - bus) < 0) - return NULL; + virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_MOUSE, + bus); - if (virDomainDefMaybeAddInput(def, - VIR_DOMAIN_INPUT_TYPE_KBD, - bus) < 0) - return NULL; + virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_KBD, + bus); } if (!dom) { -- 2.43.0 _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx