]> xenbits.xensource.com Git - libvirt.git/commitdiff
Use g_strdup instead of ignoring VIR_STRDUP_QUIET's value
authorJán Tomko <jtomko@redhat.com>
Fri, 18 Oct 2019 11:27:03 +0000 (13:27 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 21 Oct 2019 10:51:55 +0000 (12:51 +0200)
Replace all the occurrences of
  ignore_value(VIR_STRDUP_QUIET(a, b));
with
  a = g_strdup(b);

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/locking/lock_driver_sanlock.c
src/qemu/qemu_process.c
src/util/virerror.c
src/util/virfile.c
src/util/virstoragefile.c
src/util/virutil.c
tests/networkxml2firewalltest.c
tests/virfilemock.c

index 9cedf395781566b60539dd68a937ac745b9d48d6..1d1691f6ba146ab245e9ee95cf638f416d2a3608 100644 (file)
@@ -101,7 +101,7 @@ virLockManagerSanlockError(int err,
 {
     if (err <= -200) {
 #if HAVE_SANLOCK_STRERROR
-        ignore_value(VIR_STRDUP_QUIET(*message, sanlock_strerror(err)));
+        *message = g_strdup(sanlock_strerror(err));
 #else
         ignore_value(virAsprintfQuiet(message, _("sanlock error %d"), err));
 #endif
index 9eaea4edfd1844017ffcd460dc939248b69e2977..843e8525911fdf6c91b5259a6a6f22c941952449 100644 (file)
@@ -959,7 +959,7 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon G_GNUC_UNUSED,
         /* We have a SYNC API waiting for this event, dispatch it back */
         job->newstate = status;
         VIR_FREE(job->errmsg);
-        ignore_value(VIR_STRDUP_QUIET(job->errmsg, error));
+        job->errmsg = g_strdup(error);
         virDomainObjBroadcast(vm);
     } else {
         /* there is no waiting SYNC API, dispatch the update to a thread */
@@ -1749,11 +1749,11 @@ qemuProcessHandleDumpCompleted(qemuMonitorPtr mon G_GNUC_UNUSED,
     }
     priv->job.dumpCompleted = true;
     priv->job.current->stats.dump = *stats;
-    ignore_value(VIR_STRDUP_QUIET(priv->job.error, error));
+    priv->job.error = g_strdup(error);
 
     /* Force error if extracting the DUMP_COMPLETED status failed */
     if (!error && status < 0) {
-        ignore_value(VIR_STRDUP_QUIET(priv->job.error, virGetLastErrorMessage()));
+        priv->job.error = g_strdup(virGetLastErrorMessage());
         priv->job.current->stats.dump.status = QEMU_MONITOR_DUMP_STATUS_FAILED;
     }
 
@@ -3407,20 +3407,20 @@ qemuProcessUpdateState(virQEMUDriverPtr driver, virDomainObjPtr vm)
           oldReason == VIR_DOMAIN_PAUSED_STARTING_UP))) {
         newState = VIR_DOMAIN_RUNNING;
         newReason = VIR_DOMAIN_RUNNING_BOOTED;
-        ignore_value(VIR_STRDUP_QUIET(msg, "finished booting"));
+        msg = g_strdup("finished booting");
     } else if (state == VIR_DOMAIN_PAUSED && running) {
         newState = VIR_DOMAIN_RUNNING;
         newReason = VIR_DOMAIN_RUNNING_UNPAUSED;
-        ignore_value(VIR_STRDUP_QUIET(msg, "was unpaused"));
+        msg = g_strdup("was unpaused");
     } else if (state == VIR_DOMAIN_RUNNING && !running) {
         if (reason == VIR_DOMAIN_PAUSED_SHUTTING_DOWN) {
             newState = VIR_DOMAIN_SHUTDOWN;
             newReason = VIR_DOMAIN_SHUTDOWN_UNKNOWN;
-            ignore_value(VIR_STRDUP_QUIET(msg, "shutdown"));
+            msg = g_strdup("shutdown");
         } else if (reason == VIR_DOMAIN_PAUSED_CRASHED) {
             newState = VIR_DOMAIN_CRASHED;
             newReason = VIR_DOMAIN_CRASHED_PANICKED;
-            ignore_value(VIR_STRDUP_QUIET(msg, "crashed"));
+            msg = g_strdup("crashed");
         } else {
             newState = VIR_DOMAIN_PAUSED;
             newReason = reason;
index b45c53b7df5cf2c06f21aeae3289c3554776fead..512b2bc7fecf87bde8267f25e9d9b1cfa78268a9 100644 (file)
@@ -187,8 +187,7 @@ virErrorGenericFailure(virErrorPtr err)
     err->code = VIR_ERR_INTERNAL_ERROR;
     err->domain = VIR_FROM_NONE;
     err->level = VIR_ERR_ERROR;
-    ignore_value(VIR_STRDUP_QUIET(err->message,
-                                  _("An error occurred, but the cause is unknown")));
+    err->message = g_strdup(_("An error occurred, but the cause is unknown"));
 }
 
 
@@ -831,7 +830,7 @@ virRaiseErrorFull(const char *filename,
      * formats the message; drop message on OOM situations
      */
     if (fmt == NULL) {
-        ignore_value(VIR_STRDUP_QUIET(str, _("No error message provided")));
+        str = g_strdup(_("No error message provided"));
     } else {
         va_list ap;
         va_start(ap, fmt);
@@ -850,9 +849,9 @@ virRaiseErrorFull(const char *filename,
     to->code = code;
     to->message = str;
     to->level = level;
-    ignore_value(VIR_STRDUP_QUIET(to->str1, str1));
-    ignore_value(VIR_STRDUP_QUIET(to->str2, str2));
-    ignore_value(VIR_STRDUP_QUIET(to->str3, str3));
+    to->str1 = g_strdup(str1);
+    to->str2 = g_strdup(str2);
+    to->str3 = g_strdup(str3);
     to->int1 = int1;
     to->int2 = int2;
 
index 2fb389eeb2078ddb293be55d806373efa2e7a179..15713a58d9f2f36cb5ebcf66a7d0890ce00474cc 100644 (file)
@@ -1264,7 +1264,7 @@ virFileFindMountPoint(const char *type)
 
     while (getmntent_r(f, &mb, mntbuf, sizeof(mntbuf))) {
         if (STREQ(mb.mnt_type, type)) {
-            ignore_value(VIR_STRDUP_QUIET(ret, mb.mnt_dir));
+            ret = g_strdup(mb.mnt_dir);
             goto cleanup;
         }
     }
@@ -1667,7 +1667,7 @@ virFindFileInPath(const char *file)
     if (IS_ABSOLUTE_FILE_NAME(file)) {
         char *ret = NULL;
         if (virFileIsExecutable(file))
-            ignore_value(VIR_STRDUP_QUIET(ret, file));
+            ret = g_strdup(file);
         return ret;
     }
 
index 098d2684ccaea968cf61ab8cf39a4af2e6eda5d4..64e09d79511c94c7876163f92035c3a98758a5ad 100644 (file)
@@ -1711,7 +1711,7 @@ virStorageFileChainLookup(virStorageSourcePtr chain,
                 if (*parent && virStorageSourceIsLocalStorage(*parent))
                     parentDir = mdir_name((*parent)->path);
                 else
-                    ignore_value(VIR_STRDUP_QUIET(parentDir, "."));
+                    parentDir = g_strdup(".");
 
                 if (!parentDir) {
                     virReportOOMError();
index 637d19e46cb264e72a831ae5229e19b5e32ecbdb..63071e2fa681e59f6c9b015ff9d8be7f2ee2bb0e 100644 (file)
@@ -523,7 +523,7 @@ virGetHostnameImpl(bool quiet)
          * string as-is; it's up to callers to check whether "localhost"
          * is allowed.
          */
-        ignore_value(VIR_STRDUP_QUIET(result, hostname));
+        result = g_strdup(hostname);
         goto cleanup;
     }
 
@@ -539,7 +539,7 @@ virGetHostnameImpl(bool quiet)
         if (!quiet)
             VIR_WARN("getaddrinfo failed for '%s': %s",
                      hostname, gai_strerror(r));
-        ignore_value(VIR_STRDUP_QUIET(result, hostname));
+        result = g_strdup(hostname);
         goto cleanup;
     }
 
@@ -552,10 +552,10 @@ virGetHostnameImpl(bool quiet)
          * localhost.  Ignore the canonicalized name and just return the
          * original hostname
          */
-        ignore_value(VIR_STRDUP_QUIET(result, hostname));
+        result = g_strdup(hostname);
     else
         /* Caller frees this string. */
-        ignore_value(VIR_STRDUP_QUIET(result, info->ai_canonname));
+        result = g_strdup(info->ai_canonname);
 
     freeaddrinfo(info);
 
index e49eef6162d7124d6617b0736f593800612e7293..b8e974971ae74625a95f7deb441fb494afbe98ba 100644 (file)
@@ -53,8 +53,8 @@ testCommandDryRun(const char *const*args G_GNUC_UNUSED,
                   void *opaque G_GNUC_UNUSED)
 {
     *status = 0;
-    ignore_value(VIR_STRDUP_QUIET(*output, ""));
-    ignore_value(VIR_STRDUP_QUIET(*error, ""));
+    *output = g_strdup("");
+    *error = g_strdup("");
 }
 
 static int testCompareXMLToArgvFiles(const char *xml,
index 6d1153dd9f4229e11665c95b19ba9e374cfb53f4..00efb820adc3a87ad65b70bd09b838938390a2bf 100644 (file)
@@ -190,7 +190,7 @@ canonicalize_file_name(const char *path)
         if ((p = STRSKIP(path, "/some/symlink")))
             ignore_value(virAsprintfQuiet(&ret, "/gluster%s", p));
         else
-            ignore_value(VIR_STRDUP_QUIET(ret, path));
+            ret = g_strdup(path);
 
         return ret;
     }