From 43e5b6147e88bcec4fb9365675ca7524e9978041 Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Wed, 26 Jun 2024 11:33:56 -0700 Subject: [PATCH] Fix warnings --- clip.cpp | 4 ++-- geometry.cpp | 2 +- main.cpp | 5 ++++- serial.cpp | 4 ++-- shared_borders.cpp | 2 +- tile.cpp | 5 ++++- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/clip.cpp b/clip.cpp index 77445496..930ceca8 100644 --- a/clip.cpp +++ b/clip.cpp @@ -341,7 +341,7 @@ drawvec clean_or_clip_poly(drawvec &geom, int z, int buffer, bool clip, bool try if (k != i) { fprintf(f, ","); } - fprintf(f, "[%lld,%lld]", geom[k].x, geom[k].y); + fprintf(f, "[%lld,%lld]", (long long) geom[k].x, (long long) geom[k].y); } fprintf(f, "]"); @@ -1008,7 +1008,7 @@ drawvec reduce_tiny_poly(drawvec const &geom, int z, int detail, bool *still_nee fprintf(stderr, "how did we get here with %d in %d?\n", geom[i].op, (int) geom.size()); for (size_t n = 0; n < geom.size(); n++) { - fprintf(stderr, "%d/%lld/%lld ", geom[n].op, geom[n].x, geom[n].y); + fprintf(stderr, "%d/%lld/%lld ", geom[n].op, (long long) geom[n].x, (long long) geom[n].y); } fprintf(stderr, "\n"); diff --git a/geometry.cpp b/geometry.cpp index 9b9ceacf..376cc493 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -159,7 +159,7 @@ void check_polygon(drawvec &geom) { } if (!on_edge) { - fprintf(stderr, "%lld,%lld at %lld not in outer ring (%lld to %lld)\n", geom[k].x, geom[k].y, (long long) k, (long long) outer_start, (long long) (outer_start + outer_len)); + fprintf(stderr, "%lld,%lld at %lld not in outer ring (%lld to %lld)\n", (long long) geom[k].x, (long long) geom[k].y, (long long) k, (long long) outer_start, (long long) (outer_start + outer_len)); } } } diff --git a/main.cpp b/main.cpp index 8b6fee69..183ec102 100644 --- a/main.cpp +++ b/main.cpp @@ -2232,7 +2232,10 @@ std::pair read_input(std::vector &sources, char *fname, i estimated_complexity = geompos; fflush(geomfile); - pwrite(fileno(geomfile), &estimated_complexity, sizeof(estimated_complexity), 0); + if (pwrite(fileno(geomfile), &estimated_complexity, sizeof(estimated_complexity), 0) != 0) { + perror("pwrite estimated complexity"); + exit(EXIT_WRITE); + } if (fclose(geomfile) != 0) { perror("fclose geom"); diff --git a/serial.cpp b/serial.cpp index 3902f74e..bd694ebb 100644 --- a/serial.cpp +++ b/serial.cpp @@ -131,12 +131,12 @@ void deserialize_ulong_long(const char **f, unsigned long long *zigzag) { while (1) { if ((**f & 0x80) == 0) { - *zigzag |= ((const unsigned long long) **f) << shift; + *zigzag |= ((unsigned long long) **f) << shift; *f += 1; shift += 7; break; } else { - *zigzag |= ((const unsigned long long) (**f & 0x7F)) << shift; + *zigzag |= ((unsigned long long) (**f & 0x7F)) << shift; *f += 1; shift += 7; } diff --git a/shared_borders.cpp b/shared_borders.cpp index 2a1bd2ee..eec81c89 100644 --- a/shared_borders.cpp +++ b/shared_borders.cpp @@ -196,7 +196,7 @@ bool find_common_edges(std::vector &features, int z, int line_de } if (e1.first == e1.second || e2.first == e2.second) { - fprintf(stderr, "Internal error: polygon edge lookup failed for %lld,%lld to %lld,%lld or %lld,%lld to %lld,%lld\n", left[0].x, left[0].y, left[1].x, left[1].y, right[0].x, right[0].y, right[1].x, right[1].y); + fprintf(stderr, "Internal error: polygon edge lookup failed for %lld,%lld to %lld,%lld or %lld,%lld to %lld,%lld\n", (long long) left[0].x, (long long) left[0].y, (long long) left[1].x, (long long) left[1].y, (long long) right[0].x, (long long) right[0].y, (long long) right[1].x, (long long) right[1].y); exit(EXIT_IMPOSSIBLE); } diff --git a/tile.cpp b/tile.cpp index 1d407e40..7e9eb5d0 100644 --- a/tile.cpp +++ b/tile.cpp @@ -2094,7 +2094,10 @@ long long write_tile(decompressor *geoms, std::atomic *geompos_in, ch if (additional[A_TRUNCATE_ZOOMS]) { fflush(geomfile[j]->fp); - pwrite(fileno(geomfile[j]->fp), &estimated_complexity_out, sizeof(estimated_complexity_out), start_geompos[j]); + if (pwrite(fileno(geomfile[j]->fp), &estimated_complexity_out, sizeof(estimated_complexity_out), start_geompos[j]) != 0) { + perror("pwrite complexity"); + exit(EXIT_WRITE); + } } } }