Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a = g_strdup(b); Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- src/logging/log_daemon.c | 21 ++++++--------------- src/logging/log_daemon_config.c | 3 +-- src/logging/log_handler.c | 11 ++++------- src/logging/log_manager.c | 3 +-- 4 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c index 851695b109..73bd3c4ac2 100644 --- a/src/logging/log_daemon.c +++ b/src/logging/log_daemon.c @@ -388,9 +388,8 @@ virLogDaemonUnixSocketPaths(bool privileged, char **adminSockfile) { if (privileged) { - if (VIR_STRDUP(*sockfile, RUNSTATEDIR "/libvirt/virtlogd-sock") < 0 || - VIR_STRDUP(*adminSockfile, RUNSTATEDIR "/libvirt/virtlogd-admin-sock") < 0) - goto error; + *sockfile = g_strdup(RUNSTATEDIR "/libvirt/virtlogd-sock"); + *adminSockfile = g_strdup(RUNSTATEDIR "/libvirt/virtlogd-admin-sock"); } else { char *rundir = NULL; mode_t old_umask; @@ -623,8 +622,7 @@ virLogDaemonExecRestartStatePath(bool privileged, char **state_file) { if (privileged) { - if (VIR_STRDUP(*state_file, RUNSTATEDIR "/virtlogd-restart-exec.json") < 0) - goto error; + *state_file = g_strdup(RUNSTATEDIR "/virtlogd-restart-exec.json"); } else { char *rundir = NULL; mode_t old_umask; @@ -934,14 +932,12 @@ int main(int argc, char **argv) { case 'p': VIR_FREE(pid_file); - if (VIR_STRDUP_QUIET(pid_file, optarg) < 0) - goto no_memory; + pid_file = g_strdup(optarg); break; case 'f': VIR_FREE(remote_config_file); - if (VIR_STRDUP_QUIET(remote_config_file, optarg) < 0) - goto no_memory; + remote_config_file = g_strdup(optarg); break; case 'V': @@ -1018,8 +1014,7 @@ int main(int argc, char **argv) { /* Ensure the rundir exists (on tmpfs on some systems) */ if (privileged) { - if (VIR_STRDUP_QUIET(run_dir, RUNSTATEDIR "/libvirt") < 0) - goto no_memory; + run_dir = g_strdup(RUNSTATEDIR "/libvirt"); } else { if (!(run_dir = virGetUserRuntimeDirectory())) { VIR_ERROR(_("Can't determine user directory")); @@ -1220,8 +1215,4 @@ int main(int argc, char **argv) { VIR_FREE(remote_config_file); virLogDaemonConfigFree(config); return ret; - - no_memory: - VIR_ERROR(_("Can't allocate memory")); - exit(EXIT_FAILURE); } diff --git a/src/logging/log_daemon_config.c b/src/logging/log_daemon_config.c index c339da1808..df7c6339b7 100644 --- a/src/logging/log_daemon_config.c +++ b/src/logging/log_daemon_config.c @@ -40,8 +40,7 @@ int virLogDaemonConfigFilePath(bool privileged, char **configfile) { if (privileged) { - if (VIR_STRDUP(*configfile, SYSCONFDIR "/libvirt/virtlogd.conf") < 0) - goto error; + *configfile = g_strdup(SYSCONFDIR "/libvirt/virtlogd.conf"); } else { char *configdir = NULL; diff --git a/src/logging/log_handler.c b/src/logging/log_handler.c index 025a546b51..29ea3011b9 100644 --- a/src/logging/log_handler.c +++ b/src/logging/log_handler.c @@ -239,16 +239,14 @@ virLogHandlerLogFilePostExecRestart(virLogHandlerPtr handler, _("Missing 'driver' in JSON document")); goto error; } - if (VIR_STRDUP(file->driver, tmp) < 0) - goto error; + file->driver = g_strdup(tmp); if ((tmp = virJSONValueObjectGetString(object, "domname")) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing 'domname' in JSON document")); goto error; } - if (VIR_STRDUP(file->domname, tmp) < 0) - goto error; + file->domname = g_strdup(tmp); if ((domuuid = virJSONValueObjectGetString(object, "domuuid")) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -402,9 +400,8 @@ virLogHandlerDomainOpenLogFile(virLogHandlerPtr handler, file->pipefd = pipefd[0]; pipefd[0] = -1; memcpy(file->domuuid, domuuid, VIR_UUID_BUFLEN); - if (VIR_STRDUP(file->driver, driver) < 0 || - VIR_STRDUP(file->domname, domname) < 0) - goto error; + file->driver = g_strdup(driver); + file->domname = g_strdup(domname); if ((file->file = virRotatingFileWriterNew(path, handler->max_size, diff --git a/src/logging/log_manager.c b/src/logging/log_manager.c index 1613d1f8a8..b60a6aaf59 100644 --- a/src/logging/log_manager.c +++ b/src/logging/log_manager.c @@ -45,8 +45,7 @@ virLogManagerDaemonPath(bool privileged) { char *path; if (privileged) { - if (VIR_STRDUP(path, RUNSTATEDIR "/libvirt/virtlogd-sock") < 0) - return NULL; + path = g_strdup(RUNSTATEDIR "/libvirt/virtlogd-sock"); } else { char *rundir = NULL; -- 2.21.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list