From 3a2c4e25eba6b5c1566a8a289d03f86dacdcb027 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Fri, 10 May 2013 07:51:19 +0000 Subject: [PATCH] Fix more compiler warnings There are still some that would be nice to fix, but it's mostly the array subscript is above array bounds one git-svn-id: http://svn.osgeo.org/postgis/trunk@11400 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/lwlinearreferencing.c | 26 +++++++++++++------------- liblwgeom/lwsegmentize.c | 3 +-- libpgcommon/lwgeom_pg.c | 10 +++++----- postgis/lwgeom_export.c | 6 ------ postgis/lwgeom_geos.c | 5 +++-- postgis/lwgeom_in_geohash.c | 3 ++- 6 files changed, 24 insertions(+), 29 deletions(-) diff --git a/liblwgeom/lwlinearreferencing.c b/liblwgeom/lwlinearreferencing.c index 772951648..a6795433b 100644 --- a/liblwgeom/lwlinearreferencing.c +++ b/liblwgeom/lwlinearreferencing.c @@ -526,7 +526,7 @@ lwline_clip_to_ordinate_range(const LWLINE *line, char ordinate, double from, do POINTARRAY *pa_in = NULL; LWCOLLECTION *lwgeom_out = NULL; POINTARRAY *dp = NULL; - int i, rv; + int i; int added_last_point = 0; POINT4D *p = NULL, *q = NULL, *r = NULL; double ordinate_value_p = 0.0, ordinate_value_q = 0.0; @@ -579,7 +579,7 @@ lwline_clip_to_ordinate_range(const LWLINE *line, char ordinate, double from, do *q = *p; ordinate_value_q = ordinate_value_p; } - rv = getPoint4d_p(pa_in, i, p); + getPoint4d_p(pa_in, i, p); ordinate_value_p = lwpoint_get_ordinate(p, ordinate); LWDEBUGF(4, " ordinate_value_p %g (current)", ordinate_value_p); LWDEBUGF(4, " ordinate_value_q %g (previous)", ordinate_value_q); @@ -607,13 +607,13 @@ lwline_clip_to_ordinate_range(const LWLINE *line, char ordinate, double from, do { double interpolation_value; (ordinate_value_q > to) ? (interpolation_value = to) : (interpolation_value = from); - rv = point_interpolate(q, p, r, hasz, hasm, ordinate, interpolation_value); - rv = ptarray_append_point(dp, r, LW_FALSE); + point_interpolate(q, p, r, hasz, hasm, ordinate, interpolation_value); + ptarray_append_point(dp, r, LW_FALSE); LWDEBUGF(4, "[0] interpolating between (%g, %g) with interpolation point (%g)", ordinate_value_q, ordinate_value_p, interpolation_value); } } /* Add the current vertex to the point array. */ - rv = ptarray_append_point(dp, p, LW_FALSE); + ptarray_append_point(dp, p, LW_FALSE); if ( ordinate_value_p == from || ordinate_value_p == to ) { added_last_point = 2; /* Added on boundary. */ @@ -633,8 +633,8 @@ lwline_clip_to_ordinate_range(const LWLINE *line, char ordinate, double from, do * to the point array at the range boundary. */ double interpolation_value; (ordinate_value_p > to) ? (interpolation_value = to) : (interpolation_value = from); - rv = point_interpolate(q, p, r, hasz, hasm, ordinate, interpolation_value); - rv = ptarray_append_point(dp, r, LW_FALSE); + point_interpolate(q, p, r, hasz, hasm, ordinate, interpolation_value); + ptarray_append_point(dp, r, LW_FALSE); LWDEBUGF(4, " [1] interpolating between (%g, %g) with interpolation point (%g)", ordinate_value_q, ordinate_value_p, interpolation_value); } else if ( added_last_point == 2 ) @@ -648,8 +648,8 @@ lwline_clip_to_ordinate_range(const LWLINE *line, char ordinate, double from, do { double interpolation_value; (ordinate_value_p > to) ? (interpolation_value = to) : (interpolation_value = from); - rv = point_interpolate(q, p, r, hasz, hasm, ordinate, interpolation_value); - rv = ptarray_append_point(dp, r, LW_FALSE); + point_interpolate(q, p, r, hasz, hasm, ordinate, interpolation_value); + ptarray_append_point(dp, r, LW_FALSE); LWDEBUGF(4, " [2] interpolating between (%g, %g) with interpolation point (%g)", ordinate_value_q, ordinate_value_p, interpolation_value); } } @@ -659,10 +659,10 @@ lwline_clip_to_ordinate_range(const LWLINE *line, char ordinate, double from, do * so we need to add *two* interpolated points! */ dp = ptarray_construct(hasz, hasm, 2); /* Interpolate lower point. */ - rv = point_interpolate(p, q, r, hasz, hasm, ordinate, from); + point_interpolate(p, q, r, hasz, hasm, ordinate, from); ptarray_set_point4d(dp, 0, r); /* Interpolate upper point. */ - rv = point_interpolate(p, q, r, hasz, hasm, ordinate, to); + point_interpolate(p, q, r, hasz, hasm, ordinate, to); ptarray_set_point4d(dp, 1, r); } else if ( i && ordinate_value_q > to && ordinate_value_p < from ) @@ -671,10 +671,10 @@ lwline_clip_to_ordinate_range(const LWLINE *line, char ordinate, double from, do * so we need to add *two* interpolated points! */ dp = ptarray_construct(hasz, hasm, 2); /* Interpolate upper point. */ - rv = point_interpolate(p, q, r, hasz, hasm, ordinate, to); + point_interpolate(p, q, r, hasz, hasm, ordinate, to); ptarray_set_point4d(dp, 0, r); /* Interpolate lower point. */ - rv = point_interpolate(p, q, r, hasz, hasm, ordinate, from); + point_interpolate(p, q, r, hasz, hasm, ordinate, from); ptarray_set_point4d(dp, 1, r); } /* We have an extant point-array, save it out to a multi-line. */ diff --git a/liblwgeom/lwsegmentize.c b/liblwgeom/lwsegmentize.c index ad91b2cc7..bc350fad1 100644 --- a/liblwgeom/lwsegmentize.c +++ b/liblwgeom/lwsegmentize.c @@ -110,7 +110,6 @@ lwcircle_segmentize(POINT4D *p1, POINT4D *p2, POINT4D *p3, uint32_t perQuad) double increment; /* Angle per segment */ double a1, a2, a3, angle; POINTARRAY *pa; - int result; int is_circle = LW_FALSE; LWDEBUG(2, "lwcircle_calculate_gbox called."); @@ -179,7 +178,7 @@ lwcircle_segmentize(POINT4D *p1, POINT4D *p2, POINT4D *p3, uint32_t perQuad) pt.y = center.y + radius * sin(angle); pt.z = interpolate_arc(angle, a1, a2, a3, p1->z, p2->z, p3->z); pt.m = interpolate_arc(angle, a1, a2, a3, p1->m, p2->m, p3->m); - result = ptarray_append_point(pa, &pt, LW_FALSE); + ptarray_append_point(pa, &pt, LW_FALSE); } return pa; } diff --git a/libpgcommon/lwgeom_pg.c b/libpgcommon/lwgeom_pg.c index 80cd3c9ee..09d3ecc9d 100644 --- a/libpgcommon/lwgeom_pg.c +++ b/libpgcommon/lwgeom_pg.c @@ -106,7 +106,7 @@ pg_unparser_errhint(LWGEOM_UNPARSER_RESULT *lwg_unparser_result) } -void * +static void * pg_alloc(size_t size) { void * result; @@ -127,7 +127,7 @@ pg_alloc(size_t size) return result; } -void * +static void * pg_realloc(void *mem, size_t size) { void * result; @@ -143,13 +143,13 @@ pg_realloc(void *mem, size_t size) return result; } -void +static void pg_free(void *ptr) { pfree(ptr); } -void +static void pg_error(const char *fmt, va_list ap) { #define ERRMSG_MAXLEN 256 @@ -162,7 +162,7 @@ pg_error(const char *fmt, va_list ap) ereport(ERROR, (errmsg_internal("%s", errmsg))); } -void +static void pg_notice(const char *fmt, va_list ap) { char *msg; diff --git a/postgis/lwgeom_export.c b/postgis/lwgeom_export.c index 644d4e797..72abf7ab5 100644 --- a/postgis/lwgeom_export.c +++ b/postgis/lwgeom_export.c @@ -487,8 +487,6 @@ Datum LWGEOM_asX3D(PG_FUNCTION_ARGS) char *srs; int srid; int option = 0; - int is_deegree = 0; - int is_dims = 1; int precision = DBL_DIG; static const char* default_defid = "x3d:"; /* default defid */ char *defidbuf; @@ -547,12 +545,8 @@ Datum LWGEOM_asX3D(PG_FUNCTION_ARGS) else if (option & 1) srs = getSRSbySRID(srid, false); else srs = getSRSbySRID(srid, true); - if (option & 2) is_dims = 0; - if (option & 16) is_deegree = 1; - lwgeom = lwgeom_from_gserialized(geom); - x3d = lwgeom_to_x3d3(lwgeom, srs, precision,option, defid); lwgeom_free(lwgeom); diff --git a/postgis/lwgeom_geos.c b/postgis/lwgeom_geos.c index 474248fc6..eac9a015d 100644 --- a/postgis/lwgeom_geos.c +++ b/postgis/lwgeom_geos.c @@ -892,6 +892,7 @@ Datum boundary(PG_FUNCTION_ARGS) GSERIALIZED *geom1; GEOSGeometry *g1, *g3; GSERIALIZED *result; + LWGEOM *lwgeom; int srid; @@ -903,10 +904,10 @@ Datum boundary(PG_FUNCTION_ARGS) srid = gserialized_get_srid(geom1); - LWGEOM *lwgeom = lwgeom_from_gserialized(geom1); + lwgeom = lwgeom_from_gserialized(geom1); if ( ! lwgeom ) { lwerror("POSTGIS2GEOS: unable to deserialize input"); - return NULL; + PG_RETURN_NULL(); } /* GEOS doesn't do triangle type, so we special case that here */ diff --git a/postgis/lwgeom_in_geohash.c b/postgis/lwgeom_in_geohash.c index c1163a8cc..703686172 100644 --- a/postgis/lwgeom_in_geohash.c +++ b/postgis/lwgeom_in_geohash.c @@ -15,6 +15,7 @@ #include "../postgis_config.h" #include "lwgeom_pg.h" #include "liblwgeom.h" +#include "liblwgeom_internal.h"/* for decode_geohash_bbox */ Datum box2d_from_geohash(PG_FUNCTION_ARGS); Datum point_from_geohash(PG_FUNCTION_ARGS); @@ -27,7 +28,7 @@ static void geohash_lwerror(char *msg, int error_code) #include "lwgeom_export.h" -GBOX* +static GBOX* parse_geohash(char *geohash, int precision) { GBOX *box = NULL; -- 2.40.0