From: Michal Privoznik Date: Tue, 3 Jul 2018 14:55:01 +0000 (+0200) Subject: esx: De-duplicate @virtualMachine check in esxDomainLookupByName X-Git-Tag: v4.6.0-rc1~326 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d999b6016b4e9e39e23bb8bd043abe576305daf1;p=thirdparty%2Flibvirt.git esx: De-duplicate @virtualMachine check in esxDomainLookupByName The function call esxVI_LookupVirtualMachineByName(occurrence = OptionalItem) and then checks if @virtualMachine is NULL. If it is an error is reported. The same result can be achieved by setting occurrence to RequiredItem. Signed-off-by: Michal Privoznik --- diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index e906d11fa9..01bcc99962 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -1577,12 +1577,7 @@ esxDomainLookupByName(virConnectPtr conn, const char *name) "config.uuid\0") < 0 || esxVI_LookupVirtualMachineByName(priv->primary, name, propertyNameList, &virtualMachine, - esxVI_Occurrence_OptionalItem) < 0) { - goto cleanup; - } - - if (!virtualMachine) { - virReportError(VIR_ERR_NO_DOMAIN, _("No domain with name '%s'"), name); + esxVI_Occurrence_RequiredItem) < 0) { goto cleanup; }