Unverified Commit 554a6fa7 authored by Mihai Moldovan's avatar Mihai Moldovan

Merge branch 'sunweaver-pr/constify-atom-name-strings' into 3.6.x

parents f42d36fb 9c3669c6
...@@ -1066,7 +1066,7 @@ SecurityAuditResourceIDAccess( ...@@ -1066,7 +1066,7 @@ SecurityAuditResourceIDAccess(
xChangePropertyReq *req = xChangePropertyReq *req =
(xChangePropertyReq *)client->requestBuffer; (xChangePropertyReq *)client->requestBuffer;
int propertyatom = req->property; int propertyatom = req->property;
char *propertyname = NameForAtom(propertyatom); const char *propertyname = NameForAtom(propertyatom);
SecurityAudit("client %d attempted request %d with window 0x%x property %s of client %d\n", SecurityAudit("client %d attempted request %d with window 0x%x property %s of client %d\n",
client->index, reqtype, id, propertyname, cid); client->index, reqtype, id, propertyname, cid);
......
...@@ -62,7 +62,7 @@ typedef struct _Node { ...@@ -62,7 +62,7 @@ typedef struct _Node {
struct _Node *left, *right; struct _Node *left, *right;
Atom a; Atom a;
unsigned int fingerPrint; unsigned int fingerPrint;
char *string; const char *string;
} NodeRec, *NodePtr; } NodeRec, *NodePtr;
static Atom lastAtom = None; static Atom lastAtom = None;
...@@ -116,13 +116,11 @@ MakeAtom(const char *string, unsigned len, Bool makeit) ...@@ -116,13 +116,11 @@ MakeAtom(const char *string, unsigned len, Bool makeit)
} }
else else
{ {
nd->string = (char *) malloc(len + 1); nd->string = strndup(string, len);
if (!nd->string) { if (!nd->string) {
free(nd); free(nd);
return BAD_RESOURCE; return BAD_RESOURCE;
} }
strncpy(nd->string, string, (int)len);
nd->string[len] = 0;
} }
if ((lastAtom + 1) >= tableLength) { if ((lastAtom + 1) >= tableLength) {
NodePtr *table; NodePtr *table;
...@@ -131,7 +129,8 @@ MakeAtom(const char *string, unsigned len, Bool makeit) ...@@ -131,7 +129,8 @@ MakeAtom(const char *string, unsigned len, Bool makeit)
tableLength * (2 * sizeof(NodePtr))); tableLength * (2 * sizeof(NodePtr)));
if (!table) { if (!table) {
if (nd->string != string) if (nd->string != string)
free(nd->string); /* nd->string has been strdup'ed */
free((char *)nd->string);
free(nd); free(nd);
return BAD_RESOURCE; return BAD_RESOURCE;
} }
...@@ -155,7 +154,7 @@ ValidAtom(Atom atom) ...@@ -155,7 +154,7 @@ ValidAtom(Atom atom)
return (atom != None) && (atom <= lastAtom); return (atom != None) && (atom <= lastAtom);
} }
char * const char *
NameForAtom(Atom atom) NameForAtom(Atom atom)
{ {
NodePtr node; NodePtr node;
...@@ -178,7 +177,7 @@ FreeAtom(NodePtr patom) ...@@ -178,7 +177,7 @@ FreeAtom(NodePtr patom)
if(patom->right) if(patom->right)
FreeAtom(patom->right); FreeAtom(patom->right);
if (patom->a > XA_LAST_PREDEFINED) if (patom->a > XA_LAST_PREDEFINED)
free(patom->string); free((char *)patom->string);
free(patom); free(patom);
} }
......
...@@ -886,7 +886,7 @@ ProcInternAtom(register ClientPtr client) ...@@ -886,7 +886,7 @@ ProcInternAtom(register ClientPtr client)
int int
ProcGetAtomName(register ClientPtr client) ProcGetAtomName(register ClientPtr client)
{ {
char *str; const char *str;
xGetAtomNameReply reply; xGetAtomNameReply reply;
int len; int len;
REQUEST(xResourceReq); REQUEST(xResourceReq);
......
...@@ -336,7 +336,7 @@ int nxagentQueryAtoms(ScreenPtr pScreen) ...@@ -336,7 +336,7 @@ int nxagentQueryAtoms(ScreenPtr pScreen)
typedef struct { typedef struct {
Atom local; Atom local;
Atom remote; Atom remote;
char *string; const char *string;
int length; int length;
} AtomMap; } AtomMap;
...@@ -345,7 +345,7 @@ static unsigned int privAtomMapSize = 0; ...@@ -345,7 +345,7 @@ static unsigned int privAtomMapSize = 0;
static unsigned int privLastAtom = 0; static unsigned int privLastAtom = 0;
static void nxagentExpandCache(void); static void nxagentExpandCache(void);
static void nxagentWriteAtom(Atom, Atom, char*, Bool); static void nxagentWriteAtom(Atom, Atom, const char*, Bool);
static AtomMap* nxagentFindAtomByRemoteValue(Atom); static AtomMap* nxagentFindAtomByRemoteValue(Atom);
static AtomMap* nxagentFindAtomByLocalValue(Atom); static AtomMap* nxagentFindAtomByLocalValue(Atom);
static AtomMap* nxagentFindAtomByName(char*, unsigned); static AtomMap* nxagentFindAtomByName(char*, unsigned);
...@@ -368,9 +368,9 @@ static void nxagentExpandCache(void) ...@@ -368,9 +368,9 @@ static void nxagentExpandCache(void)
* then cache the atom-couple. * then cache the atom-couple.
*/ */
static void nxagentWriteAtom(Atom local, Atom remote, char *string, Bool duplicate) static void nxagentWriteAtom(Atom local, Atom remote, const char *string, Bool duplicate)
{ {
char *s; const char *s;
/* /*
* We could remove this string duplication if * We could remove this string duplication if
...@@ -460,7 +460,7 @@ static int nxagentInitAtomMap(char **atomNameList, int count, Atom *atomsRet) ...@@ -460,7 +460,7 @@ static int nxagentInitAtomMap(char **atomNameList, int count, Atom *atomsRet)
for (i = 0; i < privLastAtom; i++) for (i = 0; i < privLastAtom; i++)
{ {
name_list[count + i] = privAtomMap[i].string; name_list[count + i] = (char *)privAtomMap[i].string;
atom_list[count + i] = None; atom_list[count + i] = None;
} }
...@@ -670,7 +670,7 @@ Atom nxagentMakeAtom(char *string, unsigned int length, Bool Makeit) ...@@ -670,7 +670,7 @@ Atom nxagentMakeAtom(char *string, unsigned int length, Bool Makeit)
Atom nxagentLocalToRemoteAtom(Atom local) Atom nxagentLocalToRemoteAtom(Atom local)
{ {
AtomMap *current; AtomMap *current;
char *string; const char *string;
Atom remote; Atom remote;
if (!ValidAtom(local)) if (!ValidAtom(local))
......
...@@ -1164,7 +1164,7 @@ FIXME: Why this pointer can be not a valid ...@@ -1164,7 +1164,7 @@ FIXME: Why this pointer can be not a valid
int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection,
Window requestor, Atom property, Atom target, Time time) Window requestor, Atom property, Atom target, Time time)
{ {
char *strTarget; const char *strTarget;
int i; int i;
if (agentClipboardStatus != 1 || if (agentClipboardStatus != 1 ||
......
...@@ -491,7 +491,7 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont) ...@@ -491,7 +491,7 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont)
int nprops; int nprops;
FontPropPtr props; FontPropPtr props;
int i; int i;
char *name; const char *name;
char *origName = (char*) pScreen; char *origName = (char*) pScreen;
FontSetPrivate(pFont, nxagentFontPrivateIndex, NULL); FontSetPrivate(pFont, nxagentFontPrivateIndex, NULL);
...@@ -513,7 +513,7 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont) ...@@ -513,7 +513,7 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont)
if (!value_atom) return False; if (!value_atom) return False;
name = (char *)NameForAtom(value_atom); name = NameForAtom(value_atom);
#ifdef NXAGENT_FONTCACHE_DEBUG #ifdef NXAGENT_FONTCACHE_DEBUG
fprintf(stderr, "Font: nxagentRealizeFont, realizing font: %s\n", validateString(name)); fprintf(stderr, "Font: nxagentRealizeFont, realizing font: %s\n", validateString(name));
...@@ -602,7 +602,7 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont) ...@@ -602,7 +602,7 @@ Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont)
nxagentListRemoteFonts("*", nxagentMaxFontNames); nxagentListRemoteFonts("*", nxagentMaxFontNames);
} }
nxagentFontPriv(pFont)->font_struct = nxagentLoadQueryFont(nxagentDisplay, name, pFont); nxagentFontPriv(pFont)->font_struct = nxagentLoadQueryFont(nxagentDisplay, (char *)name, pFont);
strcpy(nxagentFontPriv(pFont)->fontName, name); strcpy(nxagentFontPriv(pFont)->fontName, name);
if (nxagentFontPriv(pFont)->font_struct != NULL) if (nxagentFontPriv(pFont)->font_struct != NULL)
{ {
......
...@@ -455,7 +455,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) ...@@ -455,7 +455,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value)
unsigned long nUnits; unsigned long nUnits;
void *value; void *value;
{ {
char *propertyS, *typeS; const char *propertyS, *typeS;
Atom propertyX, typeX; Atom propertyX, typeX;
char *output = NULL; char *output = NULL;
nxagentWMHints wmHints; nxagentWMHints wmHints;
...@@ -634,7 +634,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) ...@@ -634,7 +634,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value)
{ {
XlibAtom *atoms = malloc(nUnits * sizeof(*atoms)); XlibAtom *atoms = malloc(nUnits * sizeof(*atoms));
Atom *input = value; Atom *input = value;
char *atomName = NULL; const char *atomName = NULL;
int i; int i;
int j = 0; int j = 0;
...@@ -834,7 +834,7 @@ void nxagentImportProperty(Window window, ...@@ -834,7 +834,7 @@ void nxagentImportProperty(Window window,
WMState wmState; WMState wmState;
char *output = NULL; char *output = NULL;
char *typeS; const char *typeS;
pWin = nxagentWindowPtr(window); pWin = nxagentWindowPtr(window);
......
...@@ -480,7 +480,7 @@ extern Atom MakeAtom( ...@@ -480,7 +480,7 @@ extern Atom MakeAtom(
extern Bool ValidAtom( extern Bool ValidAtom(
Atom /*atom*/); Atom /*atom*/);
extern char *NameForAtom( extern const char *NameForAtom(
Atom /*atom*/); Atom /*atom*/);
extern void AtomError(void); extern void AtomError(void);
......
...@@ -3529,7 +3529,7 @@ register int i,bit; ...@@ -3529,7 +3529,7 @@ register int i,bit;
static Bool static Bool
_XkbCheckTypeName(Atom name,int typeNdx) _XkbCheckTypeName(Atom name,int typeNdx)
{ {
char * str; const char * str;
str= NameForAtom(name); str= NameForAtom(name);
if ((strcmp(str,"ONE_LEVEL")==0)||(strcmp(str,"TWO_LEVEL")==0)|| if ((strcmp(str,"ONE_LEVEL")==0)||(strcmp(str,"TWO_LEVEL")==0)||
......
...@@ -75,7 +75,7 @@ XkbAtomText(Display *dpy,Atom atm,unsigned format) ...@@ -75,7 +75,7 @@ XkbAtomText(Display *dpy,Atom atm,unsigned format)
{ {
char *rtrn,*tmp; char *rtrn,*tmp;
tmp= XkbAtomGetString(dpy,atm); tmp= (char *)XkbAtomGetString(dpy,atm);
if (tmp!=NULL) { if (tmp!=NULL) {
int len; int len;
len= strlen(tmp)+1; len= strlen(tmp)+1;
...@@ -118,7 +118,7 @@ char numBuf[20]; ...@@ -118,7 +118,7 @@ char numBuf[20];
if (ndx>=XkbNumVirtualMods) if (ndx>=XkbNumVirtualMods)
tmp= "illegal"; tmp= "illegal";
else if (vmodNames&&(vmodNames[ndx]!=None)) else if (vmodNames&&(vmodNames[ndx]!=None))
tmp= XkbAtomGetString(dpy,vmodNames[ndx]); tmp= (char *)XkbAtomGetString(dpy,vmodNames[ndx]);
if (tmp==NULL) if (tmp==NULL)
sprintf(tmp=numBuf,"%d",ndx); sprintf(tmp=numBuf,"%d",ndx);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment