]> xenbits.xensource.com Git - libvirt.git/commitdiff
src/lxc/: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 7 Mar 2014 08:33:31 +0000 (09:33 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 10 Mar 2014 12:45:10 +0000 (13:45 +0100)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/lxc/lxc_container.c

index f2440ff92bb79d5d2522ff65c0aff5e41b64fc5a..e03405174f94fc1a16046a4a66d3ea13297be7a4 100644 (file)
@@ -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)