Skip to content

Commit

Permalink
Fix use of printf-like functions to avoid warnings; 2 actual error fo…
Browse files Browse the repository at this point in the history
…unds
  • Loading branch information
rouault committed Jul 6, 2013
1 parent 77f9b81 commit 4d83a01
Show file tree
Hide file tree
Showing 36 changed files with 873 additions and 934 deletions.
2 changes: 1 addition & 1 deletion cgiutil.c
Expand Up @@ -64,7 +64,7 @@ int readPostBody( cgiRequestObj *request, char **data )
if( *data == NULL ) {
msIO_setHeader("Content-Type","text/html");
msIO_sendHeaders();
msIO_printf("malloc() failed, Content-Length: %u unreasonably large?\n", data_max );
msIO_printf("malloc() failed, Content-Length: %u unreasonably large?\n", (unsigned int)data_max );
return MS_FAILURE;
}

Expand Down
2 changes: 1 addition & 1 deletion mapagg.cpp
Expand Up @@ -826,7 +826,7 @@ imageObj *agg2CreateImage(int width, int height, outputFormatObj *format, colorO
r->buffer = (band_type*)malloc(width * height * 4 * sizeof(band_type));
if (r->buffer == NULL) {
msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "agg2CreateImage()",
__FILE__, __LINE__, width * height * 4 * sizeof(band_type));
__FILE__, __LINE__, (unsigned int)(width * height * 4 * sizeof(band_type)));
free(image);
return NULL;
}
Expand Down
6 changes: 3 additions & 3 deletions mapchart.c
Expand Up @@ -368,7 +368,7 @@ int msDrawPieChartLayer(mapObj *map, layerObj *layer, imageObj *image)
styles = (styleObj**)malloc((numvalues)*sizeof(styleObj*));
if (styles == NULL) {
msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "msDrawPieChartLayer()",
__FILE__, __LINE__, numvalues*sizeof(styleObj*));
__FILE__, __LINE__, (unsigned int)(numvalues*sizeof(styleObj*)));
free(values);
return MS_FAILURE;
}
Expand Down Expand Up @@ -450,7 +450,7 @@ int msDrawVBarChartLayer(mapObj *map, layerObj *layer, imageObj *image)
styles = (styleObj**)malloc(numvalues*sizeof(styleObj*));
if (styles == NULL) {
msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "msDrawVBarChartLayer()",
__FILE__, __LINE__, numvalues*sizeof(styleObj*));
__FILE__, __LINE__, (unsigned int)(numvalues*sizeof(styleObj*)));
free(values);
return MS_FAILURE;
}
Expand Down Expand Up @@ -540,7 +540,7 @@ int msDrawBarChartLayer(mapObj *map, layerObj *layer, imageObj *image)
styles = (styleObj**)malloc(numvalues*sizeof(styleObj*));
if (styles == NULL) {
msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "msDrawBarChartLayer()",
__FILE__, __LINE__, numvalues*sizeof(styleObj*));
__FILE__, __LINE__, (unsigned int)(numvalues*sizeof(styleObj*)));
free(values);
return MS_FAILURE;
}
Expand Down
2 changes: 1 addition & 1 deletion mapdebug.c
Expand Up @@ -99,7 +99,7 @@ debugInfoObj *msGetDebugInfoObj()
new_link->errorfile = NULL;
new_link->fp = NULL;
} else
msSetError(MS_MEMERR, "Out of memory allocating %u bytes.\n", "msGetDebugInfoObj()", sizeof(debugInfoObj));
msSetError(MS_MEMERR, "Out of memory allocating %u bytes.\n", "msGetDebugInfoObj()", (unsigned int)sizeof(debugInfoObj));

debuginfo_list = new_link;
}
Expand Down
2 changes: 1 addition & 1 deletion mapdraw.c
Expand Up @@ -983,7 +983,7 @@ int msDrawVectorLayer(mapObj *map, layerObj *layer, imageObj *image)
/* Check if the shape size is ok to be drawn */
if((shape.type == MS_SHAPE_LINE || shape.type == MS_SHAPE_POLYGON) && (minfeaturesize > 0) && (msShapeCheckSize(&shape, minfeaturesize) == MS_FALSE)) {
if(layer->debug >= MS_DEBUGLEVEL_V)
msDebug("msDrawVectorLayer(): Skipping shape (%d) because LAYER::MINFEATURESIZE is bigger than shape size\n", shape.index);
msDebug("msDrawVectorLayer(): Skipping shape (%ld) because LAYER::MINFEATURESIZE is bigger than shape size\n", shape.index);
msFreeShape(&shape);
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions mapdrawgdal.c
Expand Up @@ -1284,7 +1284,7 @@ static int ApplyLUT( int iColorIndex, layerObj *layer,
msSetError(MS_IOERR,
"LUT definition from file %s longer than maximum buffer size (%d bytes).",
"drawGDAL()",
path, sizeof(lut_def_fromfile) );
path, (int)sizeof(lut_def_fromfile) );
return -1;
}

Expand Down Expand Up @@ -1932,7 +1932,7 @@ msDrawRasterLayerGDAL_RawMode(
f_nodatas = (float *) calloc(sizeof(float),band_count);
if (f_nodatas == NULL) {
msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "msDrawRasterLayerGDAL_RawMode()",
__FILE__, __LINE__, sizeof(float)*band_count);
__FILE__, __LINE__, (unsigned int)(sizeof(float)*band_count));
free( band_list );
return -1;
}
Expand Down
8 changes: 4 additions & 4 deletions mapgd.c
Expand Up @@ -469,7 +469,7 @@ int renderGlyphsGD(imageObj *img, double x, double y, labelStyleObj *style, char
if(style->outlinewidth > 0) { /* handle the outline color */
error = gdImageStringFT(ip, bbox, oc, style->fonts[0], style->size, style->rotation, x, y-1, text);
if(error) {
msSetError(MS_TTFERR, error, "msDrawTextGD()");
msSetError(MS_TTFERR, "%s", "msDrawTextGD()", error);
return(MS_FAILURE);
}

Expand Down Expand Up @@ -732,7 +732,7 @@ int renderTruetypeSymbolGD(imageObj *img, double x, double y, symbolObj *symbol,
if( s->outlinecolor ) {
error = gdImageStringFT(ip, bbox, oc, symbol->full_font_path, s->scale, s->rotation, x, y-1, symbol->character);
if(error) {
msSetError(MS_TTFERR, error, "renderTruetypeSymbolGD()");
msSetError(MS_TTFERR, "%s", "renderTruetypeSymbolGD()", error);
return MS_FAILURE;
}

Expand Down Expand Up @@ -923,7 +923,7 @@ int getTruetypeTextBBoxGD(rendererVTableObj *renderer, char **fonts, int numfont
strex.flags = gdFTEX_XSHOW;
error = gdImageStringFTEx(NULL, bbox, 0, fonts[0], size, 0, 0, 0, string, &strex);
if(error) {
msSetError(MS_TTFERR, error, "gdImageStringFTEx()");
msSetError(MS_TTFERR, "%s", "gdImageStringFTEx()", error);
return(MS_FAILURE);
}

Expand All @@ -950,7 +950,7 @@ int getTruetypeTextBBoxGD(rendererVTableObj *renderer, char **fonts, int numfont
} else {
error = gdImageStringFT(NULL, bbox, 0, fonts[0], size, 0, 0, 0, string);
if(error) {
msSetError(MS_TTFERR, error, "msGetTruetypeTextBBoxGD()");
msSetError(MS_TTFERR, "%s", "msGetTruetypeTextBBoxGD()", error);
return(MS_FAILURE);
}

Expand Down
2 changes: 1 addition & 1 deletion mapgdal.c
Expand Up @@ -468,7 +468,7 @@ int msSaveImageGDAL( mapObj *map, imageObj *image, char *filename )
if (papszOptions == NULL) {
msReleaseLock( TLOCK_GDAL );
msSetError( MS_MEMERR, "Out of memory allocating %u bytes.\n", "msSaveImageGDAL()",
sizeof(char *)*(format->numformatoptions+1));
(unsigned int)(sizeof(char *)*(format->numformatoptions+1)));
return MS_FAILURE;
}

Expand Down
10 changes: 5 additions & 5 deletions mapgeomutil.cpp
Expand Up @@ -47,7 +47,7 @@ shapeObj *msRasterizeArc(double x0, double y0, double radius, double startAngle,
lineObj *line = (lineObj*)calloc(1,sizeof(lineObj));
if (!line) {
msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "msRasterizeArc()" ,
__FILE__, __LINE__, sizeof(lineObj));
__FILE__, __LINE__, (unsigned int)sizeof(lineObj));
free(shape);
return NULL;
}
Expand All @@ -56,7 +56,7 @@ shapeObj *msRasterizeArc(double x0, double y0, double radius, double startAngle,
line->point = (pointObj*)calloc(allocated_size,sizeof(pointObj));
if (!line->point) {
msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "msRasterizeArc()" ,
__FILE__, __LINE__, allocated_size*sizeof(pointObj));
__FILE__, __LINE__, (unsigned int)(allocated_size*sizeof(pointObj)));
free(line);
free(shape);
return NULL;
Expand All @@ -78,7 +78,7 @@ shapeObj *msRasterizeArc(double x0, double y0, double radius, double startAngle,
line->point = (pointObj*)realloc(line->point, allocated_size * sizeof(pointObj));
if (!line->point) {
msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "msRasterizeArc()" ,
__FILE__, __LINE__, allocated_size * sizeof(pointObj));
__FILE__, __LINE__, (unsigned int)(allocated_size * sizeof(pointObj)));
free(line);
free(shape);
return NULL;
Expand All @@ -98,7 +98,7 @@ shapeObj *msRasterizeArc(double x0, double y0, double radius, double startAngle,
line->point = (pointObj*)realloc(line->point, allocated_size * sizeof(pointObj));
if (!line->point) {
msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "msRasterizeArc()" ,
__FILE__, __LINE__, allocated_size * sizeof(pointObj));
__FILE__, __LINE__, (unsigned int)(allocated_size * sizeof(pointObj)));
free(line);
free(shape);
return NULL;
Expand All @@ -116,7 +116,7 @@ shapeObj *msRasterizeArc(double x0, double y0, double radius, double startAngle,
line->point = (pointObj*)realloc(line->point, allocated_size * sizeof(pointObj));
if (!line->point) {
msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "msRasterizeArc()" ,
__FILE__, __LINE__, allocated_size * sizeof(pointObj));
__FILE__, __LINE__, (unsigned int)(allocated_size * sizeof(pointObj)));
free(line);
free(shape);
return NULL;
Expand Down
8 changes: 4 additions & 4 deletions mapgml.c
Expand Up @@ -737,7 +737,7 @@ gmlGeometryListObj *msGMLGetGeometries(layerObj *layer, const char *metadata_nam
geometryList->geometries = (gmlGeometryObj *) malloc(sizeof(gmlGeometryObj)*geometryList->numgeometries);
if (geometryList->geometries == NULL) {
msSetError(MS_MEMERR, "Out of memory allocating %u bytes.\n", "msGMLGetGeometries()",
sizeof(gmlGeometryObj)*geometryList->numgeometries);
(unsigned int)(sizeof(gmlGeometryObj)*geometryList->numgeometries));
free(geometryList);
return NULL;
}
Expand Down Expand Up @@ -864,7 +864,7 @@ gmlNamespaceListObj *msGMLGetNamespaces(webObj *web, const char *metadata_namesp
namespaceList->namespaces = (gmlNamespaceObj *) malloc(sizeof(gmlNamespaceObj)*namespaceList->numnamespaces);
if (namespaceList->namespaces == NULL) {
msSetError(MS_MEMERR, "Out of memory allocating %u bytes.\n", "msGMLGetNamespaces()",
sizeof(gmlNamespaceObj)*namespaceList->numnamespaces);
(unsigned int)(sizeof(gmlNamespaceObj)*namespaceList->numnamespaces));
free(namespaceList);
return NULL;
}
Expand Down Expand Up @@ -933,7 +933,7 @@ gmlConstantListObj *msGMLGetConstants(layerObj *layer, const char *metadata_name
constantList->constants = (gmlConstantObj *) malloc(sizeof(gmlConstantObj)*constantList->numconstants);
if (constantList->constants == NULL) {
msSetError(MS_MEMERR, "Out of memory allocating %u bytes.\n", "msGMLGetConstants()",
sizeof(gmlConstantObj)*constantList->numconstants);
(unsigned int)(sizeof(gmlConstantObj)*constantList->numconstants));
free(constantList);
return NULL;
}
Expand Down Expand Up @@ -1024,7 +1024,7 @@ gmlGroupListObj *msGMLGetGroups(layerObj *layer, const char *metadata_namespaces
groupList->groups = (gmlGroupObj *) malloc(sizeof(gmlGroupObj)*groupList->numgroups);
if (groupList->groups == NULL) {
msSetError(MS_MEMERR, "Out of memory allocating %u bytes.\n", "msGMLGetGroups()",
sizeof(gmlGroupObj)*groupList->numgroups);
(unsigned int)(sizeof(gmlGroupObj)*groupList->numgroups));
free(groupList);
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion maphttp.c
Expand Up @@ -220,7 +220,7 @@ static size_t msHTTPWriteFct(void *buffer, size_t size, size_t nmemb,

if (psReq->debug) {
msDebug("msHTTPWriteFct(id=%d, %d bytes)\n",
psReq->nLayerId, size*nmemb);
psReq->nLayerId, (int)(size*nmemb));
}

/* Case where we are writing to a disk file. */
Expand Down
2 changes: 1 addition & 1 deletion mapimagemap.c
Expand Up @@ -698,7 +698,7 @@ int msSaveImageIM(imageObj* img, char *filename, outputFormatObj *format )
}
if (iIndice < size) {
sprintf(workbuffer, "%s", img->img.imagemap+iIndice );
msIO_fprintf(stream, workbuffer);
msIO_fprintf(stream, "%s", workbuffer);
}
} else
msIO_fwrite(img->img.imagemap, size, 1, stream);
Expand Down
4 changes: 1 addition & 3 deletions mapkmlrenderer.cpp
Expand Up @@ -984,9 +984,7 @@ char* KmlRenderer::lookupSymbolUrl(imageObj *img, symbolObj *symbol, symbolStyle
}

if (createIconImage(iconFileName, symbol, symstyle) != MS_SUCCESS) {
char errMsg[512];
sprintf(errMsg, "Error creating icon file '%s'", iconFileName);
msSetError(MS_IOERR, errMsg, "KmlRenderer::lookupSymbolStyle()" );
msSetError(MS_IOERR, "Error creating icon file '%s'", "KmlRenderer::lookupSymbolStyle()", iconFileName);
return NULL;
}

Expand Down

0 comments on commit 4d83a01

Please sign in to comment.