From: Michal Privoznik Date: Fri, 7 Mar 2014 08:33:31 +0000 (+0100) Subject: src/lxc/: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT X-Git-Tag: v1.2.3-rc1~327 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fca03f0a0d05a21ca8f0289573954da53dc0edd;p=thirdparty%2Flibvirt.git src/lxc/: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT Signed-off-by: Michal Privoznik --- diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index f2440ff92b..e03405174f 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)