From a7f032948f0e6ee32b998586b247b7412b56d39b Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Sun, 20 Dec 2009 17:42:44 +0000 Subject: [PATCH] CFLAGS=-pedantic pass over the codebase and warnings reduced git-svn-id: http://svn.osgeo.org/postgis/trunk@5039 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/g_ptarray.c | 20 ++++----- liblwgeom/lwcollection.c | 3 +- liblwgeom/lwgeodetic.c | 4 +- liblwgeom/lwgeom.c | 2 +- liblwgeom/lwmline.c | 2 +- liblwgeom/lwmpoint.c | 2 +- liblwgeom/lwmpoly.c | 2 +- liblwgeom/lwtree.c | 2 +- liblwgeom/measures.c | 89 +++++++++++++++++----------------------- loader/pgsql2shp.c | 4 +- loader/shp2pgsql-core.c | 2 +- 11 files changed, 59 insertions(+), 73 deletions(-) diff --git a/liblwgeom/g_ptarray.c b/liblwgeom/g_ptarray.c index a43290d6e..67bfaec52 100644 --- a/liblwgeom/g_ptarray.c +++ b/liblwgeom/g_ptarray.c @@ -19,7 +19,7 @@ GPTARRAY* gptarray_new(uchar flags) ptarr->npoints = 0; ptarr->ordinates = (double*)lwalloc(ptarr->capacity); return ptarr; -}; +} GPTARRAY* gptarray_copy(GPTARRAY *ptarray) { @@ -33,7 +33,7 @@ GPTARRAY* gptarray_copy(GPTARRAY *ptarray) if( ! copy->ordinates ) return NULL; memcpy(copy->ordinates, ptarray->ordinates, copy->capacity); return copy; -}; +} GPTARRAY* gptarray_new_with_size(uchar flags, int npoints) { @@ -43,18 +43,18 @@ GPTARRAY* gptarray_new_with_size(uchar flags, int npoints) ptarray->npoints = npoints; ptarray->ordinates = (double*)lwalloc(ptarray->capacity); return ptarray; -}; +} GPTARRAY* gptarray_new_with_ordinates(uchar flags, int npoints, double *ordinates) { - assert(ordinates); GPTARRAY *ptarray = (GPTARRAY*)lwalloc(sizeof(GPTARRAY)); + assert(ordinates); ptarray->flags = flags; ptarray->capacity = 0; /* We aren't managing this memory, watch out. */ ptarray->npoints = npoints; ptarray->ordinates = ordinates; return ptarray; -}; +} void gptarray_free(GPTARRAY *ptarray) { @@ -63,7 +63,7 @@ void gptarray_free(GPTARRAY *ptarray) if( ptarray->capacity > 0 ) /* Only free the ordinates if we are managing them. */ lwfree(ptarray->ordinates); lwfree(ptarray); -}; +} void gptarray_add_coord(GPTARRAY *ptarray, GCOORDINATE *coord) { @@ -88,9 +88,9 @@ void gptarray_add_coord(GPTARRAY *ptarray, GCOORDINATE *coord) GCOORDINATE* gptarray_get_coord_ro(GPTARRAY *ptarray, int i) { + GCOORDINATE *coord; assert(ptarray); - - GCOORDINATE *coord = gcoord_new(ptarray->flags); + coord = gcoord_new(ptarray->flags); coord->ordinates = ptarray->ordinates + FLAGS_NDIMS(ptarray->flags) * i; @@ -99,9 +99,9 @@ GCOORDINATE* gptarray_get_coord_ro(GPTARRAY *ptarray, int i) GCOORDINATE* gptarray_get_coord_new(GPTARRAY *ptarray, int i) { + GCOORDINATE *coord; assert(ptarray); - - GCOORDINATE *coord = gcoord_new(ptarray->flags); + coord = gcoord_new(ptarray->flags); memcpy(coord->ordinates, ptarray->ordinates + FLAGS_NDIMS(ptarray->flags) * i, diff --git a/liblwgeom/lwcollection.c b/liblwgeom/lwcollection.c index 88c738cdc..43c8c6161 100644 --- a/liblwgeom/lwcollection.c +++ b/liblwgeom/lwcollection.c @@ -337,7 +337,6 @@ char lwcollection_same(const LWCOLLECTION *c1, const LWCOLLECTION *c2) { unsigned int i; -// unsigned int *hit; LWDEBUG(2, "lwcollection_same called"); @@ -503,7 +502,7 @@ void lwcollection_free(LWCOLLECTION *col) } lwfree(col); -}; +} BOX3D *lwcollection_compute_box3d(LWCOLLECTION *col) { diff --git a/liblwgeom/lwgeodetic.c b/liblwgeom/lwgeodetic.c index 5b7fa4c07..ebc1c31fb 100644 --- a/liblwgeom/lwgeodetic.c +++ b/liblwgeom/lwgeodetic.c @@ -2096,7 +2096,7 @@ int getPoint2d_p_ro(const POINTARRAY *pa, int n, POINT2D **point) assert(n < pa->npoints); pa_ptr = getPoint_internal(pa, n); - //printf( "pa_ptr[0]: %g\n", *((double*)pa_ptr)); + /* printf( "pa_ptr[0]: %g\n", *((double*)pa_ptr)); */ *point = (POINT2D*)pa_ptr; return G_SUCCESS; @@ -2289,7 +2289,7 @@ static int ptarray_check_geodetic(const POINTARRAY *pa) for (t=0; tnpoints; t++) { getPoint2d_p(pa, t, &pt); - //printf( "%d (%g, %g)\n", t, pt.x, pt.y); + /* printf( "%d (%g, %g)\n", t, pt.x, pt.y); */ if ( pt.x < -180.0 || pt.y < -90.0 || pt.x > 180.0 || pt.y > 90.0 ) return LW_FALSE; } diff --git a/liblwgeom/lwgeom.c b/liblwgeom/lwgeom.c index d85e02249..16e470f7f 100644 --- a/liblwgeom/lwgeom.c +++ b/liblwgeom/lwgeom.c @@ -977,7 +977,7 @@ void lwgeom_free(LWGEOM *lwgeom) } return; -}; +} int lwgeom_needs_bbox(const LWGEOM *geom) diff --git a/liblwgeom/lwmline.c b/liblwgeom/lwmline.c index f9c34cf3e..10ef57c1f 100644 --- a/liblwgeom/lwmline.c +++ b/liblwgeom/lwmline.c @@ -135,4 +135,4 @@ void lwmline_free(LWMLINE *mline) } lwfree(mline); -}; +} diff --git a/liblwgeom/lwmpoint.c b/liblwgeom/lwmpoint.c index d48e033fd..99e762312 100644 --- a/liblwgeom/lwmpoint.c +++ b/liblwgeom/lwmpoint.c @@ -135,5 +135,5 @@ void lwmpoint_free(LWMPOINT *mpt) } lwfree(mpt); -}; +} diff --git a/liblwgeom/lwmpoly.c b/liblwgeom/lwmpoly.c index 016926c5b..4303b151e 100644 --- a/liblwgeom/lwmpoly.c +++ b/liblwgeom/lwmpoly.c @@ -137,5 +137,5 @@ void lwmpoly_free(LWMPOLY *mpoly) } lwfree(mpoly); -}; +} diff --git a/liblwgeom/lwtree.c b/liblwgeom/lwtree.c index faff7335e..ee5c81120 100644 --- a/liblwgeom/lwtree.c +++ b/liblwgeom/lwtree.c @@ -47,7 +47,7 @@ int rect_tree_contains_point(const RECT_NODE *node, const POINT2D *pt, int *on_b rect_tree_contains_point(node->right_node, pt, on_boundary); } } - //printf("NOT in measure range\n"); + /* printf("NOT in measure range\n"); */ return 0; } diff --git a/liblwgeom/measures.c b/liblwgeom/measures.c index 520d62824..29ac57688 100644 --- a/liblwgeom/measures.c +++ b/liblwgeom/measures.c @@ -29,17 +29,18 @@ Function initializing shortestline and longestline calculations. LWGEOM * lw_dist2d_distanceline(uchar *lw1, uchar *lw2,int srid,int mode) { - LWDEBUG(2, "lw_dist2d_distanceline is called"); double x1,x2,y1,y2; LWPOINT *point1, *point2; double initdistance = ( mode == DIST2D_MIN ? MAXFLOAT : -1.0); DISTPTS thedl; + LWPOINT *lwpoints[2]; + LWGEOM *result; + thedl.mode = mode; thedl.distance = initdistance; thedl.tolerance = 0.0; - LWPOINT *lwpoints[2]; - LWGEOM *result; + LWDEBUG(2, "lw_dist2d_distanceline is called"); if (!lw_dist2d_comp( lw1,lw2,&thedl)) { @@ -78,16 +79,16 @@ Function initializing closestpoint calculations. LWGEOM * lw_dist2d_distancepoint(uchar *lw1, uchar *lw2,int srid,int mode) { - LWDEBUG(2, "lw_dist2d_distancepoint is called"); double x,y; DISTPTS thedl; double initdistance = MAXFLOAT; + LWGEOM *result; thedl.mode = mode; thedl.distance= initdistance; thedl.tolerance = 0; - LWGEOM *result; + LWDEBUG(2, "lw_dist2d_distancepoint is called"); if (!lw_dist2d_comp( lw1,lw2,&thedl)) { @@ -128,9 +129,9 @@ The difference is just the tolerance. double lwgeom_maxdistance2d_tolerance(uchar *lw1, uchar *lw2, double tolerance) { - LWDEBUG(2, "lwgeom_maxdistance2d_tolerance is called"); /*double thedist;*/ DISTPTS thedl; + LWDEBUG(2, "lwgeom_maxdistance2d_tolerance is called"); thedl.mode = DIST2D_MAX; thedl.distance= -1; thedl.tolerance = tolerance; @@ -160,8 +161,8 @@ lwgeom_mindistance2d(uchar *lw1, uchar *lw2) double lwgeom_mindistance2d_tolerance(uchar *lw1, uchar *lw2, double tolerance) { - LWDEBUG(2, "lwgeom_mindistance2d_tolerance is called"); DISTPTS thedl; + LWDEBUG(2, "lwgeom_mindistance2d_tolerance is called"); thedl.mode = DIST2D_MIN; thedl.distance= MAXFLOAT; thedl.tolerance = tolerance; @@ -192,10 +193,10 @@ Functions preparing geometries for distance-calculations int lw_dist2d_comp(uchar *lw1, uchar *lw2, DISTPTS *dl) { - LWDEBUG(2, "lw_dist2d_comp is called"); LWGEOM *lwg1 = lwgeom_deserialize(lw1); LWGEOM *lwg2 = lwgeom_deserialize(lw2); + LWDEBUG(2, "lw_dist2d_comp is called"); return lw_dist2d_recursive ((LWCOLLECTION*) lwg1,(LWCOLLECTION*) lwg2, dl); } @@ -205,15 +206,13 @@ This is a recursive function delivering every possible combinatin of subgeometri */ int lw_dist2d_recursive(const LWCOLLECTION * lwg1,const LWCOLLECTION * lwg2,DISTPTS *dl) { - LWDEBUGF(2, "lw_dist2d_comp is called with type1=%d, type2=%d", TYPE_GETTYPE(lwg1->type), TYPE_GETTYPE(lwg2->type)); - /*If empty gemetry, return. True here only means continue searching. False would have stoped the process - if (lwgeom_is_empty(lwg1)||lwgeom_is_empty(lwg2)) return LW_TRUE; moved down*/ - int i, j; int n1=1; - int n2=1;; + int n2=1; LWGEOM *g1, *g2; + LWDEBUGF(2, "lw_dist2d_comp is called with type1=%d, type2=%d", TYPE_GETTYPE(lwg1->type), TYPE_GETTYPE(lwg2->type)); + if (lwgeom_is_collection(TYPE_GETTYPE(lwg1->type))) { LWDEBUG(3, "First geometry is collection"); @@ -296,11 +295,11 @@ This function distributes the "old-type" brut-force tasks depending on type int lw_dist2d_distribute_bruteforce(LWGEOM *lwg1, LWGEOM *lwg2, DISTPTS *dl) { - LWDEBUGF(2, "lw_dist2d_distribute_bruteforce is called with typ1=%d, type2=%d", TYPE_GETTYPE(lwg1->type), TYPE_GETTYPE(lwg2->type)); int t1 = TYPE_GETTYPE(lwg1->type); int t2 = TYPE_GETTYPE(lwg2->type); + LWDEBUGF(2, "lw_dist2d_distribute_bruteforce is called with typ1=%d, type2=%d", TYPE_GETTYPE(lwg1->type), TYPE_GETTYPE(lwg2->type)); if ( t1 == POINTTYPE ) { @@ -413,12 +412,12 @@ Here the geometries are distributed for the new faster distance-calculations int lw_dist2d_distribute_fast(LWGEOM *lwg1, LWGEOM *lwg2, DISTPTS *dl) { - LWDEBUGF(2, "lw_dist2d_distribute_fast is called with typ1=%d, type2=%d", TYPE_GETTYPE(lwg1->type), TYPE_GETTYPE(lwg2->type)); - POINTARRAY *pa1, *pa2; int type1 = TYPE_GETTYPE(lwg1->type); int type2 = TYPE_GETTYPE(lwg2->type); + LWDEBUGF(2, "lw_dist2d_distribute_fast is called with typ1=%d, type2=%d", TYPE_GETTYPE(lwg1->type), TYPE_GETTYPE(lwg2->type)); + switch (type1) { case LINETYPE: @@ -481,9 +480,9 @@ point to line calculation int lw_dist2d_point_line(LWPOINT *point, LWLINE *line, DISTPTS *dl) { - LWDEBUG(2, "lw_dist2d_point_line is called"); POINT2D p; POINTARRAY *pa = line->points; + LWDEBUG(2, "lw_dist2d_point_line is called"); getPoint2d_p(point->point, 0, &p); return lw_dist2d_pt_ptarray(&p, pa, dl); } @@ -495,15 +494,12 @@ lw_dist2d_point_line(LWPOINT *point, LWLINE *line, DISTPTS *dl) int lw_dist2d_point_poly(LWPOINT *point, LWPOLY *poly, DISTPTS *dl) { - LWDEBUG(2, "lw_dist2d_point_poly called"); - POINT2D p; int i; - getPoint2d_p(point->point, 0, &p); - - + LWDEBUG(2, "lw_dist2d_point_poly called"); + getPoint2d_p(point->point, 0, &p); if (dl->mode == DIST2D_MAX) { @@ -551,9 +547,9 @@ line to line calculation int lw_dist2d_line_line(LWLINE *line1, LWLINE *line2, DISTPTS *dl) { - LWDEBUG(2, "lw_dist2d_line_line is called"); POINTARRAY *pa1 = line1->points; POINTARRAY *pa2 = line2->points; + LWDEBUG(2, "lw_dist2d_line_line is called"); return lw_dist2d_ptarray_ptarray(pa1, pa2, dl); } /** @@ -580,11 +576,10 @@ int lw_dist2d_poly_poly(LWPOLY *poly1, LWPOLY *poly2, DISTPTS *dl) { - LWDEBUG(2, "lw_dist2d_poly_poly called"); - POINT2D pt; int i; + LWDEBUG(2, "lw_dist2d_poly_poly called"); /*1 if we are looking for maxdistance, just check the outer rings.*/ if (dl->mode == DIST2D_MAX) @@ -664,11 +659,12 @@ lw_dist2d_poly_poly(LWPOLY *poly1, LWPOLY *poly2, DISTPTS *dl) int lw_dist2d_pt_ptarray(POINT2D *p, POINTARRAY *pa,DISTPTS *dl) { - LWDEBUG(2, "lw_dist2d_pt_ptarray is called"); - int t; POINT2D start, end; int twist = dl->twisted; + + LWDEBUG(2, "lw_dist2d_pt_ptarray is called"); + getPoint2d_p(pa, 0, &start); for (t=1; tnpoints; t++) @@ -698,12 +694,10 @@ lw_dist2d_pt_ptarray(POINT2D *p, POINTARRAY *pa,DISTPTS *dl) int lw_dist2d_ptarray_poly(POINTARRAY *pa, LWPOLY *poly, DISTPTS *dl) { - LWDEBUGF(2, "lw_dist2d_ptarray_poly called (%d rings)", poly->nrings); - POINT2D pt; int i; - + LWDEBUGF(2, "lw_dist2d_ptarray_poly called (%d rings)", poly->nrings); getPoint2d_p(pa, 0, &pt); if ( !pt_in_ring_2d(&pt, poly->rings[0])) @@ -770,13 +764,13 @@ test each segment of l1 against each segment of l2. int lw_dist2d_ptarray_ptarray(POINTARRAY *l1, POINTARRAY *l2,DISTPTS *dl) { - LWDEBUG(2, "lw_dist2d_ptarray_ptarray is called"); - int t,u; POINT2D start, end; POINT2D start2, end2; int twist = dl->twisted; + LWDEBUGF(2, "lw_dist2d_ptarray_ptarray called (points: %d-%d)",l1->npoints, l2->npoints); + if (dl->mode == DIST2D_MAX)/*If we are searching for maxdistance we go straight to point-point calculation since the maxdistance have to be between two vertexes*/ { for (t=0; tnpoints; t++) /*for each segment in L1 */ @@ -825,14 +819,11 @@ but just sending every possible combination further to lw_dist2d_pt_seg int lw_dist2d_seg_seg(POINT2D *A, POINT2D *B, POINT2D *C, POINT2D *D, DISTPTS *dl) { - LWDEBUGF(2, "lw_dist2d_seg_seg [%g,%g]->[%g,%g] by [%g,%g]->[%g,%g]", - A->x,A->y,B->x,B->y, C->x,C->y, D->x, D->y); - double s_top, s_bot,s; double r_top, r_bot,r; - - + LWDEBUGF(2, "lw_dist2d_seg_seg [%g,%g]->[%g,%g] by [%g,%g]->[%g,%g]", + A->x,A->y,B->x,B->y, C->x,C->y, D->x, D->y); /*A and B are the same point */ if ( ( A->x == B->x) && (A->y == B->y) ) @@ -954,19 +945,19 @@ chosen selection of the points not all of them int lw_dist2d_fast_ptarray_ptarray(POINTARRAY *l1, POINTARRAY *l2,DISTPTS *dl, BOX2DFLOAT4 *box1, BOX2DFLOAT4 *box2) { - LWDEBUG(2, "lw_dist2d_fast_ptarray_ptarray is called"); /*here we define two lists to hold our calculated "z"-values and the order number in the geometry*/ double k, thevalue; float deltaX, deltaY, c1m, c2m; POINT2D theP,c1, c2; float min1X, max1X, max1Y, min1Y,min2X, max2X, max2Y, min2Y; - int t, n1, n2; - n1 = l1->npoints; - n2 = l2->npoints; + int t; + int n1 = l1->npoints; + int n2 = l2->npoints; + LISTSTRUCT list1[n1]; /* This could be a problem, var-size array not legal in C90 */ + LISTSTRUCT list2[n2]; /* This could be a problem, var-size array not legal in C90 */ - LISTSTRUCT list1[n1]; - LISTSTRUCT list2[n2]; + LWDEBUG(2, "lw_dist2d_fast_ptarray_ptarray is called"); max1X = box1->xmax; min1X = box1->xmin; @@ -1023,7 +1014,7 @@ lw_dist2d_fast_ptarray_ptarray(POINTARRAY *l1, POINTARRAY *l2,DISTPTS *dl, BOX2D thevalue = theP.x-(k*theP.y); list1[t].themeasure=thevalue; list1[t].pnr=t; - //lwnotice("l1 %d, measure=%f",t,thevalue ); + /* lwnotice("l1 %d, measure=%f",t,thevalue ); */ } for (t=0; tnpoints; n2 = l2->npoints; + LWDEBUG(2, "lw_dist2d_pre_seg_seg is called"); getPoint2d_p(l1, list1[0].pnr, &p1); getPoint2d_p(l2, list2[0].pnr, &p3); @@ -1273,6 +1261,7 @@ To get this points it was nessecary to change and it also showed to be about 10% int lw_dist2d_pt_seg(POINT2D *p, POINT2D *A, POINT2D *B, DISTPTS *dl) { + POINT2D c; double r; /*if start==end, then use pt distance */ if ( ( A->x == B->x) && (A->y == B->y) ) @@ -1321,10 +1310,8 @@ lw_dist2d_pt_seg(POINT2D *p, POINT2D *A, POINT2D *B, DISTPTS *dl) return lw_dist2d_pt_pt(p,B,dl); } - /*else if the point p is closer to some point between a and b then we find that point and send it to lw_dist2d_pt_pt*/ - POINT2D c; c.x=A->x + r * (B->x-A->x); c.y=A->y + r * (B->y-A->y); diff --git a/loader/pgsql2shp.c b/loader/pgsql2shp.c index cfccf5c0e..5a09c91ce 100644 --- a/loader/pgsql2shp.c +++ b/loader/pgsql2shp.c @@ -30,9 +30,9 @@ static char rcsid[] = "$Id$"; /* Solaris9 does not provide stdint.h */ /* #include */ #include -#include // for getpid() +#include /* for getpid() */ -#ifdef HAVE_UNISTD_H // for getpid() and getopt +#ifdef HAVE_UNISTD_H /* for getpid() and getopt */ #include #endif diff --git a/loader/shp2pgsql-core.c b/loader/shp2pgsql-core.c index 4294c370e..da5dfa8f0 100644 --- a/loader/shp2pgsql-core.c +++ b/loader/shp2pgsql-core.c @@ -658,7 +658,7 @@ GeneratePolygonGeometry(SHPLOADERSTATE *state, SHPObject *obj, char **geometry) { Ring **Outer; int polygon_total, ring_total; - int pi, vi; // part index and vertex index + int pi, vi; /* part index and vertex index */ int u; LWCOLLECTION *lwcollection = NULL; -- 2.50.1