summaryrefslogtreecommitdiff
path: root/dix
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@sun.com>2009-02-02 19:25:14 -0800
committerAlan Coopersmith <alan.coopersmith@sun.com>2009-02-03 10:06:00 -0800
commit5623c27700b7b23a8dbbd8c8f45e5d4fa0c667e3 (patch)
tree5ef32d8457f859742bcf2aa12019306db49d5c25 /dix
parent6869efae74381e5305b2d6517bf286e3ef7fdcb7 (diff)
Constify atom name strings
Changes MakeAtom to take a const char * and NameForAtom to return them, since many callers pass pointers to constant strings stored in read-only ELF sections. Updates in-tree callers as necessary to clear const mismatch warnings introduced by this change. Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com> Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'dix')
-rw-r--r--dix/atom.c15
-rw-r--r--dix/dispatch.c2
2 files changed, 9 insertions, 8 deletions
diff --git a/dix/atom.c b/dix/atom.c
index ab9ee800a..f5bf8ad7e 100644
--- a/dix/atom.c
+++ b/dix/atom.c
@@ -64,7 +64,7 @@ typedef struct _Node {
struct _Node *left, *right;
Atom a;
unsigned int fingerPrint;
- char *string;
+ const char *string;
} NodeRec, *NodePtr;
static Atom lastAtom = None;
@@ -75,7 +75,7 @@ static NodePtr *nodeTable;
void FreeAtom(NodePtr patom);
Atom
-MakeAtom(char *string, unsigned len, Bool makeit)
+MakeAtom(const char *string, unsigned len, Bool makeit)
{
NodePtr * np;
unsigned i;
@@ -118,13 +118,14 @@ MakeAtom(char *string, unsigned len, Bool makeit)
}
else
{
- nd->string = xalloc(len + 1);
- if (!nd->string) {
+ char *newstring = xalloc(len + 1);
+ if (!newstring) {
xfree(nd);
return BAD_RESOURCE;
}
- strncpy(nd->string, string, (int)len);
- nd->string[len] = 0;
+ strncpy(newstring, string, (int)len);
+ newstring[len] = 0;
+ nd->string = newstring;
}
if ((lastAtom + 1) >= tableLength) {
NodePtr *table;
@@ -157,7 +158,7 @@ ValidAtom(Atom atom)
return (atom != None) && (atom <= lastAtom);
}
-char *
+const char *
NameForAtom(Atom atom)
{
NodePtr node;
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 5cde80b2d..b06f4aa85 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -901,7 +901,7 @@ ProcInternAtom(ClientPtr client)
int
ProcGetAtomName(ClientPtr client)
{
- char *str;
+ const char *str;
xGetAtomNameReply reply;
int len;
REQUEST(xResourceReq);