[PATCH:xfs 1/4] Fix gcc -Wwrite-strings warnings for initialization with string literals

Alan Coopersmith alan.coopersmith at oracle.com
Sat Sep 17 01:03:23 PDT 2011


Many warnings of the form:
os/config.c:92:5: warning: initialization discards qualifiers from pointer target type

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 difs/difsutils.c    |   10 +++++-----
 include/difsutils.h |    2 +-
 include/os.h        |   10 +++++-----
 os/config.c         |    4 ++--
 os/configstr.h      |    2 +-
 os/error.c          |    8 ++++----
 os/osglue.c         |    6 +++---
 os/utils.c          |    2 +-
 8 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/difs/difsutils.c b/difs/difsutils.c
index 1149bad..1028a3c 100644
--- a/difs/difsutils.c
+++ b/difs/difsutils.c
@@ -210,15 +210,15 @@ CopyISOLatin1Lowered(char *d, char *s, int length)
 
 int
 strncmpnocase(
-    char       *first,
-    char       *second,
+    const char *first,
+    const char *second,
     int         n)
 {
-    register unsigned char *ap,
+    register const unsigned char *ap,
                *bp;
 
-    for (ap = (unsigned char *) first,
-	    bp = (unsigned char *) second;
+    for (ap = (const unsigned char *) first,
+	    bp = (const unsigned char *) second;
     /* SUPPRESS 112 */
 	    n > 0 && *ap && *bp; n--, ap++, bp++) {
 	register unsigned char a,
diff --git a/include/difsutils.h b/include/difsutils.h
index 3913358..43f1f8b 100644
--- a/include/difsutils.h
+++ b/include/difsutils.h
@@ -52,7 +52,7 @@ extern int SetDefaultResolutions (char *str);
 extern int client_auth_generation (ClientPtr client);
 #endif
 extern int set_font_authorizations (char **authorizations, int *authlen, ClientPtr client);
-extern int strncmpnocase (char *first, char *second, int n);
+extern int strncmpnocase (const char *first, const char *second, int n);
 extern pointer Xalloc (unsigned long m);
 extern pointer Xrealloc (pointer n, unsigned long m);
 extern void BlockHandler (OSTimePtr pTimeout, pointer pReadmask);
diff --git a/include/os.h b/include/os.h
index 8f99186..58238ec 100644
--- a/include/os.h
+++ b/include/os.h
@@ -95,12 +95,12 @@ extern	void	BecomeDaemon(void);
 extern	void	DetachStdio(void);
 
 /* os/error.c */
-extern void	Error(char *str);
+extern void	Error(const char *str);
 extern void	InitErrors(void);
 extern void	CloseErrors(void);
-extern void	NoticeF(char *f, ...);
-extern void	ErrorF(char * f, ...);
-extern void	FatalError(char* f, ...);
+extern void	NoticeF(const char *f, ...);
+extern void	ErrorF(const char * f, ...);
+extern void	FatalError(const char* f, ...);
 
 /* os/io.c */
 extern	Bool	InsertFakeRequest(ClientPtr client, char *data, int count);
@@ -114,7 +114,7 @@ extern	void	WriteToClient(ClientPtr client, int count, char *buf);
 extern	void	WriteToClientUnpadded(ClientPtr client, int count, char *buf);
 
 /* os/osglue.c */
-extern int 	ListCatalogues(char *pattern, int patlen, int maxnames, char **catalogues, int *len);
+extern int 	ListCatalogues(const char *pattern, int patlen, int maxnames, char **catalogues, int *len);
 extern int 	ValidateCatalogues(int *num, char *cats);
 extern int 	SetAlternateServers(char *list);
 extern int 	ListAlternateServers(AlternateServerPtr *svrs);
diff --git a/os/config.c b/os/config.c
index 6b1b08e..358189a 100644
--- a/os/config.c
+++ b/os/config.c
@@ -106,7 +106,7 @@ static ConfigOptionRec config_options[] = {
     {NULL, NULL},
 };
 
-char       *ConfigErrors[] = {
+static const char * const ConfigErrors[] = {
     "",
     "CONFIG: insufficient memory to load configuration file \"%s\"\n",
     "CONFIG: can't open configuration file \"%s\"\n",
@@ -387,7 +387,7 @@ ReadConfigFile(const char *filename)
 }
 
 struct nameVal {
-    char       *name;
+    const char *name;
     int         val;
 };
 
diff --git a/os/configstr.h b/os/configstr.h
index 0d55e23..9743852 100644
--- a/os/configstr.h
+++ b/os/configstr.h
@@ -51,7 +51,7 @@ in this Software without prior written authorization from The Open Group.
 typedef struct _config_options ConfigOptionRec, *ConfigOptionPtr;
 
 struct _config_options {
-    char       *parm_name;
+    const char *parm_name;
     char       *(*set_func) (ConfigOptionPtr, char *);
 };
 
diff --git a/os/error.c b/os/error.c
index d078f64..4dc27a8 100644
--- a/os/error.c
+++ b/os/error.c
@@ -131,7 +131,7 @@ CloseErrors(void)
 }
 
 void
-Error(char *str)
+Error(const char *str)
 {
 #ifdef USE_SYSLOG
     if (UseSyslog) {
@@ -146,7 +146,7 @@ Error(char *str)
  * used for informational messages
  */
 void
-NoticeF(char *f, ...)
+NoticeF(const char *f, ...)
 {
     /* XXX should Notices just be ignored if not using syslog? */
     va_list args;
@@ -167,7 +167,7 @@ NoticeF(char *f, ...)
  * used for non-fatal error messages
  */
 void
-ErrorF(char * f, ...)
+ErrorF(const char * f, ...)
 {
     va_list args;
     va_start(args, f);
@@ -184,7 +184,7 @@ ErrorF(char * f, ...)
 }
 
 void
-FatalError(char * f, ...)
+FatalError(const char * f, ...)
 {
     va_list args;
     va_start(args, f);
diff --git a/os/osglue.c b/os/osglue.c
index bcfce2f..2a16a9a 100644
--- a/os/osglue.c
+++ b/os/osglue.c
@@ -80,10 +80,10 @@ static AlternateServerPtr alt_servers = (AlternateServerPtr) 0;
  *
  */
 
-static char *catalogue_name = "all";
+static const char *catalogue_name = "all";
 
 static Bool			/* stolen from R4 Match() */
-pattern_match(char *pat, int plen, char *string)
+pattern_match(const char *pat, int plen, const char *string)
 {
     register int i,
                 l;
@@ -153,7 +153,7 @@ pattern_match(char *pat, int plen, char *string)
 }
 
 int
-ListCatalogues(char *pattern, int patlen, int maxnames, 
+ListCatalogues(const char *pattern, int patlen, int maxnames,
 	       char **catalogues, int *len)
 {
     int         count = 0;
diff --git a/os/utils.c b/os/utils.c
index 7714e75..7aa2188 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -88,7 +88,7 @@ int 	     OldListenCount = 0;
 #endif
 #define WRITES(s) write(STDERR_FILENO, s, strlen(s))
 
-static char *pidFile = XFSPIDDIR "/xfs.pid";
+static const char *pidFile = XFSPIDDIR "/xfs.pid";
 static int  pidFd;
 static FILE *pidFilePtr;
 static int  StorePid (void);
-- 
1.7.3.2



More information about the xorg-devel mailing list