Skip to content

Commit

Permalink
Fix gcc warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tidwall committed Jan 4, 2025
1 parent 248e74b commit bdfaa88
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
42 changes: 21 additions & 21 deletions tests/test_geobin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion tg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bdfaa88

Please sign in to comment.