[nas] [patch] const-correctness

Stefan Huehner stefan at huehner.org
Sat Jul 15 15:45:38 MDT 2006


Hi,

attached patch corrects some code-path wich drop the const qualifier
from i.e. 'const char*' to 'char *' and marks read-only string
parameters as const.

Please review and consider applying.

Regards,
Stefan

-------------- next part --------------
Index: lib/audio/8svx.c
===================================================================
--- lib/audio/8svx.c	(revision 152)
+++ lib/audio/8svx.c	(working copy)
@@ -43,7 +43,7 @@
 #define Err()		{ SvxCloseFile(si); return NULL; }
 #define readID(_f)	fread(_f, sizeof(SVX_ID), 1, si->fp)
 #define readByte(_f)	fread(_f, 1, 1, si->fp)
-#define cmpID(_x, _y)	strncmp((char *) (_x), (char *) (_y), sizeof(SVX_ID))
+#define cmpID(_x, _y)	strncmp((const char *) (_x), (const char *) (_y), sizeof(SVX_ID))
 
 static int
 readChunk(SvxChunk *c, FILE *fp)
Index: lib/audio/AuErrDes.c
===================================================================
--- lib/audio/AuErrDes.c	(revision 152)
+++ lib/audio/AuErrDes.c	(working copy)
@@ -110,7 +110,7 @@
 }
 
 static XrmDatabase
-getFileDataBase(char *filename)
+getFileDataBase(const char *filename)
 {
     FILE           *fp;
     char            line[BUFSIZ],
Index: lib/audio/ConnSvr.c
===================================================================
--- lib/audio/ConnSvr.c	(revision 152)
+++ lib/audio/ConnSvr.c	(working copy)
@@ -321,7 +321,7 @@
     _AuConst char *lastp, *p;		/* char pointers */
     char *phostname = NULL;		/* start of host of server */
     char *psvrnum = NULL;		/* start of svrnum of server */
-    char *realtrans;			/* real audio transport prefix */
+    const char *realtrans;		/* real audio transport prefix */
     char newsvrnum[10];			/* in case need to convert from X */
     int saviserver;			/* a temp variable */
     AuBool xname = AuTrue;		/* most applications it will be */
Index: lib/audio/aiff.c
===================================================================
--- lib/audio/aiff.c	(revision 152)
+++ lib/audio/aiff.c	(working copy)
@@ -41,7 +41,7 @@
 
 #define Err()		{ AiffCloseFile(ai); return NULL; }
 #define readID(_f)	fread(_f, sizeof(AIFF_ID), 1, ai->fp)
-#define cmpID(_x, _y)	strncmp((char *) (_x), (char *) (_y), sizeof(AIFF_ID))
+#define cmpID(_x, _y)	strncmp((const char *) (_x), (const char *) (_y), sizeof(AIFF_ID))
 #define PAD2(_x)	(((_x) + 1) & ~1)
 
 /**
Index: lib/audio/Alibint.c
===================================================================
--- lib/audio/Alibint.c	(revision 152)
+++ lib/audio/Alibint.c	(working copy)
@@ -1341,7 +1341,7 @@
     char buffer[BUFSIZ];
     char mesg[BUFSIZ];
     char number[32];
-    char *mtype = "audiolib";
+    const char *mtype = "audiolib";
     register _AuExtension *ext = (_AuExtension *)NULL;
     _AuExtension *bext = (_AuExtension *)NULL;
     AuGetErrorText(aud, event->error_code, buffer, BUFSIZ);
Index: lib/audio/wave.c
===================================================================
--- lib/audio/wave.c	(revision 152)
+++ lib/audio/wave.c	(working copy)
@@ -46,7 +46,7 @@
 #define Err()		{ WaveCloseFile(wi); return NULL; }
 #define readFourcc(_f)	fread(_f, sizeof(RIFF_FOURCC), 1, wi->fp)
 #define cmpID(_x, _y)							      \
-    strncmp((char *) (_x), (char *) (_y), sizeof(RIFF_FOURCC))
+    strncmp((const char *) (_x), (const char *) (_y), sizeof(RIFF_FOURCC))
 #define PAD2(_x)	(((_x) + 1) & ~1)
 
 static int
Index: lib/audio/Util.c
===================================================================
--- lib/audio/Util.c	(revision 152)
+++ lib/audio/Util.c	(working copy)
@@ -190,7 +190,7 @@
 static struct
 {
     int             format;
-    char           *string,
+    const char     *string,
                    *define;
 } formats[] =
   {
@@ -258,7 +258,7 @@
 static struct
 {
     int             waveform;
-    char           *string;
+    const char      *string;
 } waveforms[] =
   {
     AuWaveFormSquare, "Square",


More information about the Nas mailing list