Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nx-libs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dimbor
nx-libs
Commits
d6cc85e5
Commit
d6cc85e5
authored
Dec 29, 2019
by
Ulrich Sibiller
Committed by
Mike Gabriel
Jan 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Error.c: make nxagentHomeDir a pointer
no more hardcoded string length
parent
03544b3a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
26 deletions
+17
-26
Error.c
nx-X11/programs/Xserver/hw/nxagent/Error.c
+17
-26
No files found.
nx-X11/programs/Xserver/hw/nxagent/Error.c
View file @
d6cc85e5
...
...
@@ -85,7 +85,7 @@ char *nxagentClientsLogName = NULL;
* User's home.
*/
static
char
nxagentHomeDir
[
DEFAULT_STRING_LENGTH
]
=
{
0
}
;
static
char
*
nxagentHomeDir
=
NULL
;
/*
* NX root directory.
...
...
@@ -323,9 +323,13 @@ void nxagentEndRedirectToClientsLog(void)
nxagentCloseClientsLogFile
();
}
/*
* returns a pointer to the static nxagentHomeDir. The caller must not free
* this pointer!
*/
char
*
nxagentGetHomePath
(
void
)
{
if
(
*
nxagentHomeDir
==
'\0'
)
if
(
!
nxagentHomeDir
)
{
/*
* Check the NX_HOME environment.
...
...
@@ -336,7 +340,7 @@ char *nxagentGetHomePath(void)
if
(
homeEnv
==
NULL
||
*
homeEnv
==
'\0'
)
{
#ifdef TEST
fprintf
(
stderr
,
"
nxagentGetHomePath: No environment for NX_HOME.
\n
"
);
fprintf
(
stderr
,
"
%s: No environment for NX_HOME.
\n
"
,
__func__
);
#endif
homeEnv
=
getenv
(
"HOME"
);
...
...
@@ -344,40 +348,31 @@ char *nxagentGetHomePath(void)
if
(
homeEnv
==
NULL
||
*
homeEnv
==
'\0'
)
{
#ifdef PANIC
fprintf
(
stderr
,
"
nxagentGetHomePath: PANIC! No environment for HOME.
\n
"
);
fprintf
(
stderr
,
"
%s: PANIC! No environment for HOME.
\n
"
,
__func__
);
#endif
return
NULL
;
}
}
if
(
strlen
(
homeEnv
)
>
DEFAULT_STRING_LENGTH
-
1
)
/* FIXME: this is currently never freed as it is thought to last
over the complete runtime. We should add a free call at shutdown
eventually... */
nxagentHomeDir
=
strdup
(
homeEnv
);
if
(
!
nxagentHomeDir
)
{
#ifdef PANIC
fprintf
(
stderr
,
"nxagentGetHomePath: PANIC! Invalid value for the NX "
"home directory '%s'.
\n
"
,
homeEnv
);
fprintf
(
stderr
,
"%s: PANIC! Can't allocate memory for the home path.
\n
"
,
__func__
);
#endif
return
NULL
;
}
snprintf
(
nxagentHomeDir
,
DEFAULT_STRING_LENGTH
,
"%s"
,
homeEnv
);
#ifdef TEST
fprintf
(
stderr
,
"nxagentGetHomePath: Assuming NX user's home directory '%s'.
\n
"
,
nxagentHomeDir
);
#endif
}
char
*
homePath
=
strdup
(
nxagentHomeDir
);
if
(
homePath
==
NULL
)
{
#ifdef PANIC
fprintf
(
stderr
,
"nxagentGetHomePath: PANIC! Can't allocate memory for the home path.
\n
"
);
fprintf
(
stderr
,
"%s: Assuming NX user's home directory '%s'.
\n
"
,
__func__
,
nxagentHomeDir
);
#endif
return
NULL
;
}
return
homePath
;
return
nxagentHomeDir
;
}
char
*
nxagentGetRootPath
(
void
)
...
...
@@ -416,8 +411,6 @@ char *nxagentGetRootPath(void)
"home directory '%s'.
\n
"
,
homeEnv
);
#endif
SAFE_free
(
homeEnv
);
return
NULL
;
}
...
...
@@ -427,8 +420,6 @@ char *nxagentGetRootPath(void)
snprintf
(
nxagentRootDir
,
DEFAULT_STRING_LENGTH
,
"%s/.nx"
,
homeEnv
);
SAFE_free
(
homeEnv
);
/*
* Create the NX root directory.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment