Move virGetUserEnt() to where its needed

In the first if case, virGetUserEnt() isn't necessary so don't bother
calling it before determining we need it.
This commit is contained in:
Doug Goldstein 2013-06-16 14:33:44 -05:00
parent 847e1cd1f8
commit b5c5f236bb

View File

@ -759,12 +759,13 @@ static char *virGetXDGDirectory(const char *xdgenvname, const char *xdgdefdir)
{
const char *path = getenv(xdgenvname);
char *ret = NULL;
char *home = virGetUserEnt(geteuid(), VIR_USER_ENT_DIRECTORY);
char *home = NULL;
if (path && path[0]) {
if (virAsprintf(&ret, "%s/libvirt", path) < 0)
goto no_memory;
} else {
home = virGetUserEnt(geteuid(), VIR_USER_ENT_DIRECTORY);
if (virAsprintf(&ret, "%s/%s/libvirt", home, xdgdefdir) < 0)
goto no_memory;
}