[PATCH v2 2/4] util: string: Use VIR_AUTOSTRINGLIST instead of VIR_AUTOPTR(virString)

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

 



Use of VIR_AUTOPTR and virString is confusing as it's a list and not a
single pointer. Replace it by VIR_AUTOSTRINGLIST as string lists are
basically the only sane NULL-terminated list we can have.

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/xenconfig/xen_common.c             |  6 +++---
 9 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index a3481bfa08..e0729a24bf 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_AUTOSTRINGLIST 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..42122dcd97 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_AUTOSTRINGLIST 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_AUTOSTRINGLIST 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_AUTOSTRINGLIST controllers = NULL;
+    VIR_AUTOSTRINGLIST 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..6df90937c2 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_AUTOSTRINGLIST lines = NULL;
+    VIR_AUTOSTRINGLIST 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..826a95538e 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_AUTOSTRINGLIST tokens = NULL;
+    VIR_AUTOSTRINGLIST 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_AUTOSTRINGLIST 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_AUTOSTRINGLIST lines = NULL;
+    VIR_AUTOSTRINGLIST tokens = NULL;

     /**
      * $ zpool get -Hp health,size,free,allocated test
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 3d533c68a6..84a65a2f6d 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_AUTOSTRINGLIST lines = NULL;
     int ret = -1;

     /* Compile all regular expressions */
diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index d63ce05ed8..d42c734ea6 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_AUTOSTRINGLIST 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..52b86c549d 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_AUTOSTRINGLIST 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..f361f96203 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_AUTOSTRINGLIST 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_AUTOSTRINGLIST 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_AUTOSTRINGLIST 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_AUTOSTRINGLIST 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_AUTOSTRINGLIST version = NULL;

     if (!compat)
         return 0;
diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index 94e0703cf3..2c8179f19c 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_AUTOSTRINGLIST 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_AUTOSTRINGLIST 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_AUTOSTRINGLIST 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