From 7db3379d37b533d47025637b41bd948f8ffc7c6a Mon Sep 17 00:00:00 2001 From: abeylot Date: Mon, 19 Feb 2024 15:15:01 +0100 Subject: [PATCH] remove some pedantic warnings --- CompiledDataManager.hpp | 10 +++++----- Makefile | 2 +- compile.cpp | 16 ++++++++-------- helpers/config.hpp | 18 +++++++++--------- renumber.cpp | 18 +++++++++--------- server.cpp | 2 +- services/IdxList.cpp | 2 +- services/MapDisplay.cpp | 26 +++++++++++++------------- services/Ping.cpp | 2 +- services/RelationList.cpp | 2 +- services/Tile.cpp | 19 ++++++++++--------- services/renderers/SvgRenderer.cpp | 4 ++-- 12 files changed, 61 insertions(+), 60 deletions(-) diff --git a/CompiledDataManager.hpp b/CompiledDataManager.hpp index aab5a56..51e50f3 100644 --- a/CompiledDataManager.hpp +++ b/CompiledDataManager.hpp @@ -28,7 +28,7 @@ struct Tags unsigned char tag_size = 0; unsigned char value_size = 0; - + tag_size = (unsigned char) data[used]; used++; tag = data + used; @@ -165,7 +165,7 @@ public : std::map* symbols; std::map* charconvs; //std::map* patterns; - + std::string path; CompiledDataManager(std::string name,std::vector* conf, std::map* symbs = NULL, std::map* convs = NULL) @@ -183,7 +183,7 @@ public : relMembers= new fidx::FileRawData((name + "/relMembers").c_str(),false); baliseTags = new fidx::FileRawVarData((name + "/baliseTags").c_str(),false); - + textIndexNode = new fidx::FileIndex ((name + "/textIndexNode" ).c_str(), false); textIndexWay = new fidx::FileIndex ((name + "/textIndexWay" ).c_str(), false); @@ -216,7 +216,7 @@ public : //Relation* loadRelation(uint64_t id); Relation* loadRelationFast(uint64_t id); Relation* loadRelation(uint64_t id, short recurs = 2, bool fast = false); - + inline void load(Relation*& r, uint64_t id, bool fast) { @@ -228,7 +228,7 @@ public : w = loadWay(id, fast); } - inline void load(Point*& p, uint64_t id, bool fast) + inline void load(Point*& p, uint64_t id, [[maybe_unused]] bool fast) { p = loadPoint(id); } diff --git a/Makefile b/Makefile index 8510dac..d0e96ba 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ GIT_VERSION = "$(shell git describe --tags)" CC= g++ -cc=$(CC) -O2 -g -Wall -std=c++17 -D_FILE_OFFSET_BITS=64 -DVERSION=\"$(GIT_VERSION)\" +cc=$(CC) -O2 -g -Wall -Wextra -pedantic-errors -std=c++17 -D_FILE_OFFSET_BITS=64 -DVERSION=\"$(GIT_VERSION)\" #cc=$(CC) -g -Wall -std=c++17 -D_FILE_OFFSET_BITS=64 -DVERSION=\"$(GIT_VERSION)\" diff --git a/compile.cpp b/compile.cpp index ce57c7a..5a81746 100644 --- a/compile.cpp +++ b/compile.cpp @@ -120,8 +120,8 @@ struct shp_file struct ShpVisitor { std::vector shpFiles; - void log(uint64_t done){}; - void startTag(std::vector& tagStack, SeqBalise* b) + void log([[maybe_unused]] uint64_t done){}; + void startTag([[maybe_unused]] std::vector& tagStack, SeqBalise* b) { if (b->baliseName == "shp_file") { @@ -129,11 +129,11 @@ struct ShpVisitor } } - void endTag(std::vector& tagStack, SeqBalise* b) + void endTag([[maybe_unused]] std::vector& tagStack, [[maybe_unused]] SeqBalise* b) { } - void stringNode(const std::vector& tagStack, std::string& s) + void stringNode([[maybe_unused]] const std::vector& tagStack,[[maybe_unused]] std::string& s) { } }; @@ -202,7 +202,7 @@ struct XmlVisitor uint64_t wayid; uint64_t nodid; - bool isRel = false;; + bool isRel = false; bool isWay = false; bool isNod = false; @@ -266,11 +266,11 @@ struct XmlVisitor std::cerr << " done " << (done >> UINT64_C(20)) << "Mio.\t relations " << relationIndex->itemCount << "\tways " << wayIndex->itemCount << "\tnodes " << nodeIndex->itemCount<< "\n" << std::flush; } - void stringNode(const std::vector& tagStack, std::string& s) + void stringNode([[maybe_unused]] const std::vector& tagStack, [[maybe_unused]] std::string& s) { } - void startTag(const std::vector& tagStack, SeqBalise* b) + void startTag([[maybe_unused]] const std::vector& tagStack, SeqBalise* b) { if ((b->baliseName == BALISENAME_TAG)&&(isNod || isWay || isRel)) { @@ -371,7 +371,7 @@ struct XmlVisitor } } - void endTag(const std::vector& tagStack, SeqBalise* b) + void endTag([[maybe_unused]] const std::vector& tagStack, SeqBalise* b) { if (b->baliseName == BALISENAME_TAG) { diff --git a/helpers/config.hpp b/helpers/config.hpp index 7df1d6d..bf0fc25 100644 --- a/helpers/config.hpp +++ b/helpers/config.hpp @@ -45,7 +45,7 @@ struct CssClass } return result; } - std::string makeClass(std::string clName, double ppm, bool evenOdd) + std::string makeClass(std::string clName, double ppm) { std::string result = ""; //std::string result = "/*" + tagValue + "*/\n"; @@ -120,8 +120,8 @@ struct IndexDesc struct ParmsXmlVisitor { std::map parameters; - void log(uint64_t done){}; - void startTag(std::vector& tagStack, SeqBalise* b) + void log([[maybe_unused]] uint64_t done){}; + void startTag([[maybe_unused]] std::vector& tagStack, SeqBalise* b) { if (b->baliseName == "parameter") { @@ -129,11 +129,11 @@ struct ParmsXmlVisitor } } - void endTag(std::vector& tagStack, SeqBalise* b) + void endTag([[maybe_unused]] std::vector& tagStack, [[maybe_unused]] SeqBalise* b) { } - void stringNode(std::vector& tagStack, std::string& s) + void stringNode([[maybe_unused]] std::vector& tagStack, [[maybe_unused]] std::string& s) { } @@ -197,11 +197,11 @@ struct XmlVisitor ~XmlVisitor() { } - void log(uint64_t done) + void log([[maybe_unused]] uint64_t done) { } - void startTag(std::vector& tagStack, SeqBalise* b) + void startTag([[maybe_unused]]std::vector& tagStack, SeqBalise* b) { if (b->baliseName == "style") { @@ -323,7 +323,7 @@ struct XmlVisitor } } - void endTag(std::vector& tagStack, SeqBalise* b) + void endTag([[maybe_unused]] std::vector& tagStack, SeqBalise* b) { if ( symbolId != "") { @@ -360,7 +360,7 @@ struct XmlVisitor } } - void stringNode(std::vector& tagStack, std::string& s) + void stringNode([[maybe_unused]] std::vector& tagStack, std::string& s) { if(symbolId != "") { diff --git a/renumber.cpp b/renumber.cpp index e6c297b..75da78b 100644 --- a/renumber.cpp +++ b/renumber.cpp @@ -52,13 +52,13 @@ struct XmlVisitor { std::cerr << " done " << (done >> UINT64_C(20)) << "Mio.\t relations " << relid << "\tways " << wayid << "\tnodes " << nodid<< "\n" << std::flush; } - void startTag(const std::vector& tagStack, SeqBalise* b) + void startTag([[maybe_unused]] const std::vector& tagStack, [[maybe_unused]] SeqBalise* b) { } - void stringNode(const std::vector& tagStack, std::string& s) + void stringNode([[maybe_unused]] const std::vector& tagStack, [[maybe_unused]] std::string& s) { } - void endTag(const std::vector& tagStack, SeqBalise* b) + void endTag([[maybe_unused]] const std::vector& tagStack, SeqBalise* b) { if (b->baliseName == BALISENAME_RELATION) { @@ -72,23 +72,23 @@ struct XmlVisitor wayIdIndex->append(atoll((b->keyValues["id"]).c_str()), wayid++); tags=0; } - + else if (b->baliseName == BALISENAME_TAG) { tags++;; } - + else if (b->baliseName == BALISENAME_NODE) { if(tags) { - nodeIdIndex->append(atoll((b->keyValues["id"]).c_str()), - (GeoPointNumberIndex){ nodid++, Coordinates::toNormalizedLon(b->keyValues["lon"]), Coordinates::toNormalizedLat(b->keyValues["lat"])}); + GeoPointNumberIndex pt{ nodid++, Coordinates::toNormalizedLon(b->keyValues["lon"]), Coordinates::toNormalizedLat(b->keyValues["lat"])}; + nodeIdIndex->append(atoll((b->keyValues["id"]).c_str()),pt); } else { - nodeIdIndex->append(atoll((b->keyValues["id"]).c_str()), - (GeoPointNumberIndex){ 0, Coordinates::toNormalizedLon(b->keyValues["lon"]), Coordinates::toNormalizedLat(b->keyValues["lat"])}); + GeoPointNumberIndex pt{ 0, Coordinates::toNormalizedLon(b->keyValues["lon"]), Coordinates::toNormalizedLat(b->keyValues["lat"])}; + nodeIdIndex->append(atoll((b->keyValues["id"]).c_str()),pt); } tags = 0; } diff --git a/server.cpp b/server.cpp index 49bf447..1560d9d 100644 --- a/server.cpp +++ b/server.cpp @@ -24,7 +24,7 @@ ParmsXmlVisitor params; volatile bool sigstop; -void sig_handler(int sig) +void sig_handler([[maybe_unused]]int sig) { sigstop = true; } diff --git a/services/IdxList.cpp b/services/IdxList.cpp index 91b948f..2083c9c 100644 --- a/services/IdxList.cpp +++ b/services/IdxList.cpp @@ -1,5 +1,5 @@ #include "IdxList.hpp" -Msg* IdxList::processRequest(Msg* request, CompiledDataManager& mger) +Msg* IdxList::processRequest([[maybe_unused]] Msg* request, CompiledDataManager& mger) { std::string resp = " "; Msg* rep = new Msg; diff --git a/services/MapDisplay.cpp b/services/MapDisplay.cpp index cc22c68..be4c063 100644 --- a/services/MapDisplay.cpp +++ b/services/MapDisplay.cpp @@ -8,13 +8,13 @@ MapDisplay::~MapDisplay() { } -Msg* MapDisplay::processRequest(Msg* request, CompiledDataManager& mger) +Msg* MapDisplay::processRequest(Msg* request, [[maybe_unused]] CompiledDataManager& mger) { bool pin = false; std::string longitude = "-1.554136"; std::string latitude = "47.218637"; std::string zoom = "12"; - + std::string resp = "" "" @@ -42,8 +42,8 @@ Msg* MapDisplay::processRequest(Msg* request, CompiledDataManager& mger) "" "" "" - - "
" + + "
" "
" "
" - - + + "
" - + "" - "" + "" ""; - - + + if (request->getRecord(2)->getNamedValue("lattitude") != "") { latitude = request->getRecord(2)->getNamedValue("lattitude"); @@ -78,7 +78,7 @@ Msg* MapDisplay::processRequest(Msg* request, CompiledDataManager& mger) { latitude = request->getRecord(1)->getNamedValue("lattitude"); } - + if (request->getRecord(2)->getNamedValue("longitude") != "") { longitude = request->getRecord(2)->getNamedValue("longitude"); @@ -87,7 +87,7 @@ Msg* MapDisplay::processRequest(Msg* request, CompiledDataManager& mger) { longitude = request->getRecord(1)->getNamedValue("longitude"); } - + if (request->getRecord(2)->getNamedValue("zoom") != "") { zoom = request->getRecord(2)->getNamedValue("zoom"); @@ -101,7 +101,7 @@ Msg* MapDisplay::processRequest(Msg* request, CompiledDataManager& mger) { pin = true; } - + resp.replace(resp.find("#lon#"),5,longitude); resp.replace(resp.find("#lat#"),5,latitude); resp.replace(resp.find("#zoom#"),6,zoom); diff --git a/services/Ping.cpp b/services/Ping.cpp index 81ca181..1133d5e 100644 --- a/services/Ping.cpp +++ b/services/Ping.cpp @@ -1,5 +1,5 @@ #include "Ping.hpp" -Msg* Ping::processRequest(Msg* request, CompiledDataManager& mger) +Msg* Ping::processRequest([[maybe_unused]] Msg* request, [[maybe_unused]] CompiledDataManager& mger) { std::string resp = " Ping!"; Msg* rep = new Msg; diff --git a/services/RelationList.cpp b/services/RelationList.cpp index 33974f7..a2b8c3c 100644 --- a/services/RelationList.cpp +++ b/services/RelationList.cpp @@ -3,7 +3,7 @@ #include "../common/constants.hpp" #include -Msg* RelationList::processRequest(Msg* request, CompiledDataManager& mger) +Msg* RelationList::processRequest([[maybe_unused]] Msg* request, CompiledDataManager& mger) { //GeoBox geoBox; // DataManager mger; diff --git a/services/Tile.cpp b/services/Tile.cpp index 77eaeb3..0b6eafb 100644 --- a/services/Tile.cpp +++ b/services/Tile.cpp @@ -42,15 +42,15 @@ int def(std::string& source, FILE* dest) { strm.avail_in = CHUNK; memcpy(in, source.c_str() + pos, CHUNK); - pos += CHUNK; + pos += CHUNK; } else { strm.avail_in = length - pos; memcpy(in, source.c_str() + pos, length - pos); pos = length; - do_stop = true; - } + do_stop = true; + } /*if (ferror(source)) { (void)deflateEnd(&strm); return Z_ERRNO; @@ -116,15 +116,15 @@ int def(std::string& source, std::string& dest) { strm.avail_in = CHUNK; memcpy(in, source.c_str() + pos, CHUNK); - pos += CHUNK; + pos += CHUNK; } else { strm.avail_in = length - pos; memcpy(in, source.c_str() + pos, length - pos); pos = length; - do_stop = true; - } + do_stop = true; + } flush = do_stop ? Z_FINISH : Z_NO_FLUSH; strm.next_in = in; @@ -197,6 +197,7 @@ int inf(FILE *source, std::string& dest) switch (ret) { case Z_NEED_DICT: ret = Z_DATA_ERROR; /* and fall through */ + [[fallthrough]]; case Z_DATA_ERROR: case Z_MEM_ERROR: (void)inflateEnd(&strm); @@ -230,7 +231,7 @@ double tiley2lat(int y, int z) return 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n))); } -Msg* Tile::processRequest(Msg* request, CompiledDataManager& mger) +Msg* Tile::processRequest([[maybe_unused]] Msg* request, CompiledDataManager& mger) { char filename[250]; @@ -288,14 +289,14 @@ Msg* Tile::processRequest(Msg* request, CompiledDataManager& mger) res.append(buffer, len); } } - + } if(filefound) { //printf("USING CACHE !\n"); fclose(in); encoder.addContent(rep,res); - }else{ + }else{ std::string dir1 = mger.path + "/cache/" + std::to_string(_z); std::string dir2 = dir1 + "/" + std::to_string(_x); diff --git a/services/renderers/SvgRenderer.cpp b/services/renderers/SvgRenderer.cpp index dfd1e6c..290127c 100644 --- a/services/renderers/SvgRenderer.cpp +++ b/services/renderers/SvgRenderer.cpp @@ -544,7 +544,7 @@ std::string SvgRenderer::renderItems(Rectangle rect, uint32_t sizex, uint32_t si { if( cssClasses.find("c"+std::to_string(cl->rank)) != cssClasses.end() ) { - std::string style = cl->makeClass("c" + std::to_string(cl->rank), ppm, (idxDesc->type == "relation")); + std::string style = cl->makeClass("c" + std::to_string(cl->rank), ppm); if(style.find("url(#"+pattern.first) != std::string::npos) { found = true; @@ -572,7 +572,7 @@ std::string SvgRenderer::renderItems(Rectangle rect, uint32_t sizex, uint32_t si { if( cssClasses.find("c"+std::to_string(cl->rank)) != cssClasses.end() ) { - result << cl->makeClass("c" + std::to_string(cl->rank), ppm, (idxDesc->type == "relation")); + result << cl->makeClass("c" + std::to_string(cl->rank), ppm); } } }