]> granicus.if.org Git - postgis/commitdiff
Change all PARANOIA blocks to throw errors instead of
authorPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 8 Sep 2017 21:09:53 +0000 (21:09 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 8 Sep 2017 21:09:53 +0000 (21:09 +0000)
quietly changing return values

git-svn-id: http://svn.osgeo.org/postgis/trunk@15667 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/lwcollection.c
liblwgeom/lwgeom_api.c
liblwgeom/lwgeom_geos.c
liblwgeom/lwgeom_geos_clean.c
liblwgeom/lwgeom_geos_split.c
liblwgeom/lwout_wkt.c
liblwgeom/ptarray.c
postgis/lwgeom_box3d.c

index cfb6d923f42dcae863b4469c63f13b163647d597..f1a1604d4080c9dd772e883784d00a815f491bae 100644 (file)
@@ -219,6 +219,7 @@ LWCOLLECTION* lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
        {
                if ( col->geoms[i] == geom )
                {
+            lwerror("%s [%d] found duplicate geometry in collection %p == %p", __FILE__, __LINE__, col->geoms[i], geom);
                        LWDEBUGF(4, "Found duplicate geometry in collection %p == %p", col->geoms[i], geom);
                        return col;
                }
index 0997725cd0e10273670c659d87f47302ab7b0b1e..01122259d5445a6a27890d65c96343e78372a82f 100644 (file)
@@ -246,11 +246,15 @@ getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *op)
        int zmflag;
 
 #if PARANOIA_LEVEL > 0
-       if ( ! pa ) lwerror("getPoint4d_p: NULL pointarray");
+       if ( ! pa ) 
+       {
+               lwerror("%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
+               return 0;
+       }
 
        if ( (n<0) || (n>=pa->npoints))
        {
-               lwerror("getPoint4d_p: point offset out of range");
+               lwerror("%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
                return 0;
        }
 #endif
@@ -335,12 +339,16 @@ getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *op)
        uint8_t *ptr;
 
 #if PARANOIA_LEVEL > 0
-       if ( ! pa ) return 0;
+       if ( ! pa ) 
+       {
+               lwerror("%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
+               return 0;
+       }
 
        if ( (n<0) || (n>=pa->npoints))
        {
-               LWDEBUGF(4, "%d out of numpoint range (%d)", n, pa->npoints);
-               return 0; /*error */
+               lwerror("%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
+               return 0;
        }
 #endif
 
@@ -386,12 +394,16 @@ getPoint3dm_p(const POINTARRAY *pa, int n, POINT3DM *op)
        int zmflag;
 
 #if PARANOIA_LEVEL > 0
-       if ( ! pa ) return 0;
+       if ( ! pa ) 
+       {
+               lwerror("%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
+               return 0;
+       }
 
        if ( (n<0) || (n>=pa->npoints))
        {
-               lwerror("%d out of numpoint range (%d)", n, pa->npoints);
-               return 0; /*error */
+               lwerror("%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
+               return 0;
        }
 #endif
 
@@ -462,12 +474,16 @@ int
 getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
 {
 #if PARANOIA_LEVEL > 0
-       if ( ! pa ) return 0;
+       if ( ! pa ) 
+       {
+               lwerror("%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
+               return 0;
+       }
 
        if ( (n<0) || (n>=pa->npoints))
        {
-               lwerror("getPoint2d_p: point offset out of range");
-               return 0; /*error */
+               lwerror("%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
+               return 0;
        }
 #endif
 
index dde69595a13fce107e7f57d73780925a52e6b26b..14799810fbf6466ffebb0515fc41fad047ce523f 100644 (file)
@@ -1250,7 +1250,7 @@ LWGEOM_GEOS_buildArea(const GEOSGeometry* geom_in)
   if ( GEOSGeomTypeId(geos_result) != COLLECTIONTYPE )
   {
     GEOSGeom_destroy(geos_result);
-    lwerror("Unexpected return from GEOSpolygonize");
+    lwerror("%s [%d] Unexpected return from GEOSpolygonize", __FILE__, __LINE__);
     return 0;
   }
 #endif
@@ -1431,7 +1431,7 @@ lwgeom_buildarea(const LWGEOM *geom)
 #if PARANOIA_LEVEL > 0
        if ( geom_out == NULL )
        {
-               lwerror("serialization error");
+               lwerror("%s [%s] serialization error", __FILE__, __LINE__);
                return NULL;
        }
 
index a30e696466ea04f5a22aa2d32db0f77839e2ecd9..5a6138a4e8788c42915c088c2185e18529698be9 100644 (file)
@@ -964,7 +964,7 @@ LWGEOM_GEOS_makeValid(const GEOSGeometry* gin)
                        GEOSGeom_destroy(pd);
                        if ( loss )
                        {
-                               lwnotice("Vertices lost in LWGEOM_GEOS_makeValid");
+                               lwnotice("%s [%d] Vertices lost in LWGEOM_GEOS_makeValid", __FILE__, __LINE__);
                                /* return NULL */
                        }
        }
index 3447aed0ebc6d3f829b1e0044de804605ea00f5b..4e41a6764540a3d66e1ee2ebad6cea52ced29029 100644 (file)
@@ -397,16 +397,6 @@ lwpoly_split_by_line(const LWPOLY* lwpoly_in, const LWLINE* blade_in)
                return NULL;
        }
 
-       /* debugging..
-               lwnotice("Bounds poly: %s",
-                              lwgeom_to_ewkt(GEOS2LWGEOM(g1_bounds, hasZ)));
-               lwnotice("Line: %s",
-                              lwgeom_to_ewkt(GEOS2LWGEOM(g2, hasZ)));
-
-               lwnotice("Noded bounds: %s",
-                              lwgeom_to_ewkt(GEOS2LWGEOM(vgeoms[0], hasZ)));
-       */
-
        polygons = GEOSPolygonize(vgeoms, 1);
        if ( NULL == polygons )
        {
@@ -426,7 +416,7 @@ lwpoly_split_by_line(const LWPOLY* lwpoly_in, const LWLINE* blade_in)
                GEOSGeom_destroy(g1_bounds);
                GEOSGeom_destroy((GEOSGeometry*)vgeoms[0]);
                GEOSGeom_destroy(polygons);
-               lwerror("Unexpected return from GEOSpolygonize");
+               lwerror("%s [%s] Unexpected return from GEOSpolygonize", __FILE__, __LINE__);
                return 0;
        }
 #endif
index e04db3c2a68cd6a6dd3d452afd7f7edbc53442b3..5fbccb76b37e2316e80d93aece1fb2f95e708e7b 100644 (file)
@@ -160,7 +160,7 @@ static void lwline_to_wkt_sb(const LWLINE *line, stringbuffer_t *sb, int precisi
                return;
        }
 
-       ptarray_to_wkt_sb(line->points, sb, precision, variant);
+    ptarray_to_wkt_sb(line->points, sb, precision, variant);
 }
 
 /*
index 102b2c1bd98e6ba6f383cc7f97f9851b63c5cfc3..9394534d8bc21b55bcf0b58c5ebe9eeca61f2186 100644 (file)
@@ -564,14 +564,15 @@ ptarray_removePoint(POINTARRAY *pa, uint32_t which)
 #if PARANOIA_LEVEL > 0
        if ( which > pa->npoints-1 )
        {
-               lwerror("ptarray_removePoint: offset (%d) out of range (%d..%d)",
+               lwerror("%s [%d] offset (%d) out of range (%d..%d)", __FILE__, __LINE__,
                        which, 0, pa->npoints-1);
                return NULL;
        }
 
        if ( pa->npoints < 3 )
        {
-               lwerror("ptarray_removePointe: can't remove a point from a 2-vertex POINTARRAY");
+               lwerror("%s [%d] can't remove a point from a 2-vertex POINTARRAY", __FILE__, __LINE__);
+               return NULL;
        }
 #endif
 
@@ -1706,7 +1707,7 @@ getPoint_internal(const POINTARRAY *pa, int n)
 #if PARANOIA_LEVEL > 0
        if ( pa == NULL )
        {
-               lwerror("getPoint got NULL pointarray");
+               lwerror("%s [%d] got NULL pointarray", __FILE__, __LINE__);
                return NULL;
        }
 
@@ -1716,7 +1717,7 @@ getPoint_internal(const POINTARRAY *pa, int n)
             ( n > pa->npoints ) ||
             ( n >= pa->maxpoints ) )
        {
-               lwerror("getPoint_internal called outside of ptarray range (n=%d, pa.npoints=%d, pa.maxpoints=%d)",n,pa->npoints,pa->maxpoints);
+               lwerror("%s [%d] called outside of ptarray range (n=%d, pa.npoints=%d, pa.maxpoints=%d)", __FILE__, __LINE__, n, pa->npoints, pa->maxpoints);
                return NULL; /*error */
        }
 #endif
index e67b4387c8588653406fd93d0921a0e16e405bd4..1a6a2c1a7ea24ef0577692452314e55afc92f68a 100644 (file)
@@ -170,9 +170,7 @@ Datum BOX3D_to_BOX2D(PG_FUNCTION_ARGS)
 static void
 box3d_to_box_p(BOX3D *box, BOX *out)
 {
-#if PARANOIA_LEVEL > 0
-       if (box == NULL) return;
-#endif
+       if ( ! box ) return;
 
        out->low.x = box->xmin;
        out->low.y = box->ymin;