]> xenbits.xensource.com Git - libvirt.git/commitdiff
lib: Use virReportSystemError() more
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 29 Mar 2022 08:10:59 +0000 (10:10 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 7 Apr 2022 10:11:22 +0000 (12:11 +0200)
Instead of reporting virReportError(..., g_strerror(), ...) let's
use proper virReportSystemError(). Generated with help of cocci:

  @@
  expression c;
  @@
      <...
  -   virReportError(c,
  +   virReportSystemError(errno,
                         ...,
  -                      g_strerror(errno),
                         ...);
      ...>

But then I had to hand fix format strings, because I'm not sure
if cocci even knows how to do that. And even if it did, I surely
don't.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/libxl/libxl_conf.c
src/libxl/libxl_driver.c
src/qemu/qemu_interface.c

index a0fc51c74afd49e0a92d2ec535869578f81d8620..6398129195eae31df7178ac8acd7efaef5011b87 100644 (file)
@@ -1775,10 +1775,9 @@ libxlDriverConfigInit(libxlDriverConfig *cfg)
     uint64_t free_mem;
 
     if (g_mkdir_with_parents(cfg->logDir, 0777) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("failed to create log dir '%s': %s"),
-                       cfg->logDir,
-                       g_strerror(errno));
+        virReportSystemError(errno,
+                             _("failed to create log dir '%s'"),
+                             cfg->logDir);
         return -1;
     }
 
index 01f281d0a543f0cff92fcb4589b6a1b7d7d48919..5d76eb975224148bc613bf1d7b8ec2b67370915a 100644 (file)
@@ -721,38 +721,33 @@ libxlStateInitialize(bool privileged,
 
     libxl_driver->config = cfg;
     if (g_mkdir_with_parents(cfg->stateDir, 0777) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("failed to create state dir '%s': %s"),
-                       cfg->stateDir,
-                       g_strerror(errno));
+        virReportSystemError(errno,
+                             _("failed to create state dir '%s'"),
+                             cfg->stateDir);
         goto error;
     }
     if (g_mkdir_with_parents(cfg->libDir, 0777) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("failed to create lib dir '%s': %s"),
-                       cfg->libDir,
-                       g_strerror(errno));
+        virReportSystemError(errno,
+                             _("failed to create lib dir '%s'"),
+                             cfg->libDir);
         goto error;
     }
     if (g_mkdir_with_parents(cfg->saveDir, 0777) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("failed to create save dir '%s': %s"),
-                       cfg->saveDir,
-                       g_strerror(errno));
+        virReportSystemError(errno,
+                             _("failed to create save dir '%s'"),
+                             cfg->saveDir);
         goto error;
     }
     if (g_mkdir_with_parents(cfg->autoDumpDir, 0777) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("failed to create dump dir '%s': %s"),
-                       cfg->autoDumpDir,
-                       g_strerror(errno));
+        virReportSystemError(errno,
+                             _("failed to create dump dir '%s'"),
+                             cfg->autoDumpDir);
         goto error;
     }
     if (g_mkdir_with_parents(cfg->channelDir, 0777) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("failed to create channel dir '%s': %s"),
-                       cfg->channelDir,
-                       g_strerror(errno));
+        virReportSystemError(errno,
+                             _("failed to create channel dir '%s'"),
+                             cfg->channelDir);
         goto error;
     }
 
index 676bc896d636ed2773e20ad368290797099bfce7..e5f47109880af4c3e6047f04a680fadf5bd1adb6 100644 (file)
@@ -368,12 +368,12 @@ qemuCreateInBridgePortWithHelper(virQEMUDriverConfig *cfg,
         virCommandAbort(cmd);
 
         if (errbuf && *errbuf)
-            errstr = g_strdup_printf("\nstderr=%s", errbuf);
+            errstr = g_strdup_printf("stderr=%s", errbuf);
 
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-            _("%s: failed to communicate with bridge helper: %s%s"),
-            cmdstr, g_strerror(errno),
-            NULLSTR_EMPTY(errstr));
+        virReportSystemError(errno,
+                             _("%s: failed to communicate with bridge helper: %s"),
+                             cmdstr,
+                             NULLSTR_EMPTY(errstr));
         VIR_FREE(errstr);
         goto cleanup;
     }