[PATCH 3/4] util: string: Use VIR_AUTOLISTPTR for 'virString'

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

 



VIR_AUTOPTR should not be used for vectors except for the rare case of
NULL-terminated lists. Convert all cases of usage of VIR_AUTOPTR for
'virString' to VIR_AUTOLISTPTR.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/lxc/lxc_process.c                  |  2 +-
 src/qemu/qemu_conf.c                   |  8 ++++----
 src/storage/storage_backend_sheepdog.c |  4 ++--
 src/storage/storage_backend_zfs.c      | 10 +++++-----
 src/util/vircommand.c                  |  2 +-
 src/util/virfirewall.c                 |  2 +-
 src/util/virprocess.c                  |  2 +-
 src/util/virstoragefile.c              | 10 +++++-----
 src/util/virstring.h                   |  2 +-
 src/xenconfig/xen_common.c             |  6 +++---
 10 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index a3481bfa08..566ed13fda 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -1181,7 +1181,7 @@ int virLXCProcessStart(virConnectPtr conn,
     size_t i;
     char *logfile = NULL;
     int logfd = -1;
-    VIR_AUTOPTR(virString) veths = NULL;
+    VIR_AUTOLISTPTR(virString) veths = NULL;
     int handshakefds[2] = { -1, -1 };
     off_t pos = -1;
     char ebuf[1024];
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 2f5ef8d0c4..72a0b97772 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -645,7 +645,7 @@ static int
 virQEMUDriverConfigLoadProcessEntry(virQEMUDriverConfigPtr cfg,
                                     virConfPtr conf)
 {
-    VIR_AUTOPTR(virString) hugetlbfs = NULL;
+    VIR_AUTOLISTPTR(virString) hugetlbfs = NULL;
     VIR_AUTOFREE(char *) stdioHandler = NULL;
     VIR_AUTOFREE(char *) corestr = NULL;
     size_t i;
@@ -832,7 +832,7 @@ static int
 virQEMUDriverConfigLoadNVRAMEntry(virQEMUDriverConfigPtr cfg,
                                   virConfPtr conf)
 {
-    VIR_AUTOPTR(virString) nvram = NULL;
+    VIR_AUTOLISTPTR(virString) nvram = NULL;
     size_t i;

     if (virConfGetValueStringList(conf, "nvram", false, &nvram) < 0)
@@ -869,8 +869,8 @@ virQEMUDriverConfigLoadSecurityEntry(virQEMUDriverConfigPtr cfg,
                                      virConfPtr conf,
                                      bool privileged)
 {
-    VIR_AUTOPTR(virString) controllers = NULL;
-    VIR_AUTOPTR(virString) namespaces = NULL;
+    VIR_AUTOLISTPTR(virString) controllers = NULL;
+    VIR_AUTOLISTPTR(virString) namespaces = NULL;
     VIR_AUTOFREE(char *) user = NULL;
     VIR_AUTOFREE(char *) group = NULL;
     size_t i, j;
diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
index 99f3283a1c..4c01207409 100644
--- a/src/storage/storage_backend_sheepdog.c
+++ b/src/storage/storage_backend_sheepdog.c
@@ -138,8 +138,8 @@ virStorageBackendSheepdogRefreshAllVol(virStoragePoolObjPtr pool)
 {
     size_t i;
     VIR_AUTOFREE(char *) output = NULL;
-    VIR_AUTOPTR(virString) lines = NULL;
-    VIR_AUTOPTR(virString) cells = NULL;
+    VIR_AUTOLISTPTR(virString) lines = NULL;
+    VIR_AUTOLISTPTR(virString) cells = NULL;
     VIR_AUTOPTR(virCommand) cmd = NULL;

     cmd = virCommandNewArgList(SHEEPDOGCLI, "vdi", "list", "-r", NULL);
diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c
index 7ffdff638e..25f9e90f98 100644
--- a/src/storage/storage_backend_zfs.c
+++ b/src/storage/storage_backend_zfs.c
@@ -106,8 +106,8 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool,
     bool is_new_vol = false;
     virStorageVolDefPtr volume = NULL;
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
-    VIR_AUTOPTR(virString) tokens = NULL;
-    VIR_AUTOPTR(virString) name_tokens = NULL;
+    VIR_AUTOLISTPTR(virString) tokens = NULL;
+    VIR_AUTOLISTPTR(virString) name_tokens = NULL;

     if (!(tokens = virStringSplitCount(volume_string, "\t", 0, &count)))
         return -1;
@@ -177,7 +177,7 @@ virStorageBackendZFSFindVols(virStoragePoolObjPtr pool,
 {
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
     size_t i;
-    VIR_AUTOPTR(virString) lines = NULL;
+    VIR_AUTOLISTPTR(virString) lines = NULL;
     VIR_AUTOPTR(virCommand) cmd = NULL;
     VIR_AUTOFREE(char *) volumes_list = NULL;

@@ -224,8 +224,8 @@ virStorageBackendZFSRefreshPool(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED)
     char *zpool_props = NULL;
     size_t i;
     VIR_AUTOPTR(virCommand) cmd = NULL;
-    VIR_AUTOPTR(virString) lines = NULL;
-    VIR_AUTOPTR(virString) tokens = NULL;
+    VIR_AUTOLISTPTR(virString) lines = NULL;
+    VIR_AUTOLISTPTR(virString) tokens = NULL;

     /**
      * $ zpool get -Hp health,size,free,allocated test
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 3d533c68a6..8d8862ad85 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -2983,7 +2983,7 @@ virCommandRunRegex(virCommandPtr cmd,
     int totgroups = 0, ngroup = 0, maxvars = 0;
     char **groups;
     VIR_AUTOFREE(char *) outbuf = NULL;
-    VIR_AUTOPTR(virString) lines = NULL;
+    VIR_AUTOLISTPTR(virString) lines = NULL;
     int ret = -1;

     /* Compile all regular expressions */
diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index d63ce05ed8..2b7620f943 100644
--- a/src/util/virfirewall.c
+++ b/src/util/virfirewall.c
@@ -719,7 +719,7 @@ virFirewallApplyRule(virFirewallPtr firewall,
 {
     VIR_AUTOFREE(char *) output = NULL;
     VIR_AUTOFREE(char *) str = virFirewallRuleToString(rule);
-    VIR_AUTOPTR(virString) lines = NULL;
+    VIR_AUTOLISTPTR(virString) lines = NULL;
     VIR_INFO("Applying rule '%s'", NULLSTR(str));

     if (rule->ignoreErrors)
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 4e69228f34..80aba1e44d 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -987,7 +987,7 @@ int virProcessGetStartTime(pid_t pid,
     int len;
     VIR_AUTOFREE(char *) filename = NULL;
     VIR_AUTOFREE(char *) buf = NULL;
-    VIR_AUTOPTR(virString) tokens = NULL;
+    VIR_AUTOLISTPTR(virString) tokens = NULL;

     if (virAsprintf(&filename, "/proc/%llu/stat", (long long) pid) < 0)
         return -1;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index b2e308d81d..87ce299e64 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1571,7 +1571,7 @@ virStorageFileParseBackingStoreStr(const char *str,
     size_t nstrings;
     unsigned int idx = 0;
     char *suffix;
-    VIR_AUTOPTR(virString) strings = NULL;
+    VIR_AUTOLISTPTR(virString) strings = NULL;

     *chainIndex = 0;

@@ -2661,7 +2661,7 @@ virStorageSourceParseBackingURI(virStorageSourcePtr src,
     virURIPtr uri = NULL;
     const char *path = NULL;
     int ret = -1;
-    VIR_AUTOPTR(virString) scheme = NULL;
+    VIR_AUTOLISTPTR(virString) scheme = NULL;

     if (!(uri = virURIParse(uristr))) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -2765,7 +2765,7 @@ virStorageSourceRBDAddHost(virStorageSourcePtr src,
 {
     char *port;
     size_t skip;
-    VIR_AUTOPTR(virString) parts = NULL;
+    VIR_AUTOLISTPTR(virString) parts = NULL;

     if (VIR_EXPAND_N(src->hosts, src->nhosts, 1) < 0)
         return -1;
@@ -2921,7 +2921,7 @@ static int
 virStorageSourceParseNBDColonString(const char *nbdstr,
                                     virStorageSourcePtr src)
 {
-    VIR_AUTOPTR(virString) backing = NULL;
+    VIR_AUTOLISTPTR(virString) backing = NULL;

     if (!(backing = virStringSplit(nbdstr, ":", 0)))
         return -1;
@@ -4208,7 +4208,7 @@ int
 virStorageFileCheckCompat(const char *compat)
 {
     unsigned int result;
-    VIR_AUTOPTR(virString) version = NULL;
+    VIR_AUTOLISTPTR(virString) version = NULL;

     if (!compat)
         return 0;
diff --git a/src/util/virstring.h b/src/util/virstring.h
index aef82471c2..b2c7178686 100644
--- a/src/util/virstring.h
+++ b/src/util/virstring.h
@@ -307,6 +307,6 @@ int virStringParsePort(const char *str,
                        unsigned int *port)
     ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;

-VIR_DEFINE_AUTOPTR_FUNC(virString, virStringListFree);
+VIR_DEFINE_AUTOLISTPTR_FUNC_DIRECT(virString, virStringListFree);

 #endif /* LIBVIRT_VIRSTRING_H */
diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index 94e0703cf3..6b0bdcb178 100644
--- a/src/xenconfig/xen_common.c
+++ b/src/xenconfig/xen_common.c
@@ -473,7 +473,7 @@ xenHandleConfGetValueStringListErrors(int ret)
 static int
 xenParsePCIList(virConfPtr conf, virDomainDefPtr def)
 {
-    VIR_AUTOPTR(virString) pcis = NULL;
+    VIR_AUTOLISTPTR(virString) pcis = NULL;
     virString *entries = NULL;
     int rc;

@@ -666,7 +666,7 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
     }

     if (!hvm && def->graphics == NULL) { /* New PV guests use this format */
-        VIR_AUTOPTR(virString) vfbs = NULL;
+        VIR_AUTOLISTPTR(virString) vfbs = NULL;
         int rc;

         if ((rc = virConfGetValueStringList(conf, "vfb", false, &vfbs)) == 1) {
@@ -764,7 +764,7 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
 static int
 xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char *nativeFormat)
 {
-    VIR_AUTOPTR(virString) serials = NULL;
+    VIR_AUTOLISTPTR(virString) serials = NULL;
     virDomainChrDefPtr chr = NULL;

     if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
-- 
2.20.1

--
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]

  Powered by Linux