[PATCH] Make function prototypes ANSI C

Petter Reinholdtsen pere at HUNGRY.COM
Mon Jan 24 18:27:57 EST 2005


Adding more warnings, pinpoint several places in the code where '()'
is used to indicate functions without arguments.  In ANSI C, '(void)'
is the correct way to specify this, and the code in question specifies
a function with an unspecified list of arguments, not a function
without arguments.  The compiler emits this message for the code in
question:

  warning: function declaration isn't a prototype

The following patch get rid of all these warnings.  Please include it
in a future version of mapserver.  (And please apply the patch add
more warning flags to the default build. :)

Index: map.h
===================================================================
RCS file: /data2/cvsroot/mapserver/map.h,v
retrieving revision 1.388
diff -u -3 -p -u -r1.388 map.h
--- map.h       12 Jan 2005 21:11:21 -0000      1.388
+++ map.h       24 Jan 2005 23:20:03 -0000
@@ -156,7 +156,7 @@

 #ifndef DISABLE_CVSID
 #  define MS_CVSID(string)     static char ms_cvsid[] = string; \
-static char *cvsid_aw() { return( cvsid_aw() ? ((char *) NULL) : ms_cvsid ); }
+static char *cvsid_aw(void) { return( cvsid_aw() ? ((char *) NULL) : ms_cvsid ); }
 #else
 #  define MS_CVSID(string)
 #endif
Index: maperror.c
===================================================================
RCS file: /data2/cvsroot/mapserver/maperror.c,v
retrieving revision 1.59
diff -u -3 -p -u -r1.59 maperror.c
--- maperror.c  7 Jan 2005 18:51:09 -0000       1.59
+++ maperror.c  24 Jan 2005 23:20:03 -0000
@@ -184,7 +184,7 @@ errorObj *msGetErrorObj()
 ** the head is moved to the new errorObj, freeing the head errorObj to receive
 ** the new error information.
 */
-static errorObj *msInsertErrorObj()
+static errorObj *msInsertErrorObj(void)
 {
   errorObj *ms_error;
   ms_error = msGetErrorObj();
Index: mapfile.c
===================================================================
RCS file: /data2/cvsroot/mapserver/mapfile.c,v
retrieving revision 1.289
diff -u -3 -p -u -r1.289 mapfile.c
--- mapfile.c   20 Dec 2004 22:41:48 -0000      1.289
+++ mapfile.c   24 Jan 2005 23:20:04 -0000
@@ -62,8 +62,8 @@

 MS_CVSID("$Id: mapfile.c,v 1.289 2004/12/20 22:41:48 sdlime Exp $")

-extern int msyylex();
-extern void msyyrestart();
+extern int msyylex(void);
+extern void msyyrestart(FILE *);
 extern double msyynumber;
 extern char *msyytext;
 extern int msyylineno;
@@ -161,7 +161,7 @@ int getSymbol(int n, ...) {
 ** Get a string or symbol as a string.   Operates like getString(), but also
 ** supports symbols.
 */
-static char *getToken() {
+static char *getToken(void) {

     msyylex();

Index: maplexer.l
===================================================================
RCS file: /data2/cvsroot/mapserver/maplexer.l,v
retrieving revision 1.86
diff -u -3 -p -u -r1.86 maplexer.l
--- maplexer.l  29 Oct 2004 02:55:45 -0000      1.86
+++ maplexer.l  24 Jan 2005 23:20:04 -0000
@@ -31,7 +31,7 @@ char *msyystring=NULL;

 int msyyreturncomments = 0;

-void lexer_cleanup() {
+void lexer_cleanup(void) {
 #ifndef YY_CURRENT_BUFFER_LVALUE
     /* yy_current_buffer was there only in older versions (e.g. 2.5.4)
      * but is gone in newer versions (e.g. 2.5.31)
Index: mapogcfilter.c
===================================================================
RCS file: /data2/cvsroot/mapserver/mapogcfilter.c,v
retrieving revision 1.41
diff -u -3 -p -u -r1.41 mapogcfilter.c
--- mapogcfilter.c      6 Jan 2005 00:33:49 -0000       1.41
+++ mapogcfilter.c      24 Jan 2005 23:20:04 -0000
@@ -1127,7 +1127,7 @@ void FLTFreeFilterEncodingNode(FilterEnc
 /*                                                                      */
 /*      return a FilerEncoding node.                                    */
 /************************************************************************/
-FilterEncodingNode *FLTCreateFilterEncodingNode()
+FilterEncodingNode *FLTCreateFilterEncodingNode(void)
 {
     FilterEncodingNode *psFilterNode = NULL;

Index: mapogcfilter.h
===================================================================
RCS file: /data2/cvsroot/mapserver/mapogcfilter.h,v
retrieving revision 1.7
diff -u -3 -p -u -r1.7 mapogcfilter.h
--- mapogcfilter.h      28 Jul 2004 22:16:17 -0000      1.7
+++ mapogcfilter.h      24 Jan 2005 23:20:04 -0000
@@ -114,7 +114,7 @@ typedef struct
 /*      prototypes.                                                     */
 /* -------------------------------------------------------------------- */
 FilterEncodingNode *FLTParseFilterEncoding(char *szXMLString);
-FilterEncodingNode *FLTCreateFilterEncodingNode();
+FilterEncodingNode *FLTCreateFilterEncodingNode(void);
 int FLTApplyFilterToLayer(FilterEncodingNode *psNode, mapObj *map,
                          int iLayerIndex, int bOnlySpatialFilter);
 int FLTApplySpatialFilterToLayer(FilterEncodingNode *psNode, mapObj *map,
Index: mapparser.y
===================================================================
RCS file: /data2/cvsroot/mapserver/mapparser.y,v
retrieving revision 1.12
diff -u -3 -p -u -r1.12 mapparser.y
--- mapparser.y 24 Mar 2004 18:39:29 -0000      1.12
+++ mapparser.y 24 Jan 2005 23:20:04 -0000
@@ -13,8 +13,8 @@
 #include "map.h" /* for TRUE/FALSE and REGEX includes */
 #include "maptime.h" /* for time comparison routines */

-extern int msyylex(); /* lexer globals */
-extern int msyyerror();
+extern int msyylex(void); /* lexer globals */
+extern int msyyerror(const char *);

 int msyyresult;
 %}
Index: mapraster.c
===================================================================
RCS file: /data2/cvsroot/mapserver/mapraster.c,v
retrieving revision 1.123
diff -u -3 -p -u -r1.123 mapraster.c
--- mapraster.c 15 Nov 2004 18:55:49 -0000      1.123
+++ mapraster.c 24 Jan 2005 23:20:04 -0000
@@ -78,8 +78,8 @@

 MS_CVSID("$Id: mapraster.c,v 1.123 2004/11/15 18:55:49 frank Exp $")

-extern int msyyparse();
-extern int msyylex();
+extern int msyyparse(void);
+extern int msyylex(void);
 extern char *msyytext;

 extern int msyyresult; // result of parsing, true/false
Index: mapserv.c
===================================================================
RCS file: /data2/cvsroot/mapserver/mapserv.c,v
retrieving revision 1.142
diff -u -3 -p -u -r1.142 mapserv.c
--- mapserv.c   9 Dec 2004 21:20:19 -0000       1.142
+++ mapserv.c   24 Jan 2005 23:20:04 -0000
@@ -140,7 +140,7 @@ int writeLog(int show_error)
   return(0);
 }

-void writeError()
+void writeError(void)
 {
   errorObj *ms_error = msGetErrorObj();

@@ -226,7 +226,7 @@ static double getNumeric(char *s)
 ** Extract Map File name from params and load it.
 ** Returns map object or NULL on error.
 */
-mapObj *loadMap()
+mapObj *loadMap(void)
 {
   int i,j,k;
   mapObj *map = NULL;
@@ -300,7 +300,7 @@ mapObj *loadMap()
 /*
 ** Process CGI parameters.
 */
-void loadForm()
+void loadForm(void)
 {
   int i,j,n;
   char **tokens=NULL;
@@ -953,7 +953,7 @@ void loadForm()
   if(msObj->Map->width == -1) msObj->Map->width = msObj->ImgCols;
 }

-void setExtentFromShapes() {
+void setExtentFromShapes(void) {
   int found=0;
   double dx, dy, cellsize;

@@ -1007,7 +1007,7 @@ void setExtentFromShapes() {


 /* FIX: NEED ERROR CHECKING HERE FOR IMGPNT or MAPPNT */
-void setCoordinate()
+void setCoordinate(void)
 {
   double cellx,celly;

@@ -1020,7 +1020,7 @@ void setCoordinate()
   return;
 }

-void returnCoordinate()
+void returnCoordinate(pointObj pnt)
 {
   msSetError(MS_NOERR,
              "Your \"<i>click</i>\" corresponds to (approximately): (%g, %g).",
Index: mapsymbol.c
===================================================================
RCS file: /data2/cvsroot/mapserver/mapsymbol.c,v
retrieving revision 1.79
diff -u -3 -p -u -r1.79 mapsymbol.c
--- mapsymbol.c 19 Nov 2004 17:38:41 -0000      1.79
+++ mapsymbol.c 24 Jan 2005 23:20:04 -0000
@@ -64,8 +64,8 @@

 MS_CVSID("$Id: mapsymbol.c,v 1.79 2004/11/19 17:38:41 sean Exp $")

-extern int msyylex(); /* lexer globals */
-extern void msyyrestart();
+extern int msyylex(void); /* lexer globals */
+extern void msyyrestart(FILE *);
 extern double msyynumber;
 extern char *msyytext;
 extern int msyylineno;
Index: mapthread.h
===================================================================
RCS file: /data2/cvsroot/mapserver/mapthread.h,v
retrieving revision 1.4
diff -u -3 -p -u -r1.4 mapthread.h
--- mapthread.h 21 Oct 2004 04:30:55 -0000      1.4
+++ mapthread.h 24 Jan 2005 23:20:04 -0000
@@ -40,8 +40,8 @@ extern "C" {
 #endif

 #ifdef USE_THREAD
-void msThreadInit();
-int msGetThreadId();
+void msThreadInit(void);
+int msGetThreadId(void);
 void msAcquireLock(int);
 void msReleaseLock(int);
 #else
Index: maptime.h
===================================================================
RCS file: /data2/cvsroot/mapserver/maptime.h,v
retrieving revision 1.8
diff -u -3 -p -u -r1.8 maptime.h
--- maptime.h   21 Oct 2004 10:54:17 -0000      1.8
+++ maptime.h   24 Jan 2005 23:20:05 -0000
@@ -76,7 +76,7 @@ char *msStrptime(const char *s, const ch
 int msParseTime(const char *string, struct tm *tm);
 int msTimeMatchPattern(char *timestring, char *pattern);
 void msSetLimitedPattersToUse(char *patternstring);
-void msUnsetLimitedPatternToUse();
+void msUnsetLimitedPatternToUse(void);
 int msTimeGetResolution(const char *timestring);

 #endif /* MAPTIME_H */
Index: maputil.c
===================================================================
RCS file: /data2/cvsroot/mapserver/maputil.c,v
retrieving revision 1.168
diff -u -3 -p -u -r1.168 maputil.c
--- maputil.c   20 Jan 2005 01:59:19 -0000      1.168
+++ maputil.c   24 Jan 2005 23:20:05 -0000
@@ -74,8 +74,8 @@

 MS_CVSID("$Id: maputil.c,v 1.168 2005/01/20 01:59:19 sean Exp $")

-extern int msyyparse();
-extern int msyylex();
+extern int msyyparse(void);
+extern int msyylex(void);
 extern char *msyytext;

 extern int msyyresult; // result of parsing, true/false
@@ -1141,7 +1141,7 @@ void  msTransformShape(shapeObj *shape,

 /* This is intended to be a function to cleanup anything that "hangs around"
    when all maps are destroyed, like Registered GDAL drivers, and so forth. */
-extern void lexer_cleanup();
+extern void lexer_cleanup(void);

 void msCleanup()
 {
Index: mapwfslayer.c
===================================================================
RCS file: /data2/cvsroot/mapserver/mapwfslayer.c,v
retrieving revision 1.29
diff -u -3 -p -u -r1.29 mapwfslayer.c
--- mapwfslayer.c       25 Nov 2004 06:19:05 -0000      1.29
+++ mapwfslayer.c       24 Jan 2005 23:20:05 -0000
@@ -570,7 +570,7 @@ typedef struct ms_wfs_layer_info_t
  *                          msAllocWFSLayerInfo()
  *
  **********************************************************************/
-static msWFSLayerInfo *msAllocWFSLayerInfo()
+static msWFSLayerInfo *msAllocWFSLayerInfo(void)
 {
     msWFSLayerInfo *psInfo;

Index: sortshp.c
===================================================================
RCS file: /data2/cvsroot/mapserver/sortshp.c,v
retrieving revision 1.3
diff -u -3 -p -u -r1.3 sortshp.c
--- sortshp.c   21 Oct 2004 04:30:55 -0000      1.3
+++ sortshp.c   24 Jan 2005 23:20:05 -0000
@@ -47,21 +47,21 @@ typedef struct {
   int index;
 } sortStruct;

-static int compare_string_descending(i,j)
-sortStruct *i, *j;
+static int compare_string_descending(const void *a, const void *b)
 {
+  const sortStruct *i = a, *j = b;
   return(strcmp(j->string, i->string));
 }

-static int compare_string_ascending(i,j)
-sortStruct *i, *j;
+static int compare_string_ascending(const void *a, const void *b)
 {
+  const sortStruct *i = a, *j = b;
   return(strcmp(i->string, j->string));
 }

-static int compare_number_descending(i,j)
-sortStruct *i, *j;
+static int compare_number_descending(const void *a, const void *b)
 {
+  const sortStruct *i = a, *j = b;
   if(i->number > j->number)
     return(-1);
   if(i->number < j->number)
@@ -69,9 +69,9 @@ sortStruct *i, *j;
   return(0);
 }

-static int compare_number_ascending(i,j)
-sortStruct *i, *j;
+static int compare_number_ascending(const void *a, const void *b)
 {
+  const sortStruct *i = a, *j = b;
   if(i->number > j->number)
     return(1);
   if(i->number < j->number)
@@ -79,9 +79,7 @@ sortStruct *i, *j;
   return(0);
 }

-int main(argc,argv)
-int argc;
-char *argv[];
+int main(int argc, char *argv[])
 {
   SHPHandle    inSHP,outSHP; /* ---- Shapefile file pointers ---- */
   DBFHandle    inDBF,outDBF; /* ---- DBF file pointers ---- */
Index: tile4ms.c
===================================================================
RCS file: /data2/cvsroot/mapserver/tile4ms.c,v
retrieving revision 1.7
diff -u -3 -p -u -r1.7 tile4ms.c
--- tile4ms.c   21 Oct 2004 04:30:56 -0000      1.7
+++ tile4ms.c   24 Jan 2005 23:20:05 -0000
@@ -244,7 +244,7 @@ int     tilesProcessed = 0;
 }

 /***********************************************************************/
-void print_usage_and_exit() {
+void print_usage_and_exit(void) {

     printf("\nusage: tile4ms <meta-file> <tile-file> [-tile-path-only]\n");
     printf("<meta-file>\tINPUT  file containing list of shapefile names\n\t\t(complete paths 255 chars max, no extension)\n");



More information about the mapserver-dev mailing list