summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2010-12-22 10:49:42 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2011-01-12 23:10:34 -0800
commit84e512a94295387bd0625ce619fc8bd381395c71 (patch)
tree7f0ab4d716e857b57f471f266dd4afac6e6b73cc
parentc80650fddec8596ef7278e37aa12ce2076c54e93 (diff)
Convert ALLOCATE_LOCAL + sprintf to XtAsprintf
Now that we don't need to separately strlen the format string, put it directly into the function call to clear gcc warnings of: Initialize.c:397: warning: format not a string literal, argument types not checked Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/Initialize.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/Initialize.c b/src/Initialize.c
index 2e70e39..e9543da 100644
--- a/src/Initialize.c
+++ b/src/Initialize.c
@@ -380,7 +380,7 @@ static void CombineAppUserDefaults(
XrmDatabase *pdb)
{
char* filename;
- char* path;
+ char* path = NULL;
Boolean deallocate = False;
if (!(path = getenv("XUSERFILESEARCHPATH"))) {
@@ -389,20 +389,14 @@ static void CombineAppUserDefaults(
char homedir[PATH_MAX];
GetRootDirName(homedir, PATH_MAX);
if (!(old_path = getenv("XAPPLRESDIR"))) {
- char *path_default = "%s/%%L/%%N%%C:%s/%%l/%%N%%C:%s/%%N%%C:%s/%%L/%%N:%s/%%l/%%N:%s/%%N";
- if (!(path =
- ALLOCATE_LOCAL(6*strlen(homedir) + strlen(path_default))))
- _XtAllocError(NULL);
- sprintf( path, path_default,
- homedir, homedir, homedir, homedir, homedir, homedir );
+ XtAsprintf(&path,
+ "%s/%%L/%%N%%C:%s/%%l/%%N%%C:%s/%%N%%C:%s/%%L/%%N:%s/%%l/%%N:%s/%%N",
+ homedir, homedir, homedir, homedir, homedir, homedir);
} else {
- char *path_default = "%s/%%L/%%N%%C:%s/%%l/%%N%%C:%s/%%N%%C:%s/%%N%%C:%s/%%L/%%N:%s/%%l/%%N:%s/%%N:%s/%%N";
- if (!(path =
- ALLOCATE_LOCAL( 6*strlen(old_path) + 2*strlen(homedir)
- + strlen(path_default))))
- _XtAllocError(NULL);
- sprintf(path, path_default, old_path, old_path, old_path, homedir,
- old_path, old_path, old_path, homedir );
+ XtAsprintf(&path,
+ "%s/%%L/%%N%%C:%s/%%l/%%N%%C:%s/%%N%%C:%s/%%N%%C:%s/%%L/%%N:%s/%%l/%%N:%s/%%N:%s/%%N",
+ old_path, old_path, old_path, homedir,
+ old_path, old_path, old_path, homedir);
}
deallocate = True;
#endif
@@ -414,7 +408,8 @@ static void CombineAppUserDefaults(
XtFree(filename);
}
- if (deallocate) DEALLOCATE_LOCAL(path);
+ if (deallocate)
+ XtFree(path);
}
static void CombineUserDefaults(