]> granicus.if.org Git - postgis/commitdiff
CFLAGS=-pedantic pass over the codebase and warnings reduced
authorPaul Ramsey <pramsey@cleverelephant.ca>
Sun, 20 Dec 2009 17:42:44 +0000 (17:42 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Sun, 20 Dec 2009 17:42:44 +0000 (17:42 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@5039 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/g_ptarray.c
liblwgeom/lwcollection.c
liblwgeom/lwgeodetic.c
liblwgeom/lwgeom.c
liblwgeom/lwmline.c
liblwgeom/lwmpoint.c
liblwgeom/lwmpoly.c
liblwgeom/lwtree.c
liblwgeom/measures.c
loader/pgsql2shp.c
loader/shp2pgsql-core.c

index a43290d6e49e9e4fd599ff9eec957167c726db58..67bfaec5212275f06f8e8b457ee82fdd6fc35887 100644 (file)
@@ -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,
index 88c738cdc0264934cb0427677ec5b8dd36e4bbcb..43c8c616179b15f8f6960d28b3611accf1a0302d 100644 (file)
@@ -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)
 {
index 5b7fa4c0701f047b7c328d385128330ce077a57a..ebc1c31fb24d8bdb25f0fc398ee5a159695960b3 100644 (file)
@@ -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; t<pa->npoints; 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;
        }
index d85e02249c139b5108637ae2b1a7e202c3398654..16e470f7f92534000cec326369c569506b19c95c 100644 (file)
@@ -977,7 +977,7 @@ void lwgeom_free(LWGEOM *lwgeom)
        }
        return;
 
-};
+}
 
 
 int lwgeom_needs_bbox(const LWGEOM *geom)
index f9c34cf3e54f8f262bfadf3260550bbd8c3bc04c..10ef57c1f7f950e2ef83e75b1fa696b0e2fcfe9d 100644 (file)
@@ -135,4 +135,4 @@ void lwmline_free(LWMLINE *mline)
        }
        lwfree(mline);
 
-};
+}
index d48e033fdfe6fe2de2092be9fe407d138e0d33c1..99e762312314b3f797783a4240173d93ecefc42b 100644 (file)
@@ -135,5 +135,5 @@ void lwmpoint_free(LWMPOINT *mpt)
        }
        lwfree(mpt);
 
-};
+}
 
index 016926c5b1997c9ea45b0aa4a59bf1510864a494..4303b151e30ad591c0941020d8a64ac5e5b21f5a 100644 (file)
@@ -137,5 +137,5 @@ void lwmpoly_free(LWMPOLY *mpoly)
        }
        lwfree(mpoly);
 
-};
+}
 
index faff7335e2764848193f2d8235628b7850366029..ee5c811202bb65ecce17764b48d12847fd4b5c13 100644 (file)
@@ -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;
 }
 
index 520d62824aaf708ebfede18bbca16e25b8ed37fa..29ac576887ddc02929b7916d3cb2d2ae16f63cb1 100644 (file)
@@ -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; t<pa->npoints; 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; t<l1->npoints; 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; t<n2; t++) /*for each segment in L2*/
                {
@@ -1032,7 +1023,7 @@ lw_dist2d_fast_ptarray_ptarray(POINTARRAY *l1, POINTARRAY *l2,DISTPTS *dl, BOX2D
                        thevalue = theP.x-(k*theP.y);
                        list2[t].themeasure=thevalue;
                        list2[t].pnr=t;
-                       //lwnotice("l2 %d, measure=%f",t,thevalue );
+                       /* lwnotice("l2 %d, measure=%f",t,thevalue ); */
                }
                c1m = c1.x-(k*c1.y);
                c2m = c2.x-(k*c2.y);
@@ -1068,16 +1059,13 @@ struct_cmp_by_measure(const void *a, const void *b)
 int
 lw_dist2d_pre_seg_seg(POINTARRAY *l1, POINTARRAY *l2,LISTSTRUCT *list1, LISTSTRUCT *list2,double k, DISTPTS *dl)
 {
-       LWDEBUG(2, "lw_dist2d_pre_seg_seg is called");
-
-
        POINT2D p1, p2, p3, p4, p01, p02;
        int pnr1,pnr2,pnr3,pnr4, n1, n2, i, u, r, twist;
-
        double maxmeasure;
        n1=     l1->npoints;
        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);
 
index cfccf5c0e4db6158df8f9db7444fabb3fe3bc9df..5a09c91ceeba624895faeab93d20688d7ae80dac 100644 (file)
@@ -30,9 +30,9 @@ static char rcsid[] = "$Id$";
 /* Solaris9 does not provide stdint.h */
 /* #include <stdint.h> */
 #include <inttypes.h>
-#include <sys/types.h> // for getpid()
+#include <sys/types.h> /* for getpid() */
 
-#ifdef HAVE_UNISTD_H // for getpid() and getopt
+#ifdef HAVE_UNISTD_H /* for getpid() and getopt */
 #include <unistd.h> 
 #endif
 
index 4294c370ea8d01638ecf3cf56c2922816b2de72b..da5dfa8f09a74901eb5a1f5dec3df3bfdecadaf4 100644 (file)
@@ -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;