summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2010-05-12 16:48:08 -0700
committerKeith Packard <keithp@keithp.com>2010-05-12 16:48:08 -0700
commit59857ee5da5f1f3f4900292581b9586477513211 (patch)
tree5155d9b62953768fc645573c78ca0fae8438bdaa
parent21ceae9002c6364deb3d074cf2da7d3864cf6879 (diff)
parent432cbbec194e47bf2a117c9302146e786c8a4ee1 (diff)
Merge remote branch 'dottedmag/for-keithp'
-rw-r--r--dix/atom.c42
-rw-r--r--include/misc.h6
-rw-r--r--include/os.h7
-rw-r--r--mi/mipolypnt.c2
-rw-r--r--os/log.c5
-rw-r--r--os/osinit.c5
-rw-r--r--xkb/ddxLoad.c8
7 files changed, 40 insertions, 35 deletions
diff --git a/dix/atom.c b/dix/atom.c
index ecfe4b0c7..88b40db65 100644
--- a/dix/atom.c
+++ b/dix/atom.c
@@ -68,7 +68,7 @@ typedef struct _Node {
} NodeRec, *NodePtr;
static Atom lastAtom = None;
-static NodePtr atomRoot = (NodePtr)NULL;
+static NodePtr atomRoot = NULL;
static unsigned long tableLength;
static NodePtr *nodeTable;
@@ -88,7 +88,7 @@ MakeAtom(const char *string, unsigned len, Bool makeit)
fp = fp * 27 + string[i];
fp = fp * 27 + string[len - 1 - i];
}
- while (*np != (NodePtr) NULL)
+ while (*np != NULL)
{
if (fp < (*np)->fingerPrint)
np = &((*np)->left);
@@ -130,11 +130,12 @@ MakeAtom(const char *string, unsigned len, Bool makeit)
if ((lastAtom + 1) >= tableLength) {
NodePtr *table;
- table = (NodePtr *) realloc(nodeTable,
- tableLength * (2 * sizeof(NodePtr)));
+ table = realloc(nodeTable, tableLength * (2 * sizeof(NodePtr)));
if (!table) {
- if (nd->string != string)
- free(nd->string);
+ if (nd->string != string) {
+ /* nd->string has been strdup'ed */
+ free((char *)nd->string);
+ }
free(nd);
return BAD_RESOURCE;
}
@@ -142,10 +143,10 @@ MakeAtom(const char *string, unsigned len, Bool makeit)
nodeTable = table;
}
*np = nd;
- nd->left = nd->right = (NodePtr) NULL;
+ nd->left = nd->right = NULL;
nd->fingerPrint = fp;
- nd->a = (++lastAtom);
- *(nodeTable+lastAtom) = nd;
+ nd->a = ++lastAtom;
+ nodeTable[lastAtom] = nd;
return nd->a;
}
else
@@ -163,7 +164,7 @@ NameForAtom(Atom atom)
{
NodePtr node;
if (atom > lastAtom) return 0;
- if ((node = nodeTable[atom]) == (NodePtr)NULL) return 0;
+ if ((node = nodeTable[atom]) == NULL) return 0;
return node->string;
}
@@ -180,20 +181,25 @@ FreeAtom(NodePtr patom)
FreeAtom(patom->left);
if(patom->right)
FreeAtom(patom->right);
- if (patom->a > XA_LAST_PREDEFINED)
- free(patom->string);
+ if (patom->a > XA_LAST_PREDEFINED) {
+ /*
+ * All strings above XA_LAST_PREDEFINED are strdup'ed, so it's safe to
+ * cast here
+ */
+ free((char *)patom->string);
+ }
free(patom);
}
void
FreeAllAtoms(void)
{
- if(atomRoot == (NodePtr)NULL)
+ if (atomRoot == NULL)
return;
FreeAtom(atomRoot);
- atomRoot = (NodePtr)NULL;
+ atomRoot = NULL;
free(nodeTable);
- nodeTable = (NodePtr *)NULL;
+ nodeTable = NULL;
lastAtom = None;
}
@@ -202,11 +208,11 @@ InitAtoms(void)
{
FreeAllAtoms();
tableLength = InitialTableSize;
- nodeTable = malloc(InitialTableSize*sizeof(NodePtr));
+ nodeTable = malloc(InitialTableSize * sizeof(NodePtr));
if (!nodeTable)
AtomError();
- nodeTable[None] = (NodePtr)NULL;
+ nodeTable[None] = NULL;
MakePredeclaredAtoms();
if (lastAtom != XA_LAST_PREDEFINED)
- AtomError ();
+ AtomError();
}
diff --git a/include/misc.h b/include/misc.h
index c7add253e..e4bdee480 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -106,6 +106,12 @@ typedef unsigned long ATOM;
#define X_DEPRECATED
#endif
+#if defined(__GNUC__) && (__GNUC__ > 2)
+#define X_NORETURN __attribute__((noreturn))
+#else
+#define X_NORETURN
+#endif
+
#ifndef _XTYPEDEF_CALLBACKLISTPTR
typedef struct _CallbackList *CallbackListPtr; /* also in dix.h */
#define _XTYPEDEF_CALLBACKLISTPTR
diff --git a/include/os.h b/include/os.h
index 7f358eeaf..d34e056ed 100644
--- a/include/os.h
+++ b/include/os.h
@@ -299,7 +299,7 @@ extern _X_EXPORT void OsBlockSignals (void);
extern _X_EXPORT void OsReleaseSignals (void);
-extern _X_EXPORT void OsAbort (void);
+extern _X_EXPORT void OsAbort (void) X_NORETURN;
#if !defined(WIN32)
extern _X_EXPORT int System(char *);
@@ -547,10 +547,7 @@ extern _X_EXPORT void FreeAuditTimer(void);
extern _X_EXPORT void AuditF(const char *f, ...) _printf_attribute(1,2);
extern _X_EXPORT void VAuditF(const char *f, va_list args);
extern _X_EXPORT void FatalError(const char *f, ...) _printf_attribute(1,2)
-#if defined(__GNUC__) && (__GNUC__ > 2)
-__attribute((noreturn))
-#endif
-;
+ X_NORETURN;
#ifdef DEBUG
#define DebugF ErrorF
diff --git a/mi/mipolypnt.c b/mi/mipolypnt.c
index 3c6ed4eb8..5a0e52363 100644
--- a/mi/mipolypnt.c
+++ b/mi/mipolypnt.c
@@ -73,7 +73,7 @@ miPolyPoint(
int i;
xPoint *ppt;
- if(!(pwidthInit = xalloc(npt * sizeof(int))))
+ if(!(pwidthInit = malloc(npt * sizeof(int))))
return;
/* make pointlist origin relative */
diff --git a/os/log.c b/os/log.c
index ff78545e1..078165985 100644
--- a/os/log.c
+++ b/os/log.c
@@ -402,9 +402,8 @@ LogMessage(MessageType type, const char *format, ...)
va_end(ap);
}
-#ifdef __GNUC__
-void AbortServer(void) __attribute__((noreturn));
-#endif
+void
+AbortServer(void) X_NORETURN;
void
AbortServer(void)
diff --git a/os/osinit.c b/os/osinit.c
index e8fcd4540..32747df52 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -161,7 +161,6 @@ void
OsInit(void)
{
static Bool been_here = FALSE;
- static char* admpath = ADMPATH;
static char* devnull = "/dev/null";
char fname[PATH_MAX];
@@ -229,8 +228,8 @@ OsInit(void)
{
FILE *err;
- if (strlen (display) + strlen (admpath) + 1 < sizeof fname)
- sprintf (fname, admpath, display);
+ if (strlen (display) + strlen (ADMPATH) + 1 < sizeof fname)
+ sprintf (fname, ADMPATH, display);
else
strcpy (fname, devnull);
/*
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index a9b5ca984..b1d629436 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -186,7 +186,7 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
char *buf = NULL, keymap[PATH_MAX], xkm_output_dir[PATH_MAX];
const char *emptystring = "";
- const char *xkbbasedirflag = emptystring;
+ char *xkbbasedirflag = NULL;
const char *xkbbindir = emptystring;
const char *xkbbindirsep = emptystring;
@@ -230,13 +230,11 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
xkbbindir, xkbbindirsep,
( (xkbDebugFlags < 2) ? 1 :
((xkbDebugFlags > 10) ? 10 : (int)xkbDebugFlags) ),
- xkbbasedirflag, xkmfile,
+ xkbbasedirflag ? xkbbasedirflag : "", xkmfile,
PRE_ERROR_MSG, ERROR_PREFIX, POST_ERROR_MSG1,
xkm_output_dir, keymap);
- if (xkbbasedirflag != emptystring) {
- free(xkbbasedirflag);
- }
+ free(xkbbasedirflag);
#ifndef WIN32
out= Popen(buf,"w");