From 10cb83579feb53e7524ec899c0bff19161877669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 23 Oct 2014 02:46:15 -0700 Subject: gcc fixes --- common.gypi | 8 +++++++- common/glfw_view.cpp | 4 ++-- common/http_request_baton_curl.cpp | 10 +++++----- include/mbgl/geometry/buffer.hpp | 6 +++--- include/mbgl/util/pbf.hpp | 4 ++-- include/mbgl/util/transition.hpp | 8 ++++---- src/clipper/clipper.cpp | 2 ++ src/geometry/debug_font_buffer.cpp | 6 +++--- src/map/raster_tile_data.cpp | 4 ++-- src/map/tile.cpp | 16 ++++++++-------- src/map/transform_state.cpp | 4 ++-- src/map/vector_tile_data.cpp | 4 ++-- src/renderer/painter.cpp | 8 ++++---- src/storage/file_source.cpp | 26 +++++++++++++------------- src/storage/http_request.cpp | 4 ++-- src/storage/response.cpp | 2 +- src/style/style.cpp | 1 + src/style/style_parser.cpp | 2 ++ src/util/image.cpp | 1 + src/util/raster.cpp | 2 -- test/fixtures/fixture_log.cpp | 12 ++++++------ 21 files changed, 72 insertions(+), 62 deletions(-) diff --git a/common.gypi b/common.gypi index 596db5449d..627c186689 100644 --- a/common.gypi +++ b/common.gypi @@ -14,8 +14,14 @@ 'GCC_WARN_UNINITIALIZED_AUTOS': 'YES_AGGRESSIVE', }, }], + ['OS=="linux"', { + 'cflags_cc': [ + '-Wno-unknown-pragmas', # We are using '#pragma mark', but it is only available on Darwin. + '-Wno-literal-suffix', # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61653 + ], + }], ], - 'cflags_cc!': [ '-std=c++11', '-Wall', '-Wextra', '-Wshadow', '-frtti', '-fexceptions' ], + 'cflags_cc': [ '-std=c++11', '-Werror', '-Wall', '-Wextra', '-Wshadow', '-frtti', '-fexceptions' ], 'configurations': { 'Debug': { 'cflags_cc': [ '-g', '-O0', '-fno-omit-frame-pointer','-fwrapv', '-fstack-protector-all', '-fno-common' ], diff --git a/common/glfw_view.cpp b/common/glfw_view.cpp index 53cd068d09..92d1e19085 100644 --- a/common/glfw_view.cpp +++ b/common/glfw_view.cpp @@ -13,8 +13,8 @@ GLFWView::~GLFWView() { glfwTerminate(); } -void GLFWView::initialize(mbgl::Map *map) { - View::initialize(map); +void GLFWView::initialize(mbgl::Map *map_) { + View::initialize(map_); if (!glfwInit()) { fprintf(stderr, "Failed to initialize glfw\n"); diff --git a/common/http_request_baton_curl.cpp b/common/http_request_baton_curl.cpp index b5226e20ec..0c3d2b43fc 100644 --- a/common/http_request_baton_curl.cpp +++ b/common/http_request_baton_curl.cpp @@ -154,11 +154,11 @@ void curl_perform(uv_poll_t *req, int, int events) { while ((message = curl_multi_info_read(multi, &pending))) { switch (message->msg) { case CURLMSG_DONE: { - CURLContext *context = nullptr; - curl_easy_getinfo(message->easy_handle, CURLINFO_PRIVATE, (char *)&context); + CURLContext *ctx = nullptr; + curl_easy_getinfo(message->easy_handle, CURLINFO_PRIVATE, (char *)&ctx); // Make a copy so that the Baton stays around even after we are calling finish_request - util::ptr baton = context->baton; + util::ptr baton = ctx->baton; // Add human-readable error code if (message->data.result != CURLE_OK) { @@ -242,8 +242,8 @@ int handle_socket(CURL *handle, curl_socket_t sockfd, int action, void *, void * } if (action == CURL_POLL_REMOVE && socketp) { uv_poll_stop(context->poll_handle); - uv_close((uv_handle_t *)context->poll_handle, [](uv_handle_t *handle) { - delete (uv_poll_t *)handle; + uv_close((uv_handle_t *)context->poll_handle, [](uv_handle_t *poll_handle) { + delete (uv_poll_t *)poll_handle; }); context->poll_handle = nullptr; curl_multi_assign(multi, sockfd, NULL); diff --git a/include/mbgl/geometry/buffer.hpp b/include/mbgl/geometry/buffer.hpp index 446177d443..80cc6b9d1a 100644 --- a/include/mbgl/geometry/buffer.hpp +++ b/include/mbgl/geometry/buffer.hpp @@ -84,15 +84,15 @@ protected: } // Get a pointer to the item at a given index. - inline void *getElement(size_t index) { + inline void *getElement(size_t i) { if (array == nullptr) { throw std::runtime_error("Buffer was already deleted or doesn't contain elements"); } - if (index * itemSize >= pos) { + if (i * itemSize >= pos) { throw new std::runtime_error("Can't get element after array bounds"); } else { - return static_cast(array) + (index * itemSize); + return static_cast(array) + (i * itemSize); } } diff --git a/include/mbgl/util/pbf.hpp b/include/mbgl/util/pbf.hpp index ab4d60cd37..d017219a52 100644 --- a/include/mbgl/util/pbf.hpp +++ b/include/mbgl/util/pbf.hpp @@ -132,9 +132,9 @@ double pbf::float64() { std::string pbf::string() { uint32_t bytes = static_cast(varint()); - const char *string = reinterpret_cast(data); + const char *string_data = reinterpret_cast(data); skipBytes(bytes); - return std::string(string, bytes); + return std::string(string_data, bytes); } bool pbf::boolean() { diff --git a/include/mbgl/util/transition.hpp b/include/mbgl/util/transition.hpp index 16adc41ceb..b78abfa8fd 100644 --- a/include/mbgl/util/transition.hpp +++ b/include/mbgl/util/transition.hpp @@ -36,8 +36,8 @@ protected: template class ease_transition : public transition { public: - ease_transition(T from_, T to_, T& value_, timestamp start, timestamp duration) - : transition(start, duration), + ease_transition(T from_, T to_, T& value_, timestamp start_, timestamp duration_) + : transition(start_, duration_), from(from_), to(to_), value(value_) {} @@ -53,8 +53,8 @@ private: template class timeout : public transition { public: - timeout(T final_value_, T& value_, timestamp start, timestamp duration) - : transition(start, duration), + timeout(T final_value_, T& value_, timestamp start_, timestamp duration_) + : transition(start_, duration_), final_value(final_value_), value(value_) {} diff --git a/src/clipper/clipper.cpp b/src/clipper/clipper.cpp index 7571ae1439..ea468d69e4 100755 --- a/src/clipper/clipper.cpp +++ b/src/clipper/clipper.cpp @@ -48,6 +48,8 @@ #include #include +#pragma GCC diagnostic ignored "-Wshadow" + namespace ClipperLib { #ifdef use_int32 diff --git a/src/geometry/debug_font_buffer.cpp b/src/geometry/debug_font_buffer.cpp index 387a646299..2a0924a1c4 100644 --- a/src/geometry/debug_font_buffer.cpp +++ b/src/geometry/debug_font_buffer.cpp @@ -10,9 +10,9 @@ using namespace mbgl; void DebugFontBuffer::addText(const char *text, double left, double baseline, double scale) { uint16_t *coords = nullptr; - size_t length = strlen(text); - for (size_t i = 0; i < length; ++i) { - if (text[i] < 32 || text[i] > 127) { + const size_t len = strlen(text); + for (size_t i = 0; i < len; ++i) { + if (text[i] < 32 || (unsigned char)(text[i]) > 127) { continue; } diff --git a/src/map/raster_tile_data.cpp b/src/map/raster_tile_data.cpp index e7725b7abd..99ca327fe7 100644 --- a/src/map/raster_tile_data.cpp +++ b/src/map/raster_tile_data.cpp @@ -5,8 +5,8 @@ using namespace mbgl; -RasterTileData::RasterTileData(Tile::ID id, Map &map, const util::ptr &source) - : TileData(id, map, source), +RasterTileData::RasterTileData(Tile::ID id_, Map &map_, const util::ptr &source_) + : TileData(id_, map_, source_), bucket(map.getTexturepool(), properties) { } diff --git a/src/map/tile.cpp b/src/map/tile.cpp index 1fe0faefde..3070d3fd96 100644 --- a/src/map/tile.cpp +++ b/src/map/tile.cpp @@ -25,13 +25,13 @@ std::forward_list Tile::ID::children(int32_t child_z) const { assert(child_z > z); int32_t factor = std::pow(2, child_z - z); - std::forward_list children; + std::forward_list child_ids; for (int32_t ty = y * factor, y_max = (y + 1) * factor; ty < y_max; ++ty) { for (int32_t tx = x * factor, x_max = (x + 1) * factor; tx < x_max; ++tx) { - children.emplace_front(child_z, tx, ty); + child_ids.emplace_front(child_z, tx, ty); } } - return children; + return child_ids; } Tile::ID Tile::ID::normalized() const { @@ -42,13 +42,13 @@ Tile::ID Tile::ID::normalized() const { return ID { z, nx, ny }; } -bool Tile::ID::isChildOf(const Tile::ID &parent) const { - if (parent.z >= z || parent.w != w) { +bool Tile::ID::isChildOf(const Tile::ID &parent_id) const { + if (parent_id.z >= z || parent_id.w != w) { return false; } - int32_t scale = std::pow(2, z - parent.z); - return parent.x == ((x < 0 ? x - scale + 1 : x) / scale) && - parent.y == y / scale; + int32_t scale = std::pow(2, z - parent_id.z); + return parent_id.x == ((x < 0 ? x - scale + 1 : x) / scale) && + parent_id.y == y / scale; } diff --git a/src/map/transform_state.cpp b/src/map/transform_state.cpp index fa521400c3..0a858bce6a 100644 --- a/src/map/transform_state.cpp +++ b/src/map/transform_state.cpp @@ -96,8 +96,8 @@ float TransformState::lngX(float lon) const { } float TransformState::latY(float lat) const { - float latY = 180 / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360)); - return (180 - latY) * worldSize() / 360; + float lat_y = 180 / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360)); + return (180 - lat_y) * worldSize() / 360; } std::array TransformState::locationCoordinate(float lon, float lat) const { diff --git a/src/map/vector_tile_data.cpp b/src/map/vector_tile_data.cpp index 48b46059a5..b94bc66dea 100644 --- a/src/map/vector_tile_data.cpp +++ b/src/map/vector_tile_data.cpp @@ -8,8 +8,8 @@ using namespace mbgl; -VectorTileData::VectorTileData(Tile::ID id, Map &map, const util::ptr &source) - : TileData(id, map, source), +VectorTileData::VectorTileData(Tile::ID id_, Map &map_, const util::ptr &source_) + : TileData(id_, map_, source_), depth(id.z >= source->max_zoom ? map.getMaxZoom() - id.z : 1) { } diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index aa522734c5..38c2176aed 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -128,10 +128,10 @@ void Painter::useProgram(uint32_t program) { } } -void Painter::lineWidth(float lineWidth) { - if (gl_lineWidth != lineWidth) { - glLineWidth(lineWidth); - gl_lineWidth = lineWidth; +void Painter::lineWidth(float line_width) { + if (gl_lineWidth != line_width) { + glLineWidth(line_width); + gl_lineWidth = line_width; } } diff --git a/src/storage/file_source.cpp b/src/storage/file_source.cpp index 12d924416c..70b4abe4c7 100644 --- a/src/storage/file_source.cpp +++ b/src/storage/file_source.cpp @@ -27,12 +27,12 @@ FileSource::~FileSource() { // NOTE: We don't need to delete the messenger since it will be deleted by the // uv_messenger_stop() function. - util::ptr request; + util::ptr req; // Send a cancel() message to all requests that we are still holding. for (const std::pair> &pair : pending) { - if ((request = pair.second.lock())) { - request->cancel(); + if ((req = pair.second.lock())) { + req->cancel(); } } } @@ -61,25 +61,25 @@ std::unique_ptr FileSource::request(ResourceType type, const std::strin } }(); - util::ptr request; + util::ptr req; // First, try to find an existing Request object. auto it = pending.find(absoluteURL); if (it != pending.end()) { - request = it->second.lock(); + req = it->second.lock(); } - if (!request) { + if (!req) { if (absoluteURL.substr(0, 7) == "file://") { - request = std::make_shared(absoluteURL.substr(7), loop); + req = std::make_shared(absoluteURL.substr(7), loop); } else { - request = std::make_shared(type, absoluteURL, loop, store); + req = std::make_shared(type, absoluteURL, loop, store); } - pending.emplace(absoluteURL, request); + pending.emplace(absoluteURL, req); } - return std::unique_ptr(new Request(request)); + return std::unique_ptr(new Request(req)); } void FileSource::prepare(std::function fn) { @@ -93,10 +93,10 @@ void FileSource::prepare(std::function fn) { void FileSource::retryAllPending() { assert(thread_id == uv_thread_self()); - util::ptr request; + util::ptr req; for (const std::pair> &pair : pending) { - if ((request = pair.second.lock())) { - request->retryImmediately(); + if ((req = pair.second.lock())) { + req->retryImmediately(); } } diff --git a/src/storage/http_request.cpp b/src/storage/http_request.cpp index 3da4fc7c31..46b1d5e194 100644 --- a/src/storage/http_request.cpp +++ b/src/storage/http_request.cpp @@ -20,8 +20,8 @@ struct CacheRequestBaton { util::ptr store; }; -HTTPRequest::HTTPRequest(ResourceType type_, const std::string &path, uv_loop_t *loop_, util::ptr store_) - : BaseRequest(path), thread_id(uv_thread_self()), loop(loop_), store(store_), type(type_) { +HTTPRequest::HTTPRequest(ResourceType type_, const std::string &path_, uv_loop_t *loop_, util::ptr store_) + : BaseRequest(path_), thread_id(uv_thread_self()), loop(loop_), store(store_), type(type_) { if (store) { startCacheRequest(); } else { diff --git a/src/storage/response.cpp b/src/storage/response.cpp index cdaf33e4e4..f1e1c35874 100644 --- a/src/storage/response.cpp +++ b/src/storage/response.cpp @@ -9,7 +9,7 @@ int64_t Response::parseCacheControl(const char *value) { uint64_t seconds = 0; // TODO: cache-control may contain other information as well: // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 - if (std::sscanf(value, "max-age=%llu", &seconds) == 1) { + if (std::sscanf(value, "max-age=%lu", &seconds) == 1) { return std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch()).count() + seconds; diff --git a/src/style/style.cpp b/src/style/style.cpp index 6f0a0e3b28..aa5b150882 100644 --- a/src/style/style.cpp +++ b/src/style/style.cpp @@ -12,6 +12,7 @@ #include +#include namespace mbgl { diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index b2714f5da5..47ff0c30ab 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -6,6 +6,8 @@ #include #include +#include + namespace mbgl { using JSVal = const rapidjson::Value&; diff --git a/src/util/image.cpp b/src/util/image.cpp index ec218e0bed..fd0d34de2d 100644 --- a/src/util/image.cpp +++ b/src/util/image.cpp @@ -1,4 +1,5 @@ #include + #include #include diff --git a/src/util/raster.cpp b/src/util/raster.cpp index c4d7a15400..76cd411223 100644 --- a/src/util/raster.cpp +++ b/src/util/raster.cpp @@ -6,8 +6,6 @@ #include #include -#include - #include #include diff --git a/test/fixtures/fixture_log.cpp b/test/fixtures/fixture_log.cpp index c2c10fc9eb..1b1646e665 100644 --- a/test/fixtures/fixture_log.cpp +++ b/test/fixtures/fixture_log.cpp @@ -9,25 +9,25 @@ FixtureLogBackend::~FixtureLogBackend() { } size_t FixtureLogBackend::count(const LogMessage &message) const { - size_t count = 0; + size_t message_count = 0; for (const LogMessage &msg : messages) { if (msg == message) { - count++; + message_count++; msg.checked = true; } } - return count; + return message_count; } std::vector FixtureLogBackend::unchecked() const { - std::vector unchecked; + std::vector unchecked_messages; for (const LogMessage &msg : messages) { if (!msg.checked) { - unchecked.push_back(msg); + unchecked_messages.push_back(msg); msg.checked = true; } } - return unchecked; + return unchecked_messages; } ::std::ostream& operator<<(::std::ostream& os, const std::vector& messages) { -- cgit v1.2.1