Fixes various compiler diagnostics

Found with LLVM 3.9.1 and then fixed the most severe categories.
This commit is contained in:
Daniel J. Hofmann 2017-01-06 13:21:54 +01:00 committed by Daniel J. H
parent b5d5f309a3
commit 1153b78c06
12 changed files with 19 additions and 24 deletions

View File

@ -68,7 +68,7 @@ struct TileParameters final
const auto valid_z = z < 20 && z >= 12;
return valid_x && valid_y && valid_z;
};
}
};
}
}

View File

@ -396,7 +396,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
auto trace_distance = 0.0;
matching.nodes.reserve(reconstructed_indices.size());
matching.indices.reserve(reconstructed_indices.size());
for (const auto idx : reconstructed_indices)
for (const auto &idx : reconstructed_indices)
{
const auto timestamp_index = idx.first;
const auto location_index = idx.second;

View File

@ -145,7 +145,7 @@ class FileReader
result.push_back(thisline);
}
}
catch (const std::ios_base::failure &e)
catch (const std::ios_base::failure &)
{
// EOF is OK here, everything else, re-throw
if (!input_stream.eof())

View File

@ -5,11 +5,11 @@
// Helper macros, don't use these ones
// STRIP the OSRM_PROJECT_DIR from the front of a filename. Expected to come
// from CMake's CURRENT_SOURCE_DIR, which doesn't have a trailing /, hence the +1
#define _PROJECT_RELATIVE_PATH(x) std::string(x).substr(strlen(OSRM_PROJECT_DIR) + 1)
#define PROJECT_RELATIVE_PATH_(x) std::string(x).substr(strlen(OSRM_PROJECT_DIR) + 1)
// Return the path of a file, relative to the OSRM_PROJECT_DIR
#define _OSRM_SOURCE_FILE _PROJECT_RELATIVE_PATH(__FILE__)
#define OSRM_SOURCE_FILE_ PROJECT_RELATIVE_PATH_(__FILE__)
// This is the macro to use
#define SOURCE_REF std::string(" (at ") + _OSRM_SOURCE_FILE + ":" + std::to_string(__LINE__) + ")"
#define SOURCE_REF std::string(" (at ") + OSRM_SOURCE_FILE_ + ":" + std::to_string(__LINE__) + ")"
#endif // SOURCE_MACROS_HPP

View File

@ -47,7 +47,7 @@ class GeojsonLogger
// cannot lock, is tooling for locked function
static void output(bool first, const util::json::Array &array)
{
for (const auto object : array.values)
for (const auto &object : array.values)
{
if (!first)
ofs << ",\n\t\t";

View File

@ -906,7 +906,7 @@ EdgeID Contractor::LoadEdgeExpandedGraph(
auto speed_iter =
find(segment_speed_lookup,
SegmentSpeedSource{
previous_osm_node_id, segmentblocks[i].this_osm_node_id, {0, 0}});
{previous_osm_node_id, segmentblocks[i].this_osm_node_id}, {0, 0}});
if (speed_iter != segment_speed_lookup.end())
{
if (speed_iter->speed_source.speed > 0)
@ -947,10 +947,10 @@ EdgeID Contractor::LoadEdgeExpandedGraph(
continue;
}
auto turn_iter =
find(turn_penalty_lookup,
TurnPenaltySource{
penaltyblock->from_id, penaltyblock->via_id, penaltyblock->to_id, {0, 0}});
auto turn_iter = find(
turn_penalty_lookup,
TurnPenaltySource{
{penaltyblock->from_id, penaltyblock->via_id, penaltyblock->to_id}, {0, 0}});
if (turn_iter != turn_penalty_lookup.end())
{
int new_turn_weight = static_cast<int>(turn_iter->penalty_source.penalty * 10);

View File

@ -1,6 +1,3 @@
#ifndef ENGINE_GUIDANCE_ASSEMBLE_OVERVIEW_HPP
#define ENGINE_GUIDANCE_ASSEMBLE_OVERVIEW_HPP
#include "engine/douglas_peucker.hpp"
#include "engine/guidance/leg_geometry.hpp"
#include "util/viewport.hpp"
@ -30,7 +27,7 @@ unsigned calculateOverviewZoomLevel(const std::vector<LegGeometry> &leg_geometri
for (const auto &leg_geometry : leg_geometries)
{
for (const auto coord : leg_geometry.locations)
for (const auto &coord : leg_geometry.locations)
{
south_west.lon = std::min(south_west.lon, coord.lon);
south_west.lat = std::min(south_west.lat, coord.lat);
@ -96,5 +93,3 @@ std::vector<util::Coordinate> assembleOverview(const std::vector<LegGeometry> &l
} // namespace guidance
} // namespace engine
} // namespace osrm
#endif

View File

@ -32,7 +32,7 @@ classifyIntersection(Intersection intersection)
DiscreteBearing last_discrete_bearing = util::guidance::BearingClass::getDiscreteBearing(
std::round(intersection.back().bearing));
for (const auto road : intersection)
for (const auto &road : intersection)
{
const DiscreteBearing discrete_bearing =
util::guidance::BearingClass::getDiscreteBearing(std::round(road.bearing));

View File

@ -106,7 +106,7 @@ LaneDataVector laneDataFromDescription(TurnLaneDescription turn_lane_description
// transform the map into the lane data vector
LaneDataVector lane_data;
lane_data.reserve(lane_map.size());
for (const auto tag : lane_map)
for (const auto &tag : lane_map)
lane_data.push_back({tag.first, tag.second.first, tag.second.second, false});
std::sort(lane_data.begin(), lane_data.end());

View File

@ -55,7 +55,7 @@ boost::optional<ParameterT> parseParameters(std::string::iterator &iter,
// iterator to the failing position. Extract the position from the exception ourselves.
iter = failure.first;
}
catch (const boost::numeric::bad_numeric_cast &e)
catch (const boost::numeric::bad_numeric_cast &)
{
// this can happen if we get bad numeric values in the request, just handle
// as normal parser error

View File

@ -102,7 +102,7 @@ Storage::ReturnCode Storage::Run(int max_wait)
}
}
// hard unlock in case of any exception.
catch (boost::interprocess::lock_exception &ex)
catch (boost::interprocess::lock_exception &)
{
barriers.current_region_mutex.unlock_upgradable();
// make sure we exit here because this is bad

View File

@ -6,7 +6,7 @@
namespace
{
// We hard-abort on assertion violations.
void assertion_failed_msg_helper(
[[noreturn]] void assertion_failed_msg_helper(
char const *expr, char const *msg, char const *function, char const *file, long line)
{
std::cerr << "[assert] " << file << ":" << line << "\nin: " << function << ": " << expr << "\n"