[postgis-tickets] r15667 - Change all PARANOIA blocks to throw errors instead of
Paul Ramsey
pramsey at cleverelephant.ca
Fri Sep 8 14:09:53 PDT 2017
Author: pramsey
Date: 2017-09-08 14:09:53 -0700 (Fri, 08 Sep 2017)
New Revision: 15667
Modified:
trunk/liblwgeom/lwcollection.c
trunk/liblwgeom/lwgeom_api.c
trunk/liblwgeom/lwgeom_geos.c
trunk/liblwgeom/lwgeom_geos_clean.c
trunk/liblwgeom/lwgeom_geos_split.c
trunk/liblwgeom/lwout_wkt.c
trunk/liblwgeom/ptarray.c
trunk/postgis/lwgeom_box3d.c
Log:
Change all PARANOIA blocks to throw errors instead of
quietly changing return values
Modified: trunk/liblwgeom/lwcollection.c
===================================================================
--- trunk/liblwgeom/lwcollection.c 2017-09-08 20:48:38 UTC (rev 15666)
+++ trunk/liblwgeom/lwcollection.c 2017-09-08 21:09:53 UTC (rev 15667)
@@ -219,6 +219,7 @@
{
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;
}
Modified: trunk/liblwgeom/lwgeom_api.c
===================================================================
--- trunk/liblwgeom/lwgeom_api.c 2017-09-08 20:48:38 UTC (rev 15666)
+++ trunk/liblwgeom/lwgeom_api.c 2017-09-08 21:09:53 UTC (rev 15667)
@@ -246,11 +246,15 @@
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 @@
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 @@
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 @@
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
Modified: trunk/liblwgeom/lwgeom_geos.c
===================================================================
--- trunk/liblwgeom/lwgeom_geos.c 2017-09-08 20:48:38 UTC (rev 15666)
+++ trunk/liblwgeom/lwgeom_geos.c 2017-09-08 21:09:53 UTC (rev 15667)
@@ -1250,7 +1250,7 @@
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 @@
#if PARANOIA_LEVEL > 0
if ( geom_out == NULL )
{
- lwerror("serialization error");
+ lwerror("%s [%s] serialization error", __FILE__, __LINE__);
return NULL;
}
Modified: trunk/liblwgeom/lwgeom_geos_clean.c
===================================================================
--- trunk/liblwgeom/lwgeom_geos_clean.c 2017-09-08 20:48:38 UTC (rev 15666)
+++ trunk/liblwgeom/lwgeom_geos_clean.c 2017-09-08 21:09:53 UTC (rev 15667)
@@ -964,7 +964,7 @@
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 */
}
}
Modified: trunk/liblwgeom/lwgeom_geos_split.c
===================================================================
--- trunk/liblwgeom/lwgeom_geos_split.c 2017-09-08 20:48:38 UTC (rev 15666)
+++ trunk/liblwgeom/lwgeom_geos_split.c 2017-09-08 21:09:53 UTC (rev 15667)
@@ -397,16 +397,6 @@
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 @@
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
Modified: trunk/liblwgeom/lwout_wkt.c
===================================================================
--- trunk/liblwgeom/lwout_wkt.c 2017-09-08 20:48:38 UTC (rev 15666)
+++ trunk/liblwgeom/lwout_wkt.c 2017-09-08 21:09:53 UTC (rev 15667)
@@ -160,7 +160,7 @@
return;
}
- ptarray_to_wkt_sb(line->points, sb, precision, variant);
+ ptarray_to_wkt_sb(line->points, sb, precision, variant);
}
/*
Modified: trunk/liblwgeom/ptarray.c
===================================================================
--- trunk/liblwgeom/ptarray.c 2017-09-08 20:48:38 UTC (rev 15666)
+++ trunk/liblwgeom/ptarray.c 2017-09-08 21:09:53 UTC (rev 15667)
@@ -564,14 +564,15 @@
#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 @@
#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 @@
( 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
Modified: trunk/postgis/lwgeom_box3d.c
===================================================================
--- trunk/postgis/lwgeom_box3d.c 2017-09-08 20:48:38 UTC (rev 15666)
+++ trunk/postgis/lwgeom_box3d.c 2017-09-08 21:09:53 UTC (rev 15667)
@@ -170,9 +170,7 @@
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;
More information about the postgis-tickets
mailing list