From bdfaa88c08bbe2959421aa28fd204e6a1172090a Mon Sep 17 00:00:00 2001 From: tidwall Date: Fri, 3 Jan 2025 17:03:59 -0700 Subject: [PATCH] Fix gcc warnings --- tests/test_geobin.c | 42 +++++++++++++++++++++--------------------- tg.c | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/test_geobin.c b/tests/test_geobin.c index eaee409..ac285c7 100644 --- a/tests/test_geobin.c +++ b/tests/test_geobin.c @@ -53,37 +53,37 @@ void perfect_match(const char *geojson_or_wkt, const char *expect, int dims, dou void test_geobin_basic_syntax(void) { assert(tg_geom_geobin(0, 0, 0) == 0); - perfect_match("{\"type\":\"Point\",\"coordinates\":[55,44]}", 0, 2, (double[]){55, 44}, (double[]){55, 44}); - perfect_match("{\"type\":\"Point\",\"coordinates\":[55,44,33]}", 0, 3, (double[]){55, 44, 33}, (double[]){55, 44, 33}); - perfect_match("{\"type\":\"Point\",\"coordinates\":[55,44,33,22]}", 0, 4, (double[]){55, 44, 33, 22}, (double[]){55, 44, 33, 22}); - perfect_match("{\"type\":\"Point\",\"coordinates\":[55,44],\"a\":{\"b\":\"c\"}}", 0, 2, (double[]){55, 44}, (double[]){55, 44}); - perfect_match("{\"type\":\"Point\",\"coordinates\":[55,44,33],\"a\":{\"b\":\"c\"}}", 0, 3, (double[]){55, 44, 33}, (double[]){55, 44, 33}); - perfect_match("{\"type\":\"Point\",\"coordinates\":[55,44,33,22],\"a\":{\"b\":\"c\"}}", 0, 4, (double[]){55, 44, 33, 22}, (double[]){55, 44, 33, 22}); - perfect_match("POINT(55 44)", 0, 2, (double[]){55, 44}, (double[]){55, 44}); - perfect_match("POINT(55 44 33)", 0, 3, (double[]){55, 44, 33}, (double[]){55, 44, 33}); - perfect_match("POINT(55 44 33 22)", 0, 4, (double[]){55, 44, 33, 22}, (double[]){55, 44, 33, 22}); - perfect_match("POINT(55 44)", 0, 2, (double[]){55, 44}, (double[]){55, 44}); - perfect_match("POINTZ(55 44 33)", "POINT(55 44 33)", 3, (double[]){55, 44, 33}, (double[]){55, 44, 33}); - perfect_match("POINTM(55 44 33)", "POINT M(55 44 33)", 3, (double[]){55, 44, 33}, (double[]){55, 44, 33}); - perfect_match("POINT(55 44 33 22)", 0, 4, (double[]){55, 44, 33, 22}, (double[]){55, 44, 33, 22}); - perfect_match("{\"type\":\"LineString\",\"coordinates\":[[55,44],[33,22]]}", 0, 2, (double[]){33, 22}, (double[]){55, 44}); - perfect_match("{\"type\":\"LineString\",\"coordinates\":[[55,44,11],[33,22,66]]}", 0, 3, (double[]){33, 22,11}, (double[]){55, 44,66}); - perfect_match("{\"type\":\"LineString\",\"coordinates\":[[55,44,11,99],[33,22,66,77]]}", 0, 4, (double[]){33, 22, 11, 77}, (double[]){55, 44, 66, 99}); - perfect_match("{\"type\":\"Polygon\",\"coordinates\":[[[33,44],[55,66],[33,44]]]}", 0, 2, (double[]){33, 44}, (double[]){55, 66}); - perfect_match("{\"type\":\"Polygon\",\"coordinates\":[[[33,44],[55,66],[44,66],[33,44]],[[42,61],[46,61],[46,64],[42,61]]]}", 0, 2, (double[]){33, 44}, (double[]){55, 66}); + perfect_match("{\"type\":\"Point\",\"coordinates\":[55,44]}", 0, 2, (double[4]){55, 44}, (double[4]){55, 44}); + perfect_match("{\"type\":\"Point\",\"coordinates\":[55,44,33]}", 0, 3, (double[4]){55, 44, 33}, (double[4]){55, 44, 33}); + perfect_match("{\"type\":\"Point\",\"coordinates\":[55,44,33,22]}", 0, 4, (double[4]){55, 44, 33, 22}, (double[4]){55, 44, 33, 22}); + perfect_match("{\"type\":\"Point\",\"coordinates\":[55,44],\"a\":{\"b\":\"c\"}}", 0, 2, (double[4]){55, 44}, (double[4]){55, 44}); + perfect_match("{\"type\":\"Point\",\"coordinates\":[55,44,33],\"a\":{\"b\":\"c\"}}", 0, 3, (double[4]){55, 44, 33}, (double[4]){55, 44, 33}); + perfect_match("{\"type\":\"Point\",\"coordinates\":[55,44,33,22],\"a\":{\"b\":\"c\"}}", 0, 4, (double[4]){55, 44, 33, 22}, (double[4]){55, 44, 33, 22}); + perfect_match("POINT(55 44)", 0, 2, (double[4]){55, 44}, (double[4]){55, 44}); + perfect_match("POINT(55 44 33)", 0, 3, (double[4]){55, 44, 33}, (double[4]){55, 44, 33}); + perfect_match("POINT(55 44 33 22)", 0, 4, (double[4]){55, 44, 33, 22}, (double[4]){55, 44, 33, 22}); + perfect_match("POINT(55 44)", 0, 2, (double[4]){55, 44}, (double[4]){55, 44}); + perfect_match("POINTZ(55 44 33)", "POINT(55 44 33)", 3, (double[4]){55, 44, 33}, (double[4]){55, 44, 33}); + perfect_match("POINTM(55 44 33)", "POINT M(55 44 33)", 3, (double[4]){55, 44, 33}, (double[4]){55, 44, 33}); + perfect_match("POINT(55 44 33 22)", 0, 4, (double[4]){55, 44, 33, 22}, (double[4]){55, 44, 33, 22}); + perfect_match("{\"type\":\"LineString\",\"coordinates\":[[55,44],[33,22]]}", 0, 2, (double[4]){33, 22}, (double[4]){55, 44}); + perfect_match("{\"type\":\"LineString\",\"coordinates\":[[55,44,11],[33,22,66]]}", 0, 3, (double[4]){33, 22,11}, (double[4]){55, 44,66}); + perfect_match("{\"type\":\"LineString\",\"coordinates\":[[55,44,11,99],[33,22,66,77]]}", 0, 4, (double[4]){33, 22, 11, 77}, (double[4]){55, 44, 66, 99}); + perfect_match("{\"type\":\"Polygon\",\"coordinates\":[[[33,44],[55,66],[33,44]]]}", 0, 2, (double[4]){33, 44}, (double[4]){55, 66}); + perfect_match("{\"type\":\"Polygon\",\"coordinates\":[[[33,44],[55,66],[44,66],[33,44]],[[42,61],[46,61],[46,64],[42,61]]]}", 0, 2, (double[4]){33, 44}, (double[4]){55, 66}); perfect_match( "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[33,44],[55,66],[44,66],[33,44]],[[42,61],[46,61],[46,64],[42,61]]]}}", "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[33,44],[55,66],[44,66],[33,44]],[[42,61],[46,61],[46,64],[42,61]]]},\"properties\":{}}", - 2, (double[]){33, 44}, (double[]){55, 66}); + 2, (double[4]){33, 44}, (double[4]){55, 66}); perfect_match( "{\"type\":\"Feature\",\"id\":123,\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[33,44],[55,66],[44,66],[33,44]],[[42,61],[46,61],[46,64],[42,61]]]},\"properties\":{\"a\":\"b\"}}", - 0, 2, (double[]){33, 44}, (double[]){55, 66}); + 0, 2, (double[4]){33, 44}, (double[4]){55, 66}); perfect_match( "{\"type\":\"FeatureCollection\",\"features\":[" "{\"type\":\"Feature\",\"id\":123,\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[33,44],[55,66],[44,66],[33,44]],[[42,61],[46,61],[46,64],[42,61]]]},\"properties\":{\"a\":\"b\"}}," "{\"type\":\"Feature\",\"id\":123,\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[33,44],[55,66],[44,66],[33,44]],[[42,61],[46,61],[46,64],[42,61]]]},\"properties\":{\"a\":\"b\"}}" "]}", - 0, 2, (double[]){33, 44}, (double[]){55, 66}); + 0, 2, (double[4]){33, 44}, (double[4]){55, 66}); } void test_geobin_fail() { diff --git a/tg.c b/tg.c index 11bf6e6..4fa1163 100644 --- a/tg.c +++ b/tg.c @@ -14800,7 +14800,7 @@ int tg_geobin_fullrect(const uint8_t *geobin, size_t len, double min[4], memcpy(min, geobin+5, 8*dims); memcpy(max, geobin+5, 8*dims); } - } else if (geobin[0] != 0x01 && len >= 2+8*geobin[1]*2){ + } else if (geobin[0] != 0x01 && len >= 2+8*(size_t)geobin[1]*2){ // Read MBR dims = geobin[1]; memcpy(min, geobin+2, 8*dims);