Commit d6215574 authored by Ulrich Sibiller's avatar Ulrich Sibiller

Error.c: scope improvements

parent f0742c7f
......@@ -325,16 +325,13 @@ void nxagentEndRedirectToClientsLog(void)
char *nxagentGetHomePath(void)
{
char *homeEnv;
char *homePath;
if (*nxagentHomeDir == '\0')
{
/*
* Check the NX_HOME environment.
*/
homeEnv = getenv("NX_HOME");
char *homeEnv = getenv("NX_HOME");
if (homeEnv == NULL || *homeEnv == '\0')
{
......@@ -369,7 +366,7 @@ char *nxagentGetHomePath(void)
#endif
}
homePath = strdup(nxagentHomeDir);
char *homePath = strdup(nxagentHomeDir);
if (homePath == NULL)
{
......@@ -385,19 +382,13 @@ char *nxagentGetHomePath(void)
char *nxagentGetRootPath(void)
{
char *rootEnv;
char *homeEnv;
char *rootPath;
struct stat dirStat;
if (*nxagentRootDir == '\0')
{
/*
* Check the NX_ROOT environment.
*/
rootEnv = getenv("NX_ROOT");
char *rootEnv = getenv("NX_ROOT");
if (rootEnv == NULL || *rootEnv == '\0')
{
......@@ -411,7 +402,7 @@ char *nxagentGetRootPath(void)
* settings.
*/
homeEnv = nxagentGetHomePath();
char *homeEnv = nxagentGetHomePath();
if (homeEnv == NULL)
{
......@@ -443,6 +434,8 @@ char *nxagentGetRootPath(void)
* Create the NX root directory.
*/
struct stat dirStat;
if ((stat(nxagentRootDir, &dirStat) == -1) && (errno == ENOENT))
{
if (mkdir(nxagentRootDir, 0777) < 0 && (errno != EEXIST))
......@@ -478,7 +471,7 @@ char *nxagentGetRootPath(void)
}
rootPath = strdup(nxagentRootDir);
char *rootPath = strdup(nxagentRootDir);
if (rootPath == NULL)
{
......@@ -494,12 +487,6 @@ char *nxagentGetRootPath(void)
char *nxagentGetSessionPath(void)
{
char *rootPath;
char *sessionPath;
struct stat dirStat;
if (*nxagentSessionDir == '\0')
{
/*
......@@ -518,7 +505,7 @@ char *nxagentGetSessionPath(void)
return NULL;
}
rootPath = nxagentGetRootPath();
char *rootPath = nxagentGetRootPath();
if (rootPath == NULL)
{
......@@ -544,6 +531,8 @@ char *nxagentGetSessionPath(void)
SAFE_free(rootPath);
struct stat dirStat;
if ((stat(nxagentSessionDir, &dirStat) == -1) && (errno == ENOENT))
{
if (mkdir(nxagentSessionDir, 0777) < 0 && (errno != EEXIST))
......@@ -564,7 +553,7 @@ char *nxagentGetSessionPath(void)
}
sessionPath = strdup(nxagentSessionDir);
char *sessionPath = strdup(nxagentSessionDir);
if (sessionPath == NULL)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment