Skip to content

Commit

Permalink
more errors
Browse files Browse the repository at this point in the history
  • Loading branch information
paleolimbot committed Nov 29, 2023
1 parent b1b68cf commit c41200f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/geos-basic-strtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ SEXP geos_c_basic_strtree_query_geom(SEXP tree_xptr, SEXP xmin_sexp, SEXP ymin_s
GEOSSTRtree_query_r(handle, tree, geom, &basic_query_callback, query);
GEOSGeom_destroy_r(handle, geom);
if (query->has_error) {
Rf_error("Failed to allocate container for result indices [i = %d]", i + 1);
Rf_error("Failed to allocate container for result indices [i = %ld]", (long)i + 1);
}

if (fill && query->limit > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/geos-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ SEXP geos_common_tree_xptr(GEOSSTRtree* geometry, SEXP geom, SEXP indices);
// check geometry coming out of an externalptr
#define GEOS_CHECK_GEOMETRY(geometry, i) \
if (geometry == NULL) { \
Rf_error("External pointer is not valid [i=%d]", i + 1); \
Rf_error("External pointer is not valid [i=%ld]", (long)i + 1); \
}


Expand Down
24 changes: 12 additions & 12 deletions src/geos-make.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ SEXP geos_c_make_linestring(SEXP x, SEXP y, SEXP z, SEXP featureLengths) {
seq = GEOSCoordSeq_create_r(handle, featureLength, 3);
if (seq == NULL) {
UNPROTECT(1); // # nocov
GEOS_ERROR("[i=%d] ", iCoord); // # nocov
GEOS_ERROR("[i=%ld] ", (long)iCoord); // # nocov
}

for (int j = 0; j < featureLength; j++) {
Expand All @@ -81,7 +81,7 @@ SEXP geos_c_make_linestring(SEXP x, SEXP y, SEXP z, SEXP featureLengths) {
seq = GEOSCoordSeq_create_r(handle, featureLength, 2);
if (seq == NULL) {
UNPROTECT(1); // # nocov
GEOS_ERROR("[i=%d] ", iCoord); // # nocov
GEOS_ERROR("[i=%ld] ", (long)iCoord); // # nocov
}

for (int j = 0; j < featureLength; j++) {
Expand All @@ -96,7 +96,7 @@ SEXP geos_c_make_linestring(SEXP x, SEXP y, SEXP z, SEXP featureLengths) {
// attempting to destroy seq here results in crashing the session
if (itemGeometry == NULL) {
UNPROTECT(1);
GEOS_ERROR("[i=%d] ", iCoord);
GEOS_ERROR("[i=%ld] ", (long)iCoord);
}

SET_VECTOR_ELT(result, i, geos_common_geometry_xptr(itemGeometry));
Expand Down Expand Up @@ -161,7 +161,7 @@ SEXP geos_c_make_polygon(SEXP x, SEXP y, SEXP z, SEXP ringLengthsByFeature) {
if (seq == NULL) {
cleanup_geoms(handle, rings, j); // # nocov
UNPROTECT(1); // # nocov
GEOS_ERROR("[i=%d] ", iCoord); // # nocov
GEOS_ERROR("[i=%ld] ", (long)iCoord); // # nocov
}

for (int k = 0; k < ringLength; k++) {
Expand All @@ -181,7 +181,7 @@ SEXP geos_c_make_polygon(SEXP x, SEXP y, SEXP z, SEXP ringLengthsByFeature) {
if (seq == NULL) {
cleanup_geoms(handle, rings, j); // # nocov
UNPROTECT(1); // # nocov
GEOS_ERROR("[i=%d] ", iCoord); // # nocov
GEOS_ERROR("[i=%ld] ", (long)iCoord); // # nocov
}

for (int k = 0; k < ringLength; k++) {
Expand All @@ -201,7 +201,7 @@ SEXP geos_c_make_polygon(SEXP x, SEXP y, SEXP z, SEXP ringLengthsByFeature) {
if (rings[j] == NULL) {
cleanup_geoms(handle, rings, j);
UNPROTECT(1);
GEOS_ERROR("[i=%d] ", iCoord);
GEOS_ERROR("[i=%ld] ", (long)iCoord);
}
}

Expand All @@ -216,7 +216,7 @@ SEXP geos_c_make_polygon(SEXP x, SEXP y, SEXP z, SEXP ringLengthsByFeature) {
// pointers that are managed by a successful call to to
// GEOSGeom_create* functions also destroy the pointed to objects on error
UNPROTECT(1); // # nocov
GEOS_ERROR("[i=%d] ", iCoord); // # nocov
GEOS_ERROR("[i=%ld] ", (long)iCoord); // # nocov
}

SET_VECTOR_ELT(result, i, geos_common_geometry_xptr(itemGeometry));
Expand Down Expand Up @@ -253,22 +253,22 @@ SEXP geos_c_make_collection(SEXP geom, SEXP typeId, SEXP featureLengths) {
if (item == R_NilValue) {
cleanup_geoms(handle, geoms, j);
UNPROTECT(1);
Rf_error("[i=%d] Can't nest a missing geometry", iGeom);
Rf_error("[i=%ld] Can't nest a missing geometry", (long)iGeom);
}

itemGeometry = (GEOSGeometry*) R_ExternalPtrAddr(item);
if (itemGeometry == NULL) {
cleanup_geoms(handle, geoms, j);
UNPROTECT(1);
Rf_error("[i=%d] External pointer is not valid", iGeom);
Rf_error("[i=%ld] External pointer is not valid", (long)iGeom);
}

geoms[j] = GEOSGeom_clone_r(handle, itemGeometry);
// Don't know how to make this fire
if (geoms[j] == NULL) {
cleanup_geoms(handle, geoms, j); // # nocov;
UNPROTECT(1); // # nocov
GEOS_ERROR("[i=%d] ", iGeom); // # nocov
GEOS_ERROR("[i=%ld] ", (long)iGeom); // # nocov
}

iGeom++;
Expand All @@ -285,7 +285,7 @@ SEXP geos_c_make_collection(SEXP geom, SEXP typeId, SEXP featureLengths) {
}

UNPROTECT(1);
GEOS_ERROR("[i=%d] ", iGeom);
GEOS_ERROR("[i=%ld] ", (long)iGeom);
}

SET_VECTOR_ELT(result, i, geos_common_geometry_xptr(collection));
Expand Down Expand Up @@ -373,7 +373,7 @@ SEXP geos_c_empty(SEXP typeId) {

if (geometry == NULL) {
UNPROTECT(1);
GEOS_ERROR("[i=%d] ", i);
GEOS_ERROR("[i=%ld] ", (long)i);
}

SET_VECTOR_ELT(result, i, geos_common_geometry_xptr(geometry));
Expand Down
6 changes: 3 additions & 3 deletions src/geos-segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ SEXP geos_c_segment_intersection(SEXP Sax0, SEXP Say0, SEXP Sax1, SEXP Say1,
} else {
// this would fire if any value were NaN, which we have checked above
UNPROTECT(2); // # nocov
GEOS_ERROR("Can't compute segment intersection [i=%d]", i + 1); // # nocov
GEOS_ERROR("Can't compute segment intersection [i=%ld]", (long)i + 1); // # nocov
}

} else {
Expand All @@ -57,7 +57,7 @@ SEXP geos_c_segment_intersection(SEXP Sax0, SEXP Say0, SEXP Sax1, SEXP Say1,
}
}


const char* names[] = {"x", "y", ""};
SEXP result = PROTECT(Rf_mkNamed(VECSXP, names));
SET_VECTOR_ELT(result, 0, resultX);
Expand Down Expand Up @@ -93,7 +93,7 @@ SEXP geos_c_orientation_index(SEXP SAx, SEXP SAy, SEXP SBx, SEXP SBy, SEXP SPx,
if (resultCode == 2) {
// this would fire if any value were NaN, which we have checked above
UNPROTECT(1); // # nocov
GEOS_ERROR("Can't compute orientation index [i=%d]", i + 1); // # nocov
GEOS_ERROR("Can't compute orientation index [i=%ld]", (long)i + 1); // # nocov
}

INTEGER(result)[i] = resultCode;
Expand Down
2 changes: 1 addition & 1 deletion src/geos-unary-geometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ SEXP geos_c_ring_n(SEXP geom, SEXP n) {

// error for non-polygons
if (GEOSGeomTypeId_r(handle, geometry) != GEOS_POLYGON) {
Rf_error("[i=%d] Can't extract rings from a non-polygon", i);
Rf_error("[i=%ld] Can't extract rings from a non-polygon", (long)i);
}

// extraction can result in segfault rather than exception here
Expand Down

0 comments on commit c41200f

Please sign in to comment.