]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
esx_vi.c: Simplify error handling in MachineByName
authorMarcos Paulo de Souza <marcos.souza.org@gmail.com>
Tue, 3 Jul 2018 02:20:58 +0000 (23:20 -0300)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 3 Jul 2018 09:26:28 +0000 (11:26 +0200)
The same pattern is used in lots of other places.
Also, reporting error message is not desired because all callers
check the return value and report errors on their own.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/esx/esx_vi.c

index 43ff7ea0488d92349f29e04162ef3783ae6e007a..0bdfc5a8bec6175a70bf7a5429a59bcf418fc71e 100644 (file)
@@ -3014,17 +3014,8 @@ esxVI_LookupVirtualMachineByName(esxVI_Context *ctx, const char *name,
         break;
     }
 
-    if (!(*virtualMachine)) {
-        if (occurrence == esxVI_Occurrence_OptionalItem) {
-            result = 0;
-
-            goto cleanup;
-        } else {
-            virReportError(VIR_ERR_NO_DOMAIN,
-                           _("Could not find domain with name '%s'"), name);
-            goto cleanup;
-        }
-    }
+    if (!(*virtualMachine) && occurrence != esxVI_Occurrence_OptionalItem)
+        goto cleanup;
 
     result = 0;