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