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>
This commit is contained in:
parent
6869efae74
commit
5623c27700
15
dix/atom.c
15
dix/atom.c
|
@ -64,7 +64,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;
|
||||||
|
@ -75,7 +75,7 @@ static NodePtr *nodeTable;
|
||||||
void FreeAtom(NodePtr patom);
|
void FreeAtom(NodePtr patom);
|
||||||
|
|
||||||
Atom
|
Atom
|
||||||
MakeAtom(char *string, unsigned len, Bool makeit)
|
MakeAtom(const char *string, unsigned len, Bool makeit)
|
||||||
{
|
{
|
||||||
NodePtr * np;
|
NodePtr * np;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
@ -118,13 +118,14 @@ MakeAtom(char *string, unsigned len, Bool makeit)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nd->string = xalloc(len + 1);
|
char *newstring = xalloc(len + 1);
|
||||||
if (!nd->string) {
|
if (!newstring) {
|
||||||
xfree(nd);
|
xfree(nd);
|
||||||
return BAD_RESOURCE;
|
return BAD_RESOURCE;
|
||||||
}
|
}
|
||||||
strncpy(nd->string, string, (int)len);
|
strncpy(newstring, string, (int)len);
|
||||||
nd->string[len] = 0;
|
newstring[len] = 0;
|
||||||
|
nd->string = newstring;
|
||||||
}
|
}
|
||||||
if ((lastAtom + 1) >= tableLength) {
|
if ((lastAtom + 1) >= tableLength) {
|
||||||
NodePtr *table;
|
NodePtr *table;
|
||||||
|
@ -157,7 +158,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;
|
||||||
|
|
|
@ -901,7 +901,7 @@ ProcInternAtom(ClientPtr client)
|
||||||
int
|
int
|
||||||
ProcGetAtomName(ClientPtr client)
|
ProcGetAtomName(ClientPtr client)
|
||||||
{
|
{
|
||||||
char *str;
|
const char *str;
|
||||||
xGetAtomNameReply reply;
|
xGetAtomNameReply reply;
|
||||||
int len;
|
int len;
|
||||||
REQUEST(xResourceReq);
|
REQUEST(xResourceReq);
|
||||||
|
|
|
@ -253,7 +253,7 @@ Bool dmxBELoadFont(ScreenPtr pScreen, FontPtr pFont)
|
||||||
{
|
{
|
||||||
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
|
||||||
dmxFontPrivPtr pFontPriv = FontGetPrivate(pFont, dmxFontPrivateIndex);
|
dmxFontPrivPtr pFontPriv = FontGetPrivate(pFont, dmxFontPrivateIndex);
|
||||||
char *name;
|
const char *name;
|
||||||
char **oldFontPath = NULL;
|
char **oldFontPath = NULL;
|
||||||
int nOldPaths;
|
int nOldPaths;
|
||||||
Atom name_atom, value_atom;
|
Atom name_atom, value_atom;
|
||||||
|
@ -415,7 +415,7 @@ Bool dmxBELoadFont(ScreenPtr pScreen, FontPtr pFont)
|
||||||
}
|
}
|
||||||
if (!value_atom) return FALSE;
|
if (!value_atom) return FALSE;
|
||||||
|
|
||||||
name = (char *)NameForAtom(value_atom);
|
name = NameForAtom(value_atom);
|
||||||
if (!name) return FALSE;
|
if (!name) return FALSE;
|
||||||
|
|
||||||
pFontPriv->font[pScreen->myNum] =
|
pFontPriv->font[pScreen->myNum] =
|
||||||
|
|
|
@ -236,7 +236,7 @@ DoSimpleClip (BoxPtr a_dst_box,
|
||||||
static Bool
|
static Bool
|
||||||
ephyrLocalAtomToHost (int a_local_atom, int *a_host_atom)
|
ephyrLocalAtomToHost (int a_local_atom, int *a_host_atom)
|
||||||
{
|
{
|
||||||
char *atom_name=NULL;
|
const char *atom_name=NULL;
|
||||||
int host_atom=None ;
|
int host_atom=None ;
|
||||||
|
|
||||||
EPHYR_RETURN_VAL_IF_FAIL (a_host_atom, FALSE) ;
|
EPHYR_RETURN_VAL_IF_FAIL (a_host_atom, FALSE) ;
|
||||||
|
|
|
@ -40,7 +40,7 @@ xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont)
|
||||||
int nprops;
|
int nprops;
|
||||||
FontPropPtr props;
|
FontPropPtr props;
|
||||||
int i;
|
int i;
|
||||||
char *name;
|
const char *name;
|
||||||
|
|
||||||
FontSetPrivate(pFont, xnestFontPrivateIndex, NULL);
|
FontSetPrivate(pFont, xnestFontPrivateIndex, NULL);
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont)
|
||||||
|
|
||||||
if (!value_atom) return False;
|
if (!value_atom) return False;
|
||||||
|
|
||||||
name = (char *)NameForAtom(value_atom);
|
name = NameForAtom(value_atom);
|
||||||
|
|
||||||
if (!name) return False;
|
if (!name) return False;
|
||||||
|
|
||||||
|
|
|
@ -280,14 +280,14 @@ extern _X_EXPORT Bool ClientIsAsleep(
|
||||||
/* atom.c */
|
/* atom.c */
|
||||||
|
|
||||||
extern _X_EXPORT Atom MakeAtom(
|
extern _X_EXPORT Atom MakeAtom(
|
||||||
char * /*string*/,
|
const char * /*string*/,
|
||||||
unsigned /*len*/,
|
unsigned /*len*/,
|
||||||
Bool /*makeit*/);
|
Bool /*makeit*/);
|
||||||
|
|
||||||
extern _X_EXPORT Bool ValidAtom(
|
extern _X_EXPORT Bool ValidAtom(
|
||||||
Atom /*atom*/);
|
Atom /*atom*/);
|
||||||
|
|
||||||
extern _X_EXPORT char *NameForAtom(
|
extern _X_EXPORT const char *NameForAtom(
|
||||||
Atom /*atom*/);
|
Atom /*atom*/);
|
||||||
|
|
||||||
extern _X_EXPORT void AtomError(void);
|
extern _X_EXPORT void AtomError(void);
|
||||||
|
|
|
@ -880,7 +880,7 @@ extern _X_EXPORT XkbGeometryPtr XkbLookupNamedGeometry(
|
||||||
);
|
);
|
||||||
|
|
||||||
extern _X_EXPORT char * _XkbDupString(
|
extern _X_EXPORT char * _XkbDupString(
|
||||||
char * /* str */
|
const char * /* str */
|
||||||
);
|
);
|
||||||
|
|
||||||
extern _X_EXPORT void XkbConvertCase(
|
extern _X_EXPORT void XkbConvertCase(
|
||||||
|
|
|
@ -457,7 +457,7 @@ ProcXFixesGetCursorName (ClientPtr client)
|
||||||
CursorPtr pCursor;
|
CursorPtr pCursor;
|
||||||
xXFixesGetCursorNameReply reply;
|
xXFixesGetCursorNameReply reply;
|
||||||
REQUEST(xXFixesGetCursorNameReq);
|
REQUEST(xXFixesGetCursorNameReq);
|
||||||
char *str;
|
const char *str;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xXFixesGetCursorNameReq);
|
REQUEST_SIZE_MATCH(xXFixesGetCursorNameReq);
|
||||||
|
@ -507,7 +507,7 @@ ProcXFixesGetCursorImageAndName (ClientPtr client)
|
||||||
CursorPtr pCursor;
|
CursorPtr pCursor;
|
||||||
CARD32 *image;
|
CARD32 *image;
|
||||||
int npixels;
|
int npixels;
|
||||||
char *name;
|
const char *name;
|
||||||
int nbytes, nbytesRound;
|
int nbytes, nbytesRound;
|
||||||
int width, height;
|
int width, height;
|
||||||
int rc, x, y;
|
int rc, x, y;
|
||||||
|
|
|
@ -3853,7 +3853,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)||
|
||||||
|
|
|
@ -163,7 +163,7 @@ XkbWriteXKBKeymapForNames( FILE * file,
|
||||||
unsigned want,
|
unsigned want,
|
||||||
unsigned need)
|
unsigned need)
|
||||||
{
|
{
|
||||||
char * tmp;
|
const char * tmp;
|
||||||
unsigned complete;
|
unsigned complete;
|
||||||
XkbNamesPtr old_names;
|
XkbNamesPtr old_names;
|
||||||
int multi_section;
|
int multi_section;
|
||||||
|
|
|
@ -70,16 +70,17 @@ char *rtrn;
|
||||||
char *
|
char *
|
||||||
XkbAtomText(Atom atm,unsigned format)
|
XkbAtomText(Atom atm,unsigned format)
|
||||||
{
|
{
|
||||||
|
const char *atmstr;
|
||||||
char *rtrn,*tmp;
|
char *rtrn,*tmp;
|
||||||
|
|
||||||
tmp= XkbAtomGetString(atm);
|
atmstr = XkbAtomGetString(atm);
|
||||||
if (tmp!=NULL) {
|
if (atmstr != NULL) {
|
||||||
int len;
|
int len;
|
||||||
len= strlen(tmp)+1;
|
len= strlen(atmstr)+1;
|
||||||
if (len>BUFFER_SIZE)
|
if (len>BUFFER_SIZE)
|
||||||
len= BUFFER_SIZE-2;
|
len= BUFFER_SIZE-2;
|
||||||
rtrn= tbGetBuffer(len);
|
rtrn= tbGetBuffer(len);
|
||||||
strncpy(rtrn,tmp,len);
|
strncpy(rtrn,atmstr,len);
|
||||||
rtrn[len]= '\0';
|
rtrn[len]= '\0';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -104,7 +105,8 @@ XkbVModIndexText(XkbDescPtr xkb,unsigned ndx,unsigned format)
|
||||||
{
|
{
|
||||||
register int len;
|
register int len;
|
||||||
register Atom *vmodNames;
|
register Atom *vmodNames;
|
||||||
char *rtrn,*tmp;
|
char *rtrn;
|
||||||
|
const char *tmp;
|
||||||
char numBuf[20];
|
char numBuf[20];
|
||||||
|
|
||||||
if (xkb && xkb->names)
|
if (xkb && xkb->names)
|
||||||
|
@ -116,8 +118,10 @@ char numBuf[20];
|
||||||
tmp= "illegal";
|
tmp= "illegal";
|
||||||
else if (vmodNames&&(vmodNames[ndx]!=None))
|
else if (vmodNames&&(vmodNames[ndx]!=None))
|
||||||
tmp= XkbAtomGetString(vmodNames[ndx]);
|
tmp= XkbAtomGetString(vmodNames[ndx]);
|
||||||
if (tmp==NULL)
|
if (tmp==NULL) {
|
||||||
sprintf(tmp=numBuf,"%d",ndx);
|
sprintf(numBuf,"%d",ndx);
|
||||||
|
tmp = numBuf;
|
||||||
|
}
|
||||||
|
|
||||||
len= strlen(tmp)+1;
|
len= strlen(tmp)+1;
|
||||||
if (format==XkbCFile)
|
if (format==XkbCFile)
|
||||||
|
|
|
@ -51,7 +51,7 @@ XkbInternAtom(char *str,Bool only_if_exists)
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
_XkbDupString(char *str)
|
_XkbDupString(const char *str)
|
||||||
{
|
{
|
||||||
char *new;
|
char *new;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue