[PATCH:libICE 1/6] Fix gcc -Wwrite-strings warnings in _IceDefaultErrorHandler

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


Had to split char *str into two variables, const char *str for the
string literals just being passed to fprintf etal.  and char *estr
for use by EXTRACT_STRING for the results of malloc calls that get
written to and then freed.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 src/error.c |   35 ++++++++++++++++++-----------------
 1 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/src/error.c b/src/error.c
index d9419b1..044914a 100644
--- a/src/error.c
+++ b/src/error.c
@@ -364,7 +364,8 @@ _IceDefaultErrorHandler (
 	IcePointer	values
 )
 {
-    char *str;
+    const char *str;
+    char *estr;
     char *pData = (char *) values;
 
     switch (offendingMinorOpcode)
@@ -512,42 +513,42 @@ _IceDefaultErrorHandler (
 
         case IceSetupFailed:
 
-	    EXTRACT_STRING (pData, swap, str);
-	    fprintf (stderr, "Reason : %s\n", str);
-	    free(str);
+            EXTRACT_STRING (pData, swap, estr);
+            fprintf (stderr, "Reason : %s\n", estr);
+            free(estr);
             break;
 
         case IceAuthRejected:
 
-	    EXTRACT_STRING (pData, swap, str);
-	    fprintf (stderr, "Reason : %s\n", str);
-	    free(str);
+            EXTRACT_STRING (pData, swap, estr);
+            fprintf (stderr, "Reason : %s\n", estr);
+            free(estr);
             break;
 
         case IceAuthFailed:
 
-	    EXTRACT_STRING (pData, swap, str);
-	    fprintf (stderr, "Reason : %s\n", str);
-	    free(str);
+            EXTRACT_STRING (pData, swap, estr);
+            fprintf (stderr, "Reason : %s\n", estr);
+            free(estr);
             break;
 
         case IceProtocolDuplicate:
 
-	    EXTRACT_STRING (pData, swap, str);
-	    fprintf (stderr, "Protocol name : %s\n", str);
-	    free(str);
+            EXTRACT_STRING (pData, swap, estr);
+            fprintf (stderr, "Protocol name : %s\n", estr);
+            free(estr);
             break;
 
         case IceMajorOpcodeDuplicate:
 
-	    fprintf (stderr, "Major opcode : %d\n", (int) *pData);
+            fprintf (stderr, "Major opcode : %d\n", (int) *pData);
             break;
 
         case IceUnknownProtocol:
 
-	    EXTRACT_STRING (pData, swap, str);
-	    fprintf (stderr, "Protocol name : %s\n", str);
-	    free(str);
+            EXTRACT_STRING (pData, swap, estr);
+            fprintf (stderr, "Protocol name : %s\n", estr);
+            free(estr);
             break;
 
 	default:
-- 
1.7.3.2



More information about the xorg-devel mailing list