Removing most unused local variables?
Petter Reinholdtsen
pere at HUNGRY.COM
Wed Jan 26 11:54:50 EST 2005
When trying to build mapserver on Irix, the compiler reports several
warnings. One of them are "The variable "<foo>" was declared but
never referenced.". This report unused local variables.
The following patch will remove all these unused variables. This
patch _MUST NOT_ be applied to the source without reading and
controling the content. Some of the variable are probably used in the
start of some unfinished implementation, and it might make sense to
keep them. Others seem to be old cruft left over from some earlier
editing.
Some of the code seem to be real bugs (like in mapoutput.c), where the
result value is set when errors are detected, but the value isn't
returned from the function.
The big endian detection code might be replaces with the use of
AC_C_BIGENDIAN in configure.in. Not sure if this is advicable, as the
source is supposed to work on Windows, and I suspect configure isn't
used there. A better test might be this code, avoiding assumtions
about the size of int and long (from the autoconf macro):
int bigendian;
union { long l; char c[sizeof (long)]; } u;
u.l = 1;
bigendian = u.c[sizeof (long) - 1] == 1;
diff -ur src-4.4.1/epplib.c src-4.4.1-local/epplib.c
--- src-4.4.1/epplib.c 2004-10-21 06:30:54.000000000 +0200
+++ src-4.4.1-local/epplib.c 2005-01-26 17:23:29.000000000 +0100
@@ -261,10 +261,6 @@
char eppclose(eppfile *EPP)
{
- char badfile,eightbit;
-
- badfile=0;
- eightbit=0;
if (EPP->access_table!=NULL) free(EPP->saved);
if (EPP->rptr!=NULL) free(EPP->rptr);
free(EPP->fptr);
diff -ur src-4.4.1/maperror.c src-4.4.1-local/maperror.c
--- src-4.4.1/maperror.c 2004-10-21 06:30:55.000000000 +0200
+++ src-4.4.1-local/maperror.c 2005-01-26 16:54:26.000000000 +0100
@@ -343,7 +343,7 @@
void msWriteErrorImage(mapObj *map, char *filename, int blank) {
gdFontPtr font = gdFontSmall;
gdImagePtr img=NULL;
- int width=400, height=300, color;
+ int width=400, height=300;
int nMargin =5;
int nTextLength = 0;
int nUsableWidth = 0;
@@ -376,9 +376,9 @@
if (format == NULL) format = msCreateDefaultOutputFormat( NULL, "GD/PC256" );
img = gdImageCreate(width, height);
- color = gdImageColorAllocate(img, map->imagecolor.red,
- map->imagecolor.green,
- map->imagecolor.blue); // BG color
+ gdImageColorAllocate(img, map->imagecolor.red,
+ map->imagecolor.green,
+ map->imagecolor.blue); // BG color
nBlack = gdImageColorAllocate(img, 0,0,0); // Text color
if (map->outputformat && map->outputformat->transparent)
diff -ur src-4.4.1/mapgd.c src-4.4.1-local/mapgd.c
--- src-4.4.1/mapgd.c 2004-12-22 17:34:06.000000000 +0100
+++ src-4.4.1-local/mapgd.c 2005-01-26 17:19:36.000000000 +0100
@@ -794,7 +794,7 @@
static void imageOffsetPolyline(gdImagePtr img, shapeObj *p, int color, int offsetx, int offsety)
{
int i, j, first;
- int dx, dy, dx0=0, dy0=0, ox=0, oy=0, limit;
+ int dx, dy, dx0=0, ox=0, oy=0, limit;
double x, y, x0=0.0, y0=0.0, k=0.0, k0=0.0, q=0.0, q0=0.0;
float par=(float)0.71;
@@ -850,7 +850,7 @@
}
gdImageLine(img, (int)x0, (int)y0, (int)x, (int)y, color);
}
- dx0 = dx; dy0 = dy; x0 = x, y0 = y; k0 = k; q0=q;
+ dx0 = dx; x0 = x, y0 = y; k0 = k; q0=q;
}
//last point
if(first==0)gdImageLine(img, (int)x0, (int)y0, (int)(p->line[i].point[p->line[i].numpoints-1].x+ox), (int)(p->line[i].point[p->line[i].numpoints-1].y+oy), color);
@@ -1170,7 +1170,7 @@
gdPoint oldpnt,newpnt;
gdPoint sPoints[MS_MAXVECTORPOINTS];
gdImagePtr tile=NULL;
- int x, y, ox, oy;
+ int x, y;
int fc, bc, oc;
int tile_bc=-1, tile_fc=-1; /* colors (background and foreground) */
@@ -1198,8 +1198,6 @@
bc = style->backgroundcolor.pen;
fc = style->color.pen;
oc = style->outlinecolor.pen;
- ox = style->offsetx; // TODO: add scaling?
- oy = style->offsety;
if(style->size == -1) {
size = msSymbolGetDefaultSize( &( symbolset->symbol[style->symbol] ) );
@@ -1358,8 +1356,8 @@
char *error=NULL;
gdImagePtr tmp;
- int tmp_fc=-1, tmp_bc, tmp_oc=-1;
- int fc, bc, oc;
+ int tmp_fc=-1, tmp_oc=-1;
+ int fc, oc;
double size,d;
int ox, oy;
@@ -1375,7 +1373,6 @@
if(style->outlinecolor.pen == MS_PEN_UNSET) msImageSetPenGD(img, &(style->outlinecolor));
symbol = &(symbolset->symbol[style->symbol]);
- bc = style->backgroundcolor.pen;
fc = style->color.pen;
oc = style->outlinecolor.pen;
ox = style->offsetx; // TODO: add scaling?
@@ -1455,7 +1452,7 @@
/* create temporary image and allocate a few colors */
tmp = gdImageCreate(x, y);
- tmp_bc = gdImageColorAllocate(tmp, gdImageRed(img, 0), gdImageGreen(img, 0), gdImageBlue(img, 0));
+ gdImageColorAllocate(tmp, gdImageRed(img, 0), gdImageGreen(img, 0), gdImageBlue(img, 0));
gdImageColorTransparent(tmp, 0);
if(fc >= 0)
tmp_fc = gdImageColorAllocate(tmp, gdImageRed(img, fc), gdImageGreen(img, fc), gdImageBlue(img, fc));
@@ -1974,7 +1971,7 @@
static void RenderCartoLine(gdImagePtr img, int gox, double *acoord, double *bcoord, double da, double db, double angle_n, double size, int c, symbolObj *symbol, double styleCoef, double *styleSize, int *styleIndex, int *styleVis, gdPoint *points, double *da_px, double *db_px, int offseta, int offsetb, int antialias)
{
double an, bn, da_pxn, db_pxn, d_size, a, b;
- double d_step_coef, da_pxn_coef, db_pxn_coef, da_px_coef, db_px_coef;
+ double d_step_coef, da_px_coef, db_px_coef;
int db_line, first, drawpoly=0;
gdPoint poly_points[4];
static double last_style_size;
@@ -1994,8 +1991,6 @@
da_px_coef = *da_px*d_step_coef;
db_px_coef = *db_px*d_step_coef;
- da_pxn_coef = da_pxn*d_step_coef;
- db_pxn_coef = db_pxn*d_step_coef;
if(offseta != 0 || offsetb != 0) {
if (gox) {
diff -ur src-4.4.1/maplegend.c src-4.4.1-local/maplegend.c
--- src-4.4.1/maplegend.c 2004-11-22 04:43:54.000000000 +0100
+++ src-4.4.1-local/maplegend.c 2005-01-26 16:53:29.000000000 +0100
@@ -229,7 +229,6 @@
{
int status;
- gdImagePtr img; /* image data structure */
int i,j; /* loop counters */
pointObj pnt;
int size_x, size_y;
@@ -311,16 +310,13 @@
// drop this reference to output format
msApplyOutputFormat(&format, NULL, MS_NOOVERRIDE, MS_NOOVERRIDE, MS_NOOVERRIDE);
- if (image)
- img = image->img.gd;
- else {
+ if (image == NULL) {
msSetError(MS_GDERR, "Unable to initialize image.", "msDrawLegend()");
return(NULL);
}
-
+
/* Set background */
- if(image != NULL)
- msImageInitGD(image, &(map->legend.imagecolor));
+ msImageInitGD(image, &(map->legend.imagecolor));
msClearPenValues(map); // just in case the mapfile has already been processed
diff -ur src-4.4.1/mapoutput.c src-4.4.1-local/mapoutput.c
--- src-4.4.1/mapoutput.c 2004-11-18 21:55:38.000000000 +0100
+++ src-4.4.1-local/mapoutput.c 2005-01-26 17:20:23.000000000 +0100
@@ -924,8 +924,6 @@
int msOutputFormatValidate( outputFormatObj *format )
{
- int result = MS_TRUE;
-
format->bands =
atoi(msGetOutputFormatOption( format, "BAND_COUNT", "1" ));
@@ -936,7 +934,6 @@
"It has been disabled.\n",
format->name );
format->transparent = MS_FALSE;
- result = MS_FALSE;
}
if( strcasecmp(format->driver,"GD/JPEG") == 0
@@ -946,7 +943,6 @@
"IMAGEMODE forced to RGB.\n",
format->name );
format->imagemode = MS_IMAGEMODE_RGB;
- result = MS_FALSE;
}
if( format->transparent && format->imagemode == MS_IMAGEMODE_RGB )
@@ -955,7 +951,6 @@
" of RGB instead of RGBA. Changing imagemode to RGBA.\n",
format->name );
format->imagemode = MS_IMAGEMODE_RGBA;
- result = MS_FALSE;
}
/* see bug 724 */
diff -ur src-4.4.1/mapraster.c src-4.4.1-local/mapraster.c
--- src-4.4.1/mapraster.c 2004-11-15 19:55:49.000000000 +0100
+++ src-4.4.1-local/mapraster.c 2005-01-26 17:34:12.000000000 +0100
@@ -954,7 +954,6 @@
#ifdef USE_JPEG
int i,j,k; /* loop counters */
int cmap[MAXCOLORS];
- double w, h;
unsigned char vv;
JSAMPARRAY buffer;
@@ -1028,9 +1027,6 @@
// initialize the decompressor, this sets output sizes etc...
jpeg_start_decompress(&cinfo);
- w = cinfo.output_width - .5; /* to avoid rounding problems */
- h = cinfo.output_height - .5;
-
// one pixel high buffer as wide as the image, goes away when done with the image
buffer = (*cinfo.mem->alloc_sarray) ((j_common_ptr) &cinfo, JPOOL_IMAGE, cinfo.output_width, 1);
@@ -1226,14 +1222,12 @@
shapeObj tshp;
int force_gdal;
- char szPath[MS_MAXPATHLEN], cwd[MS_MAXPATHLEN];
+ char szPath[MS_MAXPATHLEN];
int final_status = MS_SUCCESS;
rectObj searchrect;
gdImagePtr img;
- cwd[0] = '\0';
-
if(layer->debug > 0 || map->debug > 1)
msDebug( "msDrawRasterLayerLow(%s): entering.\n", layer->name );
diff -ur src-4.4.1/mapserv.c src-4.4.1-local/mapserv.c
--- src-4.4.1/mapserv.c 2004-12-09 22:39:23.000000000 +0100
+++ src-4.4.1-local/mapserv.c 2005-01-26 17:23:56.000000000 +0100
@@ -954,13 +954,12 @@
}
void setExtentFromShapes() {
- int found=0;
double dx, dy, cellsize;
rectObj tmpext={-1.0,-1.0,-1.0,-1.0};
pointObj tmppnt={-1.0,-1.0};
- found = msGetQueryResultBounds(msObj->Map, &(tmpext));
+ msGetQueryResultBounds(msObj->Map, &(tmpext));
dx = tmpext.maxx - tmpext.minx;
dy = tmpext.maxy - tmpext.miny;
diff -ur src-4.4.1/mapxbase.c src-4.4.1-local/mapxbase.c
--- src-4.4.1/mapxbase.c 2005-01-26 16:49:51.000000000 +0100
+++ src-4.4.1-local/mapxbase.c 2005-01-26 16:51:18.000000000 +0100
@@ -757,7 +757,6 @@
int msDBFGetItemIndex(DBFHandle dbffile, char *name)
{
int i;
- DBFFieldType dbfField;
int fWidth,fnDecimals; /* field width and number of decimals */
char fName[32]; /* field name */
@@ -768,7 +767,7 @@
/* does name exist as a field? */
for(i=0;i<msDBFGetFieldCount(dbffile);i++) {
- dbfField = msDBFGetFieldInfo(dbffile,i,fName,&fWidth,&fnDecimals);
+ msDBFGetFieldInfo(dbffile,i,fName,&fWidth,&fnDecimals);
if(strcasecmp(name,fName) == 0) /* found it */
return(i);
}
diff -ur src-4.4.1/shptreetst.c src-4.4.1-local/shptreetst.c
--- src-4.4.1/shptreetst.c 2004-10-21 06:30:55.000000000 +0200
+++ src-4.4.1-local/shptreetst.c 2005-01-26 17:38:35.000000000 +0100
@@ -87,7 +87,6 @@
int pos;
char *bitmap = NULL;
- char mBigEndian;
treeNodeObj *node = NULL;
@@ -100,13 +99,6 @@
exit( 1 );
}
- i = 1;
- if( *((unsigned char *) &i) == 1 )
- mBigEndian = 0;
- else
- mBigEndian = 1;
-
-
qix = msSHPDiskTreeOpen (AddFileSuffix(argv[1],".qix"), 0 /* no debug*/);
if( qix == NULL )
{
diff -ur src-4.4.1/shptreevis.c src-4.4.1-local/shptreevis.c
--- src-4.4.1/shptreevis.c 2004-10-21 06:30:55.000000000 +0200
+++ src-4.4.1-local/shptreevis.c 2005-01-26 17:26:00.000000000 +0100
@@ -85,7 +85,7 @@
DBFHandle hDBF;
SHPTreeHandle qix;
- int i, j;
+ int j;
char *myfile = NULL;
treeNodeObj *node;
@@ -99,9 +99,8 @@
double X[6], Y[6];
#endif
int pos, result;
- char mBigEndian;
- int this_rec, factor;
+ int this_rec;
/* -------------------------------------------------------------------- */
/* Display a usage message. */
@@ -112,13 +111,6 @@
exit( 1 );
}
- i = 1;
- if( *((unsigned char *) &i) == 1 )
- mBigEndian = 0;
- else
- mBigEndian = 1;
-
-
qix = msSHPDiskTreeOpen (AddFileSuffix(argv[1],".qix"), 0 /* no debug*/);
if( qix == NULL )
{
@@ -199,7 +191,6 @@
DBFWriteIntegerAttribute( hDBF, this_rec, 0, node->numshapes);
DBFWriteIntegerAttribute( hDBF, this_rec, 1, node->numsubnodes);
#endif
- factor = node->numshapes + node->numsubnodes;
#ifdef MAPSERVER
shape.numlines = 1;
More information about the mapserver-dev
mailing list