Use g_strdup instead of ignoring VIR_STRDUP_QUIET's value

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>
This commit is contained in:
Ján Tomko 2019-10-18 13:27:03 +02:00
parent 64023f6d21
commit ea5bb994cb
8 changed files with 23 additions and 24 deletions

View File

@ -101,7 +101,7 @@ virLockManagerSanlockError(int err,
{ {
if (err <= -200) { if (err <= -200) {
#if HAVE_SANLOCK_STRERROR #if HAVE_SANLOCK_STRERROR
ignore_value(VIR_STRDUP_QUIET(*message, sanlock_strerror(err))); *message = g_strdup(sanlock_strerror(err));
#else #else
ignore_value(virAsprintfQuiet(message, _("sanlock error %d"), err)); ignore_value(virAsprintfQuiet(message, _("sanlock error %d"), err));
#endif #endif

View File

@ -959,7 +959,7 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon G_GNUC_UNUSED,
/* We have a SYNC API waiting for this event, dispatch it back */ /* We have a SYNC API waiting for this event, dispatch it back */
job->newstate = status; job->newstate = status;
VIR_FREE(job->errmsg); VIR_FREE(job->errmsg);
ignore_value(VIR_STRDUP_QUIET(job->errmsg, error)); job->errmsg = g_strdup(error);
virDomainObjBroadcast(vm); virDomainObjBroadcast(vm);
} else { } else {
/* there is no waiting SYNC API, dispatch the update to a thread */ /* 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.dumpCompleted = true;
priv->job.current->stats.dump = *stats; 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 */ /* Force error if extracting the DUMP_COMPLETED status failed */
if (!error && status < 0) { 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; 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))) { oldReason == VIR_DOMAIN_PAUSED_STARTING_UP))) {
newState = VIR_DOMAIN_RUNNING; newState = VIR_DOMAIN_RUNNING;
newReason = VIR_DOMAIN_RUNNING_BOOTED; 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) { } else if (state == VIR_DOMAIN_PAUSED && running) {
newState = VIR_DOMAIN_RUNNING; newState = VIR_DOMAIN_RUNNING;
newReason = VIR_DOMAIN_RUNNING_UNPAUSED; 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) { } else if (state == VIR_DOMAIN_RUNNING && !running) {
if (reason == VIR_DOMAIN_PAUSED_SHUTTING_DOWN) { if (reason == VIR_DOMAIN_PAUSED_SHUTTING_DOWN) {
newState = VIR_DOMAIN_SHUTDOWN; newState = VIR_DOMAIN_SHUTDOWN;
newReason = VIR_DOMAIN_SHUTDOWN_UNKNOWN; newReason = VIR_DOMAIN_SHUTDOWN_UNKNOWN;
ignore_value(VIR_STRDUP_QUIET(msg, "shutdown")); msg = g_strdup("shutdown");
} else if (reason == VIR_DOMAIN_PAUSED_CRASHED) { } else if (reason == VIR_DOMAIN_PAUSED_CRASHED) {
newState = VIR_DOMAIN_CRASHED; newState = VIR_DOMAIN_CRASHED;
newReason = VIR_DOMAIN_CRASHED_PANICKED; newReason = VIR_DOMAIN_CRASHED_PANICKED;
ignore_value(VIR_STRDUP_QUIET(msg, "crashed")); msg = g_strdup("crashed");
} else { } else {
newState = VIR_DOMAIN_PAUSED; newState = VIR_DOMAIN_PAUSED;
newReason = reason; newReason = reason;

View File

@ -187,8 +187,7 @@ virErrorGenericFailure(virErrorPtr err)
err->code = VIR_ERR_INTERNAL_ERROR; err->code = VIR_ERR_INTERNAL_ERROR;
err->domain = VIR_FROM_NONE; err->domain = VIR_FROM_NONE;
err->level = VIR_ERR_ERROR; err->level = VIR_ERR_ERROR;
ignore_value(VIR_STRDUP_QUIET(err->message, err->message = g_strdup(_("An error occurred, but the cause is unknown"));
_("An error occurred, but the cause is unknown")));
} }
@ -831,7 +830,7 @@ virRaiseErrorFull(const char *filename,
* formats the message; drop message on OOM situations * formats the message; drop message on OOM situations
*/ */
if (fmt == NULL) { if (fmt == NULL) {
ignore_value(VIR_STRDUP_QUIET(str, _("No error message provided"))); str = g_strdup(_("No error message provided"));
} else { } else {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
@ -850,9 +849,9 @@ virRaiseErrorFull(const char *filename,
to->code = code; to->code = code;
to->message = str; to->message = str;
to->level = level; to->level = level;
ignore_value(VIR_STRDUP_QUIET(to->str1, str1)); to->str1 = g_strdup(str1);
ignore_value(VIR_STRDUP_QUIET(to->str2, str2)); to->str2 = g_strdup(str2);
ignore_value(VIR_STRDUP_QUIET(to->str3, str3)); to->str3 = g_strdup(str3);
to->int1 = int1; to->int1 = int1;
to->int2 = int2; to->int2 = int2;

View File

@ -1264,7 +1264,7 @@ virFileFindMountPoint(const char *type)
while (getmntent_r(f, &mb, mntbuf, sizeof(mntbuf))) { while (getmntent_r(f, &mb, mntbuf, sizeof(mntbuf))) {
if (STREQ(mb.mnt_type, type)) { if (STREQ(mb.mnt_type, type)) {
ignore_value(VIR_STRDUP_QUIET(ret, mb.mnt_dir)); ret = g_strdup(mb.mnt_dir);
goto cleanup; goto cleanup;
} }
} }
@ -1667,7 +1667,7 @@ virFindFileInPath(const char *file)
if (IS_ABSOLUTE_FILE_NAME(file)) { if (IS_ABSOLUTE_FILE_NAME(file)) {
char *ret = NULL; char *ret = NULL;
if (virFileIsExecutable(file)) if (virFileIsExecutable(file))
ignore_value(VIR_STRDUP_QUIET(ret, file)); ret = g_strdup(file);
return ret; return ret;
} }

View File

@ -1711,7 +1711,7 @@ virStorageFileChainLookup(virStorageSourcePtr chain,
if (*parent && virStorageSourceIsLocalStorage(*parent)) if (*parent && virStorageSourceIsLocalStorage(*parent))
parentDir = mdir_name((*parent)->path); parentDir = mdir_name((*parent)->path);
else else
ignore_value(VIR_STRDUP_QUIET(parentDir, ".")); parentDir = g_strdup(".");
if (!parentDir) { if (!parentDir) {
virReportOOMError(); virReportOOMError();

View File

@ -523,7 +523,7 @@ virGetHostnameImpl(bool quiet)
* string as-is; it's up to callers to check whether "localhost" * string as-is; it's up to callers to check whether "localhost"
* is allowed. * is allowed.
*/ */
ignore_value(VIR_STRDUP_QUIET(result, hostname)); result = g_strdup(hostname);
goto cleanup; goto cleanup;
} }
@ -539,7 +539,7 @@ virGetHostnameImpl(bool quiet)
if (!quiet) if (!quiet)
VIR_WARN("getaddrinfo failed for '%s': %s", VIR_WARN("getaddrinfo failed for '%s': %s",
hostname, gai_strerror(r)); hostname, gai_strerror(r));
ignore_value(VIR_STRDUP_QUIET(result, hostname)); result = g_strdup(hostname);
goto cleanup; goto cleanup;
} }
@ -552,10 +552,10 @@ virGetHostnameImpl(bool quiet)
* localhost. Ignore the canonicalized name and just return the * localhost. Ignore the canonicalized name and just return the
* original hostname * original hostname
*/ */
ignore_value(VIR_STRDUP_QUIET(result, hostname)); result = g_strdup(hostname);
else else
/* Caller frees this string. */ /* Caller frees this string. */
ignore_value(VIR_STRDUP_QUIET(result, info->ai_canonname)); result = g_strdup(info->ai_canonname);
freeaddrinfo(info); freeaddrinfo(info);

View File

@ -53,8 +53,8 @@ testCommandDryRun(const char *const*args G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED) void *opaque G_GNUC_UNUSED)
{ {
*status = 0; *status = 0;
ignore_value(VIR_STRDUP_QUIET(*output, "")); *output = g_strdup("");
ignore_value(VIR_STRDUP_QUIET(*error, "")); *error = g_strdup("");
} }
static int testCompareXMLToArgvFiles(const char *xml, static int testCompareXMLToArgvFiles(const char *xml,

View File

@ -190,7 +190,7 @@ canonicalize_file_name(const char *path)
if ((p = STRSKIP(path, "/some/symlink"))) if ((p = STRSKIP(path, "/some/symlink")))
ignore_value(virAsprintfQuiet(&ret, "/gluster%s", p)); ignore_value(virAsprintfQuiet(&ret, "/gluster%s", p));
else else
ignore_value(VIR_STRDUP_QUIET(ret, path)); ret = g_strdup(path);
return ret; return ret;
} }