]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
logging: use g_strdup instead of VIR_STRDUP
authorJán Tomko <jtomko@redhat.com>
Sun, 20 Oct 2019 11:49:46 +0000 (13:49 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 21 Oct 2019 10:51:57 +0000 (12:51 +0200)
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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/logging/log_daemon.c
src/logging/log_daemon_config.c
src/logging/log_handler.c
src/logging/log_manager.c

index 851695b1091f4ebe67f7b4767c54eb16a1defd49..73bd3c4ac28082e103cc3921c98c2771cdb06731 100644 (file)
@@ -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);
 }
index c339da18085cfb587e99c9a88e50e45f1f016086..df7c6339b77c6020534b611b01eae53f84667556 100644 (file)
@@ -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;
 
index 025a546b5151b4b1a8407825b41558d86d8578dc..29ea3011b9a927fbf923b61d893de7bd5afe257a 100644 (file)
@@ -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,
index 1613d1f8a8c7b970cb3f5581b3db47a1713b5286..b60a6aaf591a6290ee047104fb64e8b618957381 100644 (file)
@@ -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;