]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
lib: Don't use virReportSystemError() if virCommandRun() fails
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 1 Apr 2019 12:56:23 +0000 (14:56 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 12 Apr 2019 13:56:28 +0000 (15:56 +0200)
Firstly, virCommandRun() does report an error on failure (which
in most cases is more accurate than what we overwrite it with).
Secondly, usually errno is not set (or gets overwritten in the
cleanup code) which makes virReportSystemError() report useless
error messages. Drop all virReportSystemError() calls in cases
like this (I've found three occurrences).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/storage/storage_backend_fs.c
src/util/virdnsmasq.c

index 97148acebe353ef32c7c5c2236f822f00084f88e..ae4e9a03a3ebd3f102355a235fb32b961d6b9534 100644 (file)
@@ -425,13 +425,8 @@ virStorageBackendExecuteMKFS(const char *device,
 
     virCommandAddArg(cmd, device);
 
-    if (virCommandRun(cmd, NULL) < 0) {
-        virReportSystemError(errno,
-                             _("Failed to make filesystem of "
-                               "type '%s' on device '%s'"),
-                             format, device);
+    if (virCommandRun(cmd, NULL) < 0)
         return -1;
-    }
 
     return 0;
 }
index 550f3179aecd34546e8be2841ea005f39301f0a2..42f62682c4aa66ba27457567c2d505f33462c875 100644 (file)
@@ -751,22 +751,16 @@ dnsmasqCapsRefreshInternal(dnsmasqCapsPtr caps, bool force)
     virCommandSetOutputBuffer(cmd, &version);
     virCommandAddEnvPassCommon(cmd);
     virCommandClearCaps(cmd);
-    if (virCommandRun(cmd, NULL) < 0) {
-        virReportSystemError(errno, _("failed to run '%s --version': %s"),
-                             caps->binaryPath, version);
+    if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;
-    }
     virCommandFree(cmd);
 
     cmd = virCommandNewArgList(caps->binaryPath, "--help", NULL);
     virCommandSetOutputBuffer(cmd, &help);
     virCommandAddEnvPassCommon(cmd);
     virCommandClearCaps(cmd);
-    if (virCommandRun(cmd, NULL) < 0) {
-        virReportSystemError(errno, _("failed to run '%s --help': %s"),
-                             caps->binaryPath, help);
+    if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;
-    }
 
     if (virAsprintf(&complete, "%s\n%s", version, help) < 0)
         goto cleanup;