[PATCH:libICE 4/6] Fix gcc -Wwrite-strings warnings in AuthNames handling

Alan Coopersmith alan.coopersmith at oracle.com
Wed Nov 9 22:19:53 PST 2011


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 src/ICElibint.h  |   26 +++++++++++++-------------
 src/getauth.c    |   40 ++++++++++++++++++++--------------------
 src/globals.h    |    2 +-
 src/process.c    |   11 ++++++-----
 src/protosetup.c |    2 +-
 5 files changed, 41 insertions(+), 40 deletions(-)

diff --git a/src/ICElibint.h b/src/ICElibint.h
index 1254f6a..0638fb0 100644
--- a/src/ICElibint.h
+++ b/src/ICElibint.h
@@ -397,7 +397,7 @@ extern _IceProtocol	_IceProtocols[];
 extern int         	_IceLastMajorOpcode;
 
 extern int		_IceAuthCount;
-extern char		*_IceAuthNames[];
+extern const char	*_IceAuthNames[];
 extern IcePoAuthProc	_IcePoAuthProcs[];
 extern IcePaAuthProc	_IcePaAuthProcs[];
 
@@ -505,35 +505,35 @@ extern void _IceConnectionClosed (
 );
 
 extern void _IceGetPoAuthData (
-    char *		/* protocol_name */,
-    char *		/* address */,
-    char *		/* auth_name */,
+    const char *	/* protocol_name */,
+    const char *	/* address */,
+    const char *	/* auth_name */,
     unsigned short *	/* auth_data_length_ret */,
     char **		/* auth_data_ret */
 );
 
 extern void _IceGetPaAuthData (
-    char *		/* protocol_name */,
-    char *		/* address */,
-    char *		/* auth_name */,
+    const char *	/* protocol_name */,
+    const char *	/* address */,
+    const char *	/* auth_name */,
     unsigned short *	/* auth_data_length_ret */,
     char **		/* auth_data_ret */
 );
 
 extern void _IceGetPoValidAuthIndices (
-    char *		/* protocol_name */,
-    char *		/* address */,
+    const char *	/* protocol_name */,
+    const char *	/* address */,
     int			/* num_auth_names */,
-    char **		/* auth_names */,
+    const char **	/* auth_names */,
     int	*		/* num_indices_ret */,
     int	*		/* indices_ret */
 );
 
 extern void _IceGetPaValidAuthIndices (
-    char *		/* protocol_name */,
-    char *		/* address */,
+    const char *	/* protocol_name */,
+    const char *	/* address */,
     int			/* num_auth_names */,
-    char **		/* auth_names */,
+    const char **	/* auth_names */,
     int	*		/* num_indices_ret */,
     int	*		/* indices_ret */
 );
diff --git a/src/getauth.c b/src/getauth.c
index fdacd24..e127206 100644
--- a/src/getauth.c
+++ b/src/getauth.c
@@ -33,7 +33,7 @@ Author: Ralph Mor, X Consortium
 #include "ICElibint.h"
 
 static Bool auth_valid (const char *auth_name, int num_auth_names,
-			char **auth_names, int *index_ret);
+			const char **auth_names, int *index_ret);
 
 
 /*
@@ -55,9 +55,9 @@ static Bool auth_valid (const char *auth_name, int num_auth_names,
 
 void
 _IceGetPoAuthData (
-	char		*protocolName,
-	char		*networkId,
-	char		*authName,
+	const char	*protocolName,
+	const char	*networkId,
+	const char	*authName,
 	unsigned short	*authDataLenRet,
 	char		**authDataRet
 )
@@ -86,9 +86,9 @@ _IceGetPoAuthData (
 
 void
 _IceGetPaAuthData (
-	char		*protocolName,
-	char		*networkId,
-	char		*authName,
+	const char	*protocolName,
+	const char	*networkId,
+	const char	*authName,
 	unsigned short	*authDataLenRet,
 	char		**authDataRet
 )
@@ -125,12 +125,12 @@ _IceGetPaAuthData (
 
 void
 _IceGetPoValidAuthIndices (
-	char	*protocol_name,
-	char	*network_id,
-	int	num_auth_names,
-	char	**auth_names,
-	int	*num_indices_ret,
-	int	*indices_ret		/* in/out arg */
+	const char	*protocol_name,
+	const char	*network_id,
+	int		num_auth_names,
+	const char	**auth_names,
+	int		*num_indices_ret,
+	int		*indices_ret		/* in/out arg */
 )
 {
     FILE    		*auth_file;
@@ -184,12 +184,12 @@ _IceGetPoValidAuthIndices (
 
 void
 _IceGetPaValidAuthIndices (
-	char	*protocol_name,
-	char	*network_id,
-	int	num_auth_names,
-	char	**auth_names,
-	int	*num_indices_ret,
-	int	*indices_ret		/* in/out arg */
+	const char	*protocol_name,
+	const char	*network_id,
+	int		num_auth_names,
+	const char	**auth_names,
+	int		*num_indices_ret,
+	int		*indices_ret		/* in/out arg */
 )
 {
     int			index_ret;
@@ -232,7 +232,7 @@ _IceGetPaValidAuthIndices (
 
 static Bool
 auth_valid (const char *auth_name, int num_auth_names,
-	    char **auth_names, int *index_ret)
+	    const char **auth_names, int *index_ret)
 
 {
     /*
diff --git a/src/globals.h b/src/globals.h
index 2102384..965386f 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -40,6 +40,6 @@ int     	_IceConnectionCount = 0;
 int         	_IceLastMajorOpcode = 0;
 
 int		_IceAuthCount = 1;
-char		*_IceAuthNames[] = {"MIT-MAGIC-COOKIE-1"};
+const char	*_IceAuthNames[] = {"MIT-MAGIC-COOKIE-1"};
 
 _IceWatchProc	*_IceWatchProcs = NULL;
diff --git a/src/process.c b/src/process.c
index dbff404..2bb8d55 100644
--- a/src/process.c
+++ b/src/process.c
@@ -861,7 +861,7 @@ ProcessConnectionSetup (
     int  hisMajorVersion, hisMinorVersion;
     int	 myAuthCount, hisAuthCount;
     int	 found, i, j;
-    char *myAuthName, **hisAuthNames = NULL;
+    char **hisAuthNames = NULL;
     char *pData, *pStart, *pEnd;
     char *vendor = NULL;
     char *release = NULL;
@@ -983,7 +983,7 @@ ProcessConnectionSetup (
     {
 	if (authUsableFlags[i])
 	{
-	    myAuthName = _IceAuthNames[i];
+	    const char *myAuthName = _IceAuthNames[i];
 
 	    for (j = 0; j < hisAuthCount && !found; j++)
 		if (strcmp (myAuthName, hisAuthNames[j]) == 0)
@@ -1838,7 +1838,7 @@ ProcessProtocolSetup (
     int	 	      	myAuthCount, hisAuthCount;
     int  	      	myOpcode, hisOpcode;
     int	 	      	found, i, j;
-    char	      	*myAuthName, **hisAuthNames = NULL;
+    char	      	**hisAuthNames = NULL;
     char 	      	*protocolName;
     char 		*pData, *pStart, *pEnd;
     char 	      	*vendor = NULL;
@@ -2009,7 +2009,8 @@ ProcessProtocolSetup (
 
     _IceGetPaValidAuthIndices (
 	_IceProtocols[myOpcode - 1].protocol_name,
-	iceConn->connection_string, myAuthCount, myProtocol->auth_names,
+	iceConn->connection_string, myAuthCount,
+	(const char **) myProtocol->auth_names,
         &authUsableCount, authIndices);
 
     for (i = 0; i < myAuthCount; i++)
@@ -2023,7 +2024,7 @@ ProcessProtocolSetup (
     {
 	if (authUsableFlags[i])
 	{
-	    myAuthName = myProtocol->auth_names[i];
+	    const char *myAuthName = myProtocol->auth_names[i];
 
 	    for (j = 0; j < hisAuthCount && !found; j++)
 		if (strcmp (myAuthName, hisAuthNames[j]) == 0)
diff --git a/src/protosetup.c b/src/protosetup.c
index a42b1a4..255b912 100644
--- a/src/protosetup.c
+++ b/src/protosetup.c
@@ -118,7 +118,7 @@ IceProtocolSetup (
 	_IceGetPoValidAuthIndices (myProtocol->protocol_name,
 	    iceConn->connection_string,
 	    myProtocol->orig_client->auth_count,
-	    myProtocol->orig_client->auth_names,
+	    (const char **) myProtocol->orig_client->auth_names,
             &authCount, authIndices);
 
     }
-- 
1.7.3.2



More information about the xorg-devel mailing list