[PATCH 11/11] Mark XKB char * as const to clean up gcc -Wwrite-strings warnings

Alan Coopersmith alan.coopersmith at oracle.com
Thu Nov 3 22:34:20 PDT 2011


Cleans up around 120 warnings from this set

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---

Brand new patch in this series, without it, patch 8 of this series 
increases the number of -Wwrite-strings warnings a little bit by
passing string literals to TryCopyStr().

 include/xkbfile.h |    4 ++--
 include/xkbsrv.h  |    4 ++--
 xkb/ddxList.c     |    2 +-
 xkb/maprules.c    |    2 +-
 xkb/xkbInit.c     |    4 ++--
 xkb/xkbfmisc.c    |    2 +-
 xkb/xkbout.c      |    6 +++---
 xkb/xkbtext.c     |   20 ++++++++++----------
 8 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/include/xkbfile.h b/include/xkbfile.h
index a4b99ee..db7dbfa 100644
--- a/include/xkbfile.h
+++ b/include/xkbfile.h
@@ -136,7 +136,7 @@ extern _X_EXPORT char *	XkbConfigText(
     unsigned 	/* format */
 );
 
-extern _X_EXPORT char *	XkbSIMatchText(
+extern _X_EXPORT const char *	XkbSIMatchText(
     unsigned	/* type */,
     unsigned	/* format */
 );
@@ -161,7 +161,7 @@ extern _X_EXPORT char *	XkbDoodadTypeText(
     unsigned	/* format */
 );
 
-extern _X_EXPORT char *	XkbActionTypeText(
+extern _X_EXPORT const char *	XkbActionTypeText(
     unsigned	/* type */,
     unsigned	/* format */
 );
diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index c6f86f5..7b00534 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -296,8 +296,8 @@ extern void xkbUnwrapProc(DeviceIntPtr, DeviceHandleProc, pointer);
 extern _X_EXPORT int	XkbReqCode;
 extern _X_EXPORT int	XkbEventBase;
 extern _X_EXPORT int	XkbKeyboardErrorCode;
-extern _X_EXPORT char *	XkbBaseDirectory;
-extern _X_EXPORT char *	XkbBinDirectory;
+extern _X_EXPORT const char *	XkbBaseDirectory;
+extern _X_EXPORT const char *	XkbBinDirectory;
 
 extern _X_EXPORT CARD32	xkbDebugFlags;
 
diff --git a/xkb/ddxList.c b/xkb/ddxList.c
index e599f91..db34c8d 100644
--- a/xkb/ddxList.c
+++ b/xkb/ddxList.c
@@ -60,7 +60,7 @@ extern int Win32System(const char *cmdline);
 
 /***====================================================================***/
 
-static char *componentDirs[_XkbListNumComponents] = {
+static const char *componentDirs[_XkbListNumComponents] = {
 	"keycodes", "types", "compat", "symbols", "geometry"
 };
 
diff --git a/xkb/maprules.c b/xkb/maprules.c
index a14fbbb..6680047 100644
--- a/xkb/maprules.c
+++ b/xkb/maprules.c
@@ -200,7 +200,7 @@ Bool	endOfFile,spacePending,slashPending,inComment;
 #define	PART_MASK	0x000F
 #define	COMPONENT_MASK	0x03F0
 
-static	char *	cname[MAX_WORDS] = {
+static	const char *	cname[MAX_WORDS] = {
 	"model", "layout", "variant", "option", 
 	"keycodes", "symbols", "types", "compat", "geometry"
 };
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index 8ddc992..f578f16 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -88,8 +88,8 @@ typedef struct	_SrvXkmInfo {
 #define	XKB_DFLT_RULES_PROP	TRUE
 #endif
 
-char	*		XkbBaseDirectory=	XKB_BASE_DIRECTORY;
-char	*		XkbBinDirectory=	XKB_BIN_DIRECTORY;
+const char *		XkbBaseDirectory=	XKB_BASE_DIRECTORY;
+const char *		XkbBinDirectory=	XKB_BIN_DIRECTORY;
 static int	 	XkbWantAccessX=		0;	
 
 static char *		XkbRulesDflt=		NULL;
diff --git a/xkb/xkbfmisc.c b/xkb/xkbfmisc.c
index d8202b4..782b823 100644
--- a/xkb/xkbfmisc.c
+++ b/xkb/xkbfmisc.c
@@ -146,7 +146,7 @@ unsigned	set,rtrn;
 /***===================================================================***/
 
 static Bool
-XkbWriteSectionFromName(FILE *file,char *sectionName,char *name)
+XkbWriteSectionFromName(FILE *file,const char *sectionName,const char *name)
 {
     fprintf(file,"    xkb_%-20s { include \"%s\" };\n",sectionName,name);
     return TRUE;
diff --git a/xkb/xkbout.c b/xkb/xkbout.c
index 082c85e..889d5cc 100644
--- a/xkb/xkbout.c
+++ b/xkb/xkbout.c
@@ -108,7 +108,7 @@ XkbWriteXKBKeycodes(	FILE *			file,
 {
 Atom			kcName;
 register unsigned 	i;
-char *			alternate;
+const char *		alternate;
 
     if ((!xkb)||(!xkb->names)||(!xkb->names->keys)) {
 	_XkbLibError(_XkbErrMissingNames,"XkbWriteXKBKeycodes",0);
@@ -133,7 +133,7 @@ char *			alternate;
     }
     if (xkb->indicators!=NULL) {
 	for (i=0;i<XkbNumIndicators;i++) {
-	    char *type;
+	    const char *type;
 	    if (xkb->indicators->phys_indicators&(1<<i))
 			type= "    ";
 	    else	type= "    virtual ";
@@ -395,7 +395,7 @@ Bool			showActions;
 	   						(showImplicit)) {
 		int 	typeNdx,g;
 		Bool	multi;
-		char *	comment="  ";
+		const char *	comment="  ";
 
 		if ((srv->explicit[i]&XkbExplicitKeyTypesMask)==0)
 		    comment= "//";
diff --git a/xkb/xkbtext.c b/xkb/xkbtext.c
index f31f53a..8ef2b05 100644
--- a/xkb/xkbtext.c
+++ b/xkb/xkbtext.c
@@ -215,7 +215,7 @@ char *str,buf[BUFFER_SIZE];
     return rtrn;
 }
 
-static char *modNames[XkbNumModifiers] = {
+static const char *modNames[XkbNumModifiers] = {
     "Shift", "Lock", "Control", "Mod1", "Mod2", "Mod3", "Mod4", "Mod5"
 };
 
@@ -367,15 +367,15 @@ char *buf;
 
 /***====================================================================***/
 
-static char *siMatchText[5] = {
+static const char *siMatchText[5] = {
 	"NoneOf", "AnyOfOrNone", "AnyOf", "AllOf", "Exactly"
 };
 
-char *
+const char *
 XkbSIMatchText(unsigned type,unsigned format)
 {
 static char buf[40];
-char *rtrn;
+const char *rtrn;
 
     switch (type&XkbSI_OpMask) {
 	case XkbSI_NoneOf:	rtrn= siMatchText[0]; break;
@@ -397,7 +397,7 @@ char *rtrn;
 
 /***====================================================================***/
 
-static char *imWhichNames[]= {
+static const char *imWhichNames[]= {
 	"base",
 	"latched",
 	"locked",
@@ -448,7 +448,7 @@ char *		buf;
     return buf;
 }
 
-static char *ctrlNames[] = {
+static const char *ctrlNames[] = {
 	"repeatKeys",
 	"slowKeys",
 	"bounceKeys",
@@ -616,7 +616,7 @@ char *	buf;
     return buf;
 }
 
-static char *actionTypeNames[XkbSA_NumActions]= {
+static const char *actionTypeNames[XkbSA_NumActions]= {
     "NoAction", 
     "SetMods",      "LatchMods",    "LockMods", 
     "SetGroup",     "LatchGroup",   "LockGroup",
@@ -631,11 +631,11 @@ static char *actionTypeNames[XkbSA_NumActions]= {
     "DeviceBtn",    "LockDeviceBtn"
 };
 
-char *
+const char *
 XkbActionTypeText(unsigned type,unsigned format)
 {
 static char buf[32];
-char *rtrn;
+const char *rtrn;
 
     if (type<=XkbSA_LastAction) {
 	rtrn= actionTypeNames[type];
@@ -652,7 +652,7 @@ char *rtrn;
 /***====================================================================***/
 
 static int
-TryCopyStr(char *to,char *from,int *pLeft)
+TryCopyStr(char *to,const char *from,int *pLeft)
 {
 register int len;
     if (*pLeft>0) {
-- 
1.7.3.2



More information about the xorg-devel mailing list