[PATCH:libXt 3/3] Convert ALLOCATE_LOCAL + sprintf to XtAsprintf
Alan Coopersmith
alan.coopersmith at oracle.com
Wed Jan 12 23:59:59 PST 2011
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 at oracle.com>
---
src/Initialize.c | 25 ++++++++++---------------
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(
--
1.7.3.2
More information about the xorg-devel
mailing list