[PATCH:libXfont 1/4] Add const attributes to fix gcc -Wwrite-strings warnings

Alan Coopersmith alan.coopersmith at oracle.com
Fri Oct 21 20:56:47 PDT 2011


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 include/X11/fonts/bdfint.h   |    6 +++---
 include/X11/fonts/fntfil.h   |    2 +-
 include/X11/fonts/fntfilst.h |    2 +-
 include/X11/fonts/fontmisc.h |    2 +-
 src/FreeType/ftenc.c         |    6 +++---
 src/FreeType/ftfuncs.c       |    2 +-
 src/bitmap/bdfutils.c        |   12 ++++++------
 src/bitmap/bitscale.c        |    2 +-
 src/builtins/builtin.h       |    2 +-
 src/fc/fsio.c                |    6 +++---
 src/fc/fsio.h                |    4 ++--
 src/fontfile/fontdir.c       |    4 ++--
 src/util/atom.c              |    4 ++--
 src/util/fontxlfd.c          |    2 +-
 14 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/include/X11/fonts/bdfint.h b/include/X11/fonts/bdfint.h
index a8d8459..c037b99 100644
--- a/include/X11/fonts/bdfint.h
+++ b/include/X11/fonts/bdfint.h
@@ -65,11 +65,11 @@ typedef struct BDFSTAT {
     BOOL        haveDefaultCh;
 }           bdfFileState;
 
-extern void bdfError ( char * message, ... );
-extern void bdfWarning ( char *message, ... );
+extern void bdfError ( const char * message, ... );
+extern void bdfWarning ( const char *message, ... );
 extern unsigned char * bdfGetLine ( FontFilePtr file, unsigned char *buf,
 				    int len );
-extern Atom bdfForceMakeAtom ( char *str, int *size );
+extern Atom bdfForceMakeAtom ( const char *str, int *size );
 extern Atom bdfGetPropertyValue ( char *s );
 extern int bdfIsInteger ( char *str );
 extern unsigned char bdfHexByte ( unsigned char *s );
diff --git a/include/X11/fonts/fntfil.h b/include/X11/fonts/fntfil.h
index feefdb3..a32df63 100644
--- a/include/X11/fonts/fntfil.h
+++ b/include/X11/fonts/fntfil.h
@@ -138,7 +138,7 @@ extern void FontFileFreeDir ( FontDirectoryPtr dir );
 extern void FontFileFreeEntry ( FontEntryPtr entry );
 extern void FontFileFreeTable ( FontTablePtr table );
 extern Bool FontFileInitTable ( FontTablePtr table, int size );
-extern FontDirectoryPtr FontFileMakeDir ( char *dirName, int size );
+extern FontDirectoryPtr FontFileMakeDir ( const char *dirName, int size );
 extern Bool FontFileMatchName ( char *name, int length, FontNamePtr pat );
 extern char * FontFileSaveString ( char *s );
 extern void FontFileSortDir ( FontDirectoryPtr dir );
diff --git a/include/X11/fonts/fntfilst.h b/include/X11/fonts/fntfilst.h
index 8926f95..6e8645e 100644
--- a/include/X11/fonts/fntfilst.h
+++ b/include/X11/fonts/fntfilst.h
@@ -124,7 +124,7 @@ typedef struct _FontDirectory {
 #define CAP_CHARSUBSETTING	0x2
 
 typedef struct _FontRenderer {
-    char    *fileSuffix;
+    const char    *fileSuffix;
     int	    fileSuffixLen;
     int	    (*OpenBitmap)(FontPathElementPtr /* fpe */,
 			  FontPtr * /* pFont */,
diff --git a/include/X11/fonts/fontmisc.h b/include/X11/fonts/fontmisc.h
index 3da1e63..73a8247 100644
--- a/include/X11/fonts/fontmisc.h
+++ b/include/X11/fonts/fontmisc.h
@@ -52,7 +52,7 @@ in this Software without prior written authorization from The Open Group.
 #define FALSE 0
 #endif
 
-extern Atom MakeAtom ( char *string, unsigned len, int makeit );
+extern Atom MakeAtom ( const char *string, unsigned len, int makeit );
 extern int ValidAtom ( Atom atom );
 extern char *NameForAtom (Atom atom);
 
diff --git a/src/FreeType/ftenc.c b/src/FreeType/ftenc.c
index 3c1d43b..9e31d75 100644
--- a/src/FreeType/ftenc.c
+++ b/src/FreeType/ftenc.c
@@ -43,9 +43,9 @@ THE SOFTWARE.
 static int find_cmap(int, int, int, FT_Face, FT_CharMap *);
 
 static int
-FTEncFontSpecific(char *encoding)
+FTEncFontSpecific(const char *encoding)
 {
-    char *p = encoding;
+    const char *p = encoding;
 
     if(strcasecmp(encoding, "microsoft-symbol") == 0)
         return 1;
@@ -69,7 +69,7 @@ FTPickMapping(char *xlfd, int length, char *filename, FT_Face face,
     int ftrc;
     int symbol = 0;
     const char *enc, *reg;
-    char *encoding_name = 0;
+    const char *encoding_name = 0;
     char buf[20];
 
     if(xlfd)
diff --git a/src/FreeType/ftfuncs.c b/src/FreeType/ftfuncs.c
index b8cf49a..918e3f3 100644
--- a/src/FreeType/ftfuncs.c
+++ b/src/FreeType/ftfuncs.c
@@ -94,7 +94,7 @@ static CharInfoRec noSuchChar = { /* metrics */{0,0,0,0,0,0},
 
 /* The propery names for all the XLFD properties. */
 
-static char *xlfd_props[] = {
+static const char *xlfd_props[] = {
     "FOUNDRY",
     "FAMILY_NAME",
     "WEIGHT_NAME",
diff --git a/src/bitmap/bdfutils.c b/src/bitmap/bdfutils.c
index a0106b7..3a3ee26 100644
--- a/src/bitmap/bdfutils.c
+++ b/src/bitmap/bdfutils.c
@@ -68,7 +68,7 @@ int bdfFileLineNum;
 /***====================================================================***/
 
 void
-bdfError(char* message, ...)
+bdfError(const char* message, ...)
 {
     va_list args;
 
@@ -81,7 +81,7 @@ bdfError(char* message, ...)
 /***====================================================================***/
 
 void
-bdfWarning(char *message, ...)
+bdfWarning(const char *message, ...)
 {
     va_list args;
 
@@ -127,7 +127,7 @@ bdfGetLine(FontFilePtr file, unsigned char *buf, int len)
 /***====================================================================***/
 
 Atom
-bdfForceMakeAtom(char *str, int *size)
+bdfForceMakeAtom(const char *str, int *size)
 {
     register int len = strlen(str);
     Atom the_atom;
@@ -249,7 +249,7 @@ bdfHexByte(unsigned char *s)
  * check for known special property values
  */
 
-static char *SpecialAtoms[] = {
+static const char *SpecialAtoms[] = {
     "FONT_ASCENT",
 #define BDF_FONT_ASCENT	0
     "FONT_DESCENT",
@@ -279,8 +279,8 @@ Bool
 bdfSpecialProperty(FontPtr pFont, FontPropPtr prop,
 		   char isString, bdfFileState *bdfState)
 {
-    char      **special;
-    char       *name;
+    const char      **special;
+    const char       *name;
 
     name = NameForAtom(prop->name);
     for (special = SpecialAtoms; *special; special++)
diff --git a/src/bitmap/bitscale.c b/src/bitmap/bitscale.c
index b857237..e89ba7c 100644
--- a/src/bitmap/bitscale.c
+++ b/src/bitmap/bitscale.c
@@ -78,7 +78,7 @@ enum scaleType {
 };
 
 typedef struct _fontProp {
-    char       *name;
+    const char *name;
     Atom        atom;
     enum scaleType type;
 } fontProp;
diff --git a/src/builtins/builtin.h b/src/builtins/builtin.h
index d97d9a5..75dff8d 100644
--- a/src/builtins/builtin.h
+++ b/src/builtins/builtin.h
@@ -36,7 +36,7 @@ typedef struct _BuiltinFile {
 } BuiltinFileRec, *BuiltinFilePtr;
 
 typedef struct _BuiltinDir {
-    char	*file_name;
+    const char	*file_name;
     char	*font_name;
 } BuiltinDirRec, *BuiltinDirPtr;
 
diff --git a/src/fc/fsio.c b/src/fc/fsio.c
index 569b3aa..03a689f 100644
--- a/src/fc/fsio.c
+++ b/src/fc/fsio.c
@@ -369,7 +369,7 @@ _fs_io_fini (FSFpePtr conn)
 }
 
 static int
-_fs_do_write(FSFpePtr conn, char *data, long len, long size)
+_fs_do_write(FSFpePtr conn, const char *data, long len, long size)
 {
     if (size == 0) {
 #ifdef DEBUG
@@ -403,7 +403,7 @@ _fs_do_write(FSFpePtr conn, char *data, long len, long size)
  * Write the indicated bytes
  */
 int
-_fs_write (FSFpePtr conn, char *data, long len)
+_fs_write (FSFpePtr conn, const char *data, long len)
 {
     return _fs_do_write (conn, data, len, len);
 }
@@ -412,7 +412,7 @@ _fs_write (FSFpePtr conn, char *data, long len)
  * Write the indicated bytes adding any appropriate pad
  */
 int
-_fs_write_pad(FSFpePtr conn, char *data, long len)
+_fs_write_pad(FSFpePtr conn, const char *data, long len)
 {
     return _fs_do_write (conn, data, len, len + padlength[len & 3]);
 }
diff --git a/src/fc/fsio.h b/src/fc/fsio.h
index 1d1b3dd..2bb8e0b 100644
--- a/src/fc/fsio.h
+++ b/src/fc/fsio.h
@@ -129,8 +129,8 @@ typedef struct _fs_fpe_data {
 #define FSIO_ERROR  -1
 
 extern Bool _fs_reopen_server ( FSFpePtr conn );
-extern int _fs_write ( FSFpePtr conn, char *data, long size );
-extern int _fs_write_pad ( FSFpePtr conn, char *data, long len );
+extern int _fs_write ( FSFpePtr conn, const char *data, long size );
+extern int _fs_write_pad ( FSFpePtr conn, const char *data, long len );
 extern int _fs_wait_for_readable ( FSFpePtr conn, int ms );
 extern long _fs_pad_length (long len);
 
diff --git a/src/fontfile/fontdir.c b/src/fontfile/fontdir.c
index e524696..97b2ba3 100644
--- a/src/fontfile/fontdir.c
+++ b/src/fontfile/fontdir.c
@@ -102,12 +102,12 @@ FontFileFreeTable (FontTablePtr table)
 }
 
 FontDirectoryPtr
-FontFileMakeDir(char *dirName, int size)
+FontFileMakeDir(const char *dirName, int size)
 {
     FontDirectoryPtr	dir;
     int			dirlen;
     int			needslash = 0;
-    char		*attrib;
+    const char		*attrib;
     int			attriblen;
 
 #if !defined(WIN32)
diff --git a/src/util/atom.c b/src/util/atom.c
index 4f69363..c47cb5c 100644
--- a/src/util/atom.c
+++ b/src/util/atom.c
@@ -54,7 +54,7 @@ static int	    reverseMapSize;
 static Atom	    lastAtom;
 
 static int
-Hash(char *string, int len)
+Hash(const char *string, int len)
 {
     int	h;
 
@@ -147,7 +147,7 @@ NameEqual (const char *a, const char *b, int l)
 #endif
 
 weak Atom
-MakeAtom(char *string, unsigned len, int makeit)
+MakeAtom(const char *string, unsigned len, int makeit)
 {
     AtomListPtr	a;
     int		hash;
diff --git a/src/util/fontxlfd.c b/src/util/fontxlfd.c
index 8124037..18046e9 100644
--- a/src/util/fontxlfd.c
+++ b/src/util/fontxlfd.c
@@ -70,7 +70,7 @@ GetInt(char *ptr, int *val)
 #ifndef NO_LOCALE
 static struct lconv *locale = 0;
 #endif
-static char *radix = ".", *plus = "+", *minus = "-";
+static const char *radix = ".", *plus = "+", *minus = "-";
 
 static char *
 readreal(char *ptr, double *result)
-- 
1.7.3.2



More information about the xorg-devel mailing list