[PATCH v2 09/37] Adapt to VIR_STRDUP in src/locking/*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/locking/lock_daemon.c          | 12 ++++++------
 src/locking/lock_daemon_config.c   |  8 ++++----
 src/locking/lock_daemon_dispatch.c |  3 ++-
 src/locking/lock_driver_lockd.c    | 22 +++++++++++-----------
 src/locking/lock_driver_sanlock.c  |  8 ++++----
 src/locking/lock_manager.c         |  2 +-
 6 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index 0d8ef39..2ace573 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -370,7 +370,7 @@ virLockDaemonPidFilePath(bool privileged,
                          char **pidfile)
 {
     if (privileged) {
-        if (!(*pidfile = strdup(LOCALSTATEDIR "/run/virtlockd.pid")))
+        if (VIR_STRDUP(*pidfile, LOCALSTATEDIR "/run/virtlockd.pid") < 0)
             goto no_memory;
     } else {
         char *rundir = NULL;
@@ -408,7 +408,7 @@ virLockDaemonUnixSocketPaths(bool privileged,
                              char **sockfile)
 {
     if (privileged) {
-        if (!(*sockfile = strdup(LOCALSTATEDIR "/run/libvirt/virtlockd-sock")))
+        if (VIR_STRDUP(*sockfile, LOCALSTATEDIR "/run/libvirt/virtlockd-sock") < 0)
             goto no_memory;
     } else {
         char *rundir = NULL;
@@ -867,7 +867,7 @@ virLockDaemonClientNewPostExecRestart(virNetServerClientPtr client,
                        _("Missing ownerName data in JSON document"));
         goto error;
     }
-    if (!(priv->ownerName = strdup(ownerName))) {
+    if (VIR_STRDUP(priv->ownerName, ownerName) < 0) {
         virReportOOMError();
         goto error;
     }
@@ -1221,13 +1221,13 @@ int main(int argc, char **argv) {
 
         case 'p':
             VIR_FREE(pid_file);
-            if (!(pid_file = strdup(optarg)))
+            if (VIR_STRDUP(pid_file, optarg) < 0)
                 exit(EXIT_FAILURE);
             break;
 
         case 'f':
             VIR_FREE(remote_config_file);
-            if (!(remote_config_file = strdup(optarg)))
+            if (VIR_STRDUP(remote_config_file, optarg) < 0)
                 exit(EXIT_FAILURE);
             break;
 
@@ -1312,7 +1312,7 @@ int main(int argc, char **argv) {
 
     /* Ensure the rundir exists (on tmpfs on some systems) */
     if (privileged) {
-        if (!(run_dir = strdup(LOCALSTATEDIR "/run/libvirt"))) {
+        if (VIR_STRDUP(run_dir, LOCALSTATEDIR "/run/libvirt") < 0) {
             virReportOOMError();
             goto cleanup;
         }
diff --git a/src/locking/lock_daemon_config.c b/src/locking/lock_daemon_config.c
index c3d59bd..972e7cf 100644
--- a/src/locking/lock_daemon_config.c
+++ b/src/locking/lock_daemon_config.c
@@ -53,8 +53,8 @@ checkType(virConfValuePtr p, const char *filename,
 }
 
 /* If there is no config data for the key, #var_name, then do nothing.
-   If there is valid data of type VIR_CONF_STRING, and strdup succeeds,
-   store the result in var_name.  Otherwise, (i.e. invalid type, or strdup
+   If there is valid data of type VIR_CONF_STRING, and VIR_STRDUP succeeds,
+   store the result in var_name.  Otherwise, (i.e. invalid type, or VIR_STRDUP
    failure), give a diagnostic and "goto" the cleanup-and-fail label.  */
 #define GET_CONF_STR(conf, filename, var_name)                          \
     do {                                                                \
@@ -63,7 +63,7 @@ checkType(virConfValuePtr p, const char *filename,
             if (checkType(p, filename, #var_name, VIR_CONF_STRING) < 0) \
                 goto error;                                             \
             VIR_FREE(data->var_name);                                   \
-            if (!(data->var_name = strdup(p->str))) {                   \
+            if (VIR_STRDUP(data->var_name, p->str) < 0) {               \
                 virReportOOMError();                                    \
                 goto error;                                             \
             }                                                           \
@@ -85,7 +85,7 @@ int
 virLockDaemonConfigFilePath(bool privileged, char **configfile)
 {
     if (privileged) {
-        if (!(*configfile = strdup(SYSCONFDIR "/libvirt/virtlockd.conf")))
+        if (VIR_STRDUP(*configfile, SYSCONFDIR "/libvirt/virtlockd.conf") < 0)
             goto no_memory;
     } else {
         char *configdir = NULL;
diff --git a/src/locking/lock_daemon_dispatch.c b/src/locking/lock_daemon_dispatch.c
index 8a92802..472b6e6 100644
--- a/src/locking/lock_daemon_dispatch.c
+++ b/src/locking/lock_daemon_dispatch.c
@@ -30,6 +30,7 @@
 #include "lock_protocol.h"
 #include "lock_daemon_dispatch_stubs.h"
 #include "virerror.h"
+#include "virstring.h"
 
 #define VIR_FROM_THIS VIR_FROM_RPC
 
@@ -275,7 +276,7 @@ virLockSpaceProtocolDispatchRegister(virNetServerPtr server ATTRIBUTE_UNUSED,
         goto cleanup;
     }
 
-    if (!(priv->ownerName = strdup(args->owner.name))) {
+    if (VIR_STRDUP(priv->ownerName, args->owner.name) < 0) {
         virReportOOMError();
         goto cleanup;
     }
diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index 28a4f15..41ff13f 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -129,7 +129,7 @@ static int virLockManagerLockDaemonLoadConfig(const char *configFile)
     CHECK_TYPE("file_lockspace_dir", VIR_CONF_STRING);
     if (p && p->str) {
         VIR_FREE(driver->fileLockSpaceDir);
-        if (!(driver->fileLockSpaceDir = strdup(p->str))) {
+        if (VIR_STRDUP(driver->fileLockSpaceDir, p->str) < 0) {
             virReportOOMError();
             virConfFree(conf);
             return -1;
@@ -140,7 +140,7 @@ static int virLockManagerLockDaemonLoadConfig(const char *configFile)
     CHECK_TYPE("lvm_lockspace_dir", VIR_CONF_STRING);
     if (p && p->str) {
         VIR_FREE(driver->lvmLockSpaceDir);
-        if (!(driver->lvmLockSpaceDir = strdup(p->str))) {
+        if (VIR_STRDUP(driver->lvmLockSpaceDir, p->str) < 0) {
             virReportOOMError();
             virConfFree(conf);
             return -1;
@@ -151,7 +151,7 @@ static int virLockManagerLockDaemonLoadConfig(const char *configFile)
     CHECK_TYPE("scsi_lockspace_dir", VIR_CONF_STRING);
     if (p && p->str) {
         VIR_FREE(driver->scsiLockSpaceDir);
-        if (!(driver->scsiLockSpaceDir = strdup(p->str))) {
+        if (VIR_STRDUP(driver->scsiLockSpaceDir, p->str) < 0) {
             virReportOOMError();
             virConfFree(conf);
             return -1;
@@ -174,7 +174,7 @@ static char *virLockManagerLockDaemonPath(bool privileged)
 {
     char *path;
     if (privileged) {
-        if (!(path = strdup(LOCALSTATEDIR "/run/libvirt/virtlockd-sock"))) {
+        if (VIR_STRDUP(path, LOCALSTATEDIR "/run/libvirt/virtlockd-sock") < 0) {
             virReportOOMError();
             return NULL;
         }
@@ -468,7 +468,7 @@ static int virLockManagerLockDaemonNew(virLockManagerPtr lock,
             if (STREQ(params[i].key, "uuid")) {
                 memcpy(priv->uuid, params[i].value.uuid, VIR_UUID_BUFLEN);
             } else if (STREQ(params[i].key, "name")) {
-                if (!(priv->name = strdup(params[i].value.str))) {
+                if (VIR_STRDUP(priv->name, params[i].value.str) < 0) {
                     virReportOOMError();
                     return -1;
                 }
@@ -588,7 +588,7 @@ static int virLockManagerLockDaemonAddResource(virLockManagerPtr lock,
 
             if (newName) {
                 VIR_DEBUG("Got an LVM UUID %s for %s", newName, name);
-                if (!(newLockspace = strdup(driver->lvmLockSpaceDir)))
+                if (VIR_STRDUP(newLockspace, driver->lvmLockSpaceDir) < 0)
                     goto no_memory;
                 autoCreate = true;
                 break;
@@ -605,7 +605,7 @@ static int virLockManagerLockDaemonAddResource(virLockManagerPtr lock,
 
             if (newName) {
                 VIR_DEBUG("Got an SCSI ID %s for %s", newName, name);
-                if (!(newLockspace = strdup(driver->scsiLockSpaceDir)))
+                if (VIR_STRDUP(newLockspace, driver->scsiLockSpaceDir) < 0)
                     goto no_memory;
                 autoCreate = true;
                 break;
@@ -615,16 +615,16 @@ static int virLockManagerLockDaemonAddResource(virLockManagerPtr lock,
         }
 
         if (driver->fileLockSpaceDir) {
-            if (!(newLockspace = strdup(driver->fileLockSpaceDir)))
+            if (VIR_STRDUP(newLockspace, driver->fileLockSpaceDir) < 0)
                 goto no_memory;
             if (!(newName = virLockManagerLockDaemonDiskLeaseName(name)))
                 goto no_memory;
             autoCreate = true;
             VIR_DEBUG("Using indirect lease %s for %s", newName, name);
         } else {
-            if (!(newLockspace = strdup("")))
+            if (VIR_STRDUP(newLockspace, "") < 0)
                 goto no_memory;
-            if (!(newName = strdup(name)))
+            if (VIR_STRDUP(newName, name) < 0)
                 goto no_memory;
             VIR_DEBUG("Using direct lease for %s", name);
         }
@@ -662,7 +662,7 @@ static int virLockManagerLockDaemonAddResource(virLockManagerPtr lock,
             virReportOOMError();
             return -1;
         }
-        if (!(newName = strdup(name)))
+        if (VIR_STRDUP(newName, name) < 0)
             goto no_memory;
 
     }   break;
diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index 48c6d56..23e9ce9 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -128,7 +128,7 @@ static int virLockManagerSanlockLoadConfig(const char *configFile)
     CHECK_TYPE("disk_lease_dir", VIR_CONF_STRING);
     if (p && p->str) {
         VIR_FREE(driver->autoDiskLeasePath);
-        if (!(driver->autoDiskLeasePath = strdup(p->str))) {
+        if (VIR_STRDUP(driver->autoDiskLeasePath, p->str) < 0) {
             virReportOOMError();
             virConfFree(conf);
             return -1;
@@ -149,7 +149,7 @@ static int virLockManagerSanlockLoadConfig(const char *configFile)
     p = virConfGetValue(conf, "user");
     CHECK_TYPE("user", VIR_CONF_STRING);
     if (p) {
-        if (!(tmp = strdup(p->str))) {
+        if (VIR_STRDUP(tmp, p->str) < 0) {
             virReportOOMError();
             virConfFree(conf);
             return -1;
@@ -166,7 +166,7 @@ static int virLockManagerSanlockLoadConfig(const char *configFile)
     p = virConfGetValue(conf, "group");
     CHECK_TYPE("group", VIR_CONF_STRING);
     if (p) {
-        if (!(tmp = strdup(p->str))) {
+        if (VIR_STRDUP(tmp, p->str) < 0) {
             virReportOOMError();
             virConfFree(conf);
             return -1;
@@ -407,7 +407,7 @@ static int virLockManagerSanlockInit(unsigned int version,
     driver->autoDiskLease = false;
     driver->user = (uid_t) -1;
     driver->group = (gid_t) -1;
-    if (!(driver->autoDiskLeasePath = strdup(LOCALSTATEDIR "/lib/libvirt/sanlock"))) {
+    if (VIR_STRDUP(driver->autoDiskLeasePath, LOCALSTATEDIR "/lib/libvirt/sanlock") < 0) {
         VIR_FREE(driver);
         virReportOOMError();
         goto error;
diff --git a/src/locking/lock_manager.c b/src/locking/lock_manager.c
index 82bbe6b..aba9161 100644
--- a/src/locking/lock_manager.c
+++ b/src/locking/lock_manager.c
@@ -194,7 +194,7 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
     plugin->driver = driver;
     plugin->handle = handle;
     plugin->refs = 1;
-    if (!(plugin->name = strdup(name))) {
+    if (VIR_STRDUP(plugin->name, name) < 0) {
         virReportOOMError();
         goto cleanup;
     }
-- 
1.8.1.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]