[PATCH 02/13] src/lxc/: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT

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

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/lxc/lxc_container.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index f2440ff..e034051 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -774,17 +774,18 @@ static int lxcContainerSetReadOnly(void)
     }
 
     while (getmntent_r(procmnt, &mntent, mntbuf, sizeof(mntbuf)) != NULL) {
+        char *tmp;
         if (STREQ(mntent.mnt_dir, "/") ||
             STREQ(mntent.mnt_dir, "/.oldroot") ||
             STRPREFIX(mntent.mnt_dir, "/.oldroot/") ||
             lxcIsBasicMountLocation(mntent.mnt_dir))
             continue;
 
-        if (VIR_REALLOC_N(mounts, nmounts + 1) < 0)
+        if (VIR_STRDUP(tmp, mntent.mnt_dir) < 0 ||
+            VIR_APPEND_ELEMENT(mounts, nmounts, tmp) < 0) {
+            VIR_FREE(tmp);
             goto cleanup;
-        if (VIR_STRDUP(mounts[nmounts], mntent.mnt_dir) < 0)
-            goto cleanup;
-        nmounts++;
+        }
     }
 
     if (mounts)
-- 
1.9.0

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