From 64720c2d2ee693d7a5f012b7ba9a7fb2b4f9121e Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Wed, 16 Apr 2014 16:59:40 +0200 Subject: [PATCH] several lints fixed that were detected by facebook's flint --- Contractor/EdgeBasedGraphFactory.cpp | 4 ++-- DataStructures/BinaryHeap.h | 8 ++++---- DataStructures/ConcurrentQueue.h | 2 +- DataStructures/DeallocatingVector.h | 4 ++-- DataStructures/DynamicGraph.h | 2 +- DataStructures/HashTable.h | 2 +- DataStructures/ImportEdge.h | 2 +- DataStructures/LRUCache.h | 2 +- DataStructures/Percent.h | 2 +- DataStructures/QueryNode.h | 6 +++--- DataStructures/Restriction.h | 7 +++---- DataStructures/SearchEngine.h | 2 +- DataStructures/SearchEngineData.h | 2 +- DataStructures/SharedMemoryVectorWrapper.h | 2 +- DataStructures/StaticKDTree.h | 4 ++-- DataStructures/XORFastHashStorage.h | 2 +- Extractor/ExtractorCallbacks.cpp | 3 ++- Extractor/ScriptingEnvironment.h | 2 +- Plugins/BasePlugin.h | 4 ++++ Plugins/NearestPlugin.h | 2 +- Plugins/TimestampPlugin.h | 2 +- Plugins/ViaRoutePlugin.h | 2 +- Server/DataStructures/InternalDataFacade.h | 2 +- Server/Server.h | 3 ++- 24 files changed, 39 insertions(+), 34 deletions(-) diff --git a/Contractor/EdgeBasedGraphFactory.cpp b/Contractor/EdgeBasedGraphFactory.cpp index e765c90b4..fef577840 100644 --- a/Contractor/EdgeBasedGraphFactory.cpp +++ b/Contractor/EdgeBasedGraphFactory.cpp @@ -47,11 +47,11 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory( std::vector & barrier_node_list, std::vector & traffic_light_node_list, std::vector & input_restrictions_list, - std::vector & m_node_info_list, + std::vector & node_info_list, SpeedProfileProperties speed_profile ) : speed_profile(speed_profile), m_turn_restrictions_count(0), - m_node_info_list(m_node_info_list) + m_node_info_list(node_info_list) { BOOST_FOREACH(const TurnRestriction & restriction, input_restrictions_list) { std::pair restriction_source = diff --git a/DataStructures/BinaryHeap.h b/DataStructures/BinaryHeap.h index 7cd17f66f..9edd600e3 100644 --- a/DataStructures/BinaryHeap.h +++ b/DataStructures/BinaryHeap.h @@ -43,7 +43,7 @@ template< typename NodeID, typename Key > class ArrayStorage { public: - ArrayStorage( size_t size ) : positions( new Key[size] ) { + explicit ArrayStorage( size_t size ) : positions( new Key[size] ) { memset(positions, 0, size*sizeof(Key)); } @@ -65,7 +65,7 @@ template< typename NodeID, typename Key > class MapStorage { public: - MapStorage( size_t ) {} + explicit MapStorage( size_t ) {} Key &operator[]( NodeID node ) { return nodes[node]; @@ -87,7 +87,7 @@ class UnorderedMapStorage { typedef typename UnorderedMapType::const_iterator UnorderedMapConstIterator; public: - UnorderedMapStorage( size_t ) { + explicit UnorderedMapStorage( size_t ) { //hash table gets 1000 Buckets nodes.rehash(1000); } @@ -119,7 +119,7 @@ public: typedef Weight WeightType; typedef Data DataType; - BinaryHeap( size_t maxID ) + explicit BinaryHeap( size_t maxID ) : nodeIndex( maxID ) { diff --git a/DataStructures/ConcurrentQueue.h b/DataStructures/ConcurrentQueue.h index ea52ef864..bc610583e 100644 --- a/DataStructures/ConcurrentQueue.h +++ b/DataStructures/ConcurrentQueue.h @@ -40,7 +40,7 @@ template class ConcurrentQueue { public: - ConcurrentQueue(const size_t max_size) : m_internal_queue(max_size) { } + explicit ConcurrentQueue(const size_t max_size) : m_internal_queue(max_size) { } inline void push(const Data & data) { boost::mutex::scoped_lock lock(m_mutex); diff --git a/DataStructures/DeallocatingVector.h b/DataStructures/DeallocatingVector.h index eef6d338d..4db1ec756 100644 --- a/DataStructures/DeallocatingVector.h +++ b/DataStructures/DeallocatingVector.h @@ -96,10 +96,10 @@ public: DeallocatingVectorIterator() {} template - DeallocatingVectorIterator(const DeallocatingVectorIterator & r) : mState(r.mState) {} + explicit DeallocatingVectorIterator(const DeallocatingVectorIterator & r) : mState(r.mState) {} DeallocatingVectorIterator(std::size_t idx, std::vector & input_list) : mState(idx, input_list) {} - DeallocatingVectorIterator(const DeallocatingVectorIteratorState & r) : mState(r) {} + explicit DeallocatingVectorIterator(const DeallocatingVectorIteratorState & r) : mState(r) {} template DeallocatingVectorIterator& operator=(const DeallocatingVectorIterator &r) { diff --git a/DataStructures/DynamicGraph.h b/DataStructures/DynamicGraph.h index 1ad5cc9a2..4a1b796ed 100644 --- a/DataStructures/DynamicGraph.h +++ b/DataStructures/DynamicGraph.h @@ -57,7 +57,7 @@ class DynamicGraph { }; //Constructs an empty graph with a given number of nodes. - DynamicGraph( int32_t nodes ) : m_numNodes(nodes), m_numEdges(0) { + explicit DynamicGraph( int32_t nodes ) : m_numNodes(nodes), m_numEdges(0) { m_nodes.reserve( m_numNodes ); m_nodes.resize( m_numNodes ); diff --git a/DataStructures/HashTable.h b/DataStructures/HashTable.h index 1e9c3333c..b4984e4b5 100644 --- a/DataStructures/HashTable.h +++ b/DataStructures/HashTable.h @@ -40,7 +40,7 @@ public: HashTable() : super() { } - HashTable(const unsigned size) : super(size) { } + explicit HashTable(const unsigned size) : super(size) { } inline void Add( KeyT const & key, ValueT const & value) { super::emplace(std::make_pair(key, value)); diff --git a/DataStructures/ImportEdge.h b/DataStructures/ImportEdge.h index 23e30e2fb..33e52cc12 100644 --- a/DataStructures/ImportEdge.h +++ b/DataStructures/ImportEdge.h @@ -129,7 +129,7 @@ public: } template - EdgeBasedEdge(const EdgeT & myEdge ) : + explicit EdgeBasedEdge(const EdgeT & myEdge ) : m_source(myEdge.source), m_target(myEdge.target), m_edgeID(myEdge.data.via), diff --git a/DataStructures/LRUCache.h b/DataStructures/LRUCache.h index 8e7733171..1dbe31709 100644 --- a/DataStructures/LRUCache.h +++ b/DataStructures/LRUCache.h @@ -43,7 +43,7 @@ private: std::list itemsInCache; boost::unordered_map::iterator > positionMap; public: - LRUCache(unsigned c) : capacity(c) {} + explicit LRUCache(unsigned c) : capacity(c) {} bool Holds(KeyT key) { if(positionMap.find(key) != positionMap.end()) { diff --git a/DataStructures/Percent.h b/DataStructures/Percent.h index dc2e7d0f4..13bf728d7 100644 --- a/DataStructures/Percent.h +++ b/DataStructures/Percent.h @@ -38,7 +38,7 @@ public: * @param maxValue the value that corresponds to 100% * @param step the progress is shown in steps of 'step' percent */ - Percent(unsigned maxValue, unsigned step = 5) { + explicit Percent(unsigned maxValue, unsigned step = 5) { reinit(maxValue, step); } diff --git a/DataStructures/QueryNode.h b/DataStructures/QueryNode.h index 89dccb47a..ae0dc4bac 100644 --- a/DataStructures/QueryNode.h +++ b/DataStructures/QueryNode.h @@ -25,8 +25,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _NODE_COORDS_H -#define _NODE_COORDS_H +#ifndef QUERY_NODE_H +#define QUERY_NODE_H #include "../typedefs.h" @@ -83,4 +83,4 @@ struct NodeInfo { } }; -#endif //_NODE_COORDS_H +#endif //QUERY_NODE_H diff --git a/DataStructures/Restriction.h b/DataStructures/Restriction.h index 9f53ce3bf..429cc8acd 100644 --- a/DataStructures/Restriction.h +++ b/DataStructures/Restriction.h @@ -58,14 +58,13 @@ struct TurnRestriction { bool unused7:1; } flags; - TurnRestriction(NodeID viaNode) : + explicit TurnRestriction(NodeID viaNode) : viaNode(viaNode), fromNode(UINT_MAX), toNode(UINT_MAX) { - } - TurnRestriction(const bool isOnly = false) : + explicit TurnRestriction(const bool isOnly = false) : viaNode(UINT_MAX), fromNode(UINT_MAX), toNode(UINT_MAX) { @@ -91,7 +90,7 @@ struct InputRestrictionContainer { { restriction.viaNode = vn; } - InputRestrictionContainer( + explicit InputRestrictionContainer( bool isOnly = false ) : fromWay(UINT_MAX), diff --git a/DataStructures/SearchEngine.h b/DataStructures/SearchEngine.h index 025805cc4..f03bf93d9 100644 --- a/DataStructures/SearchEngine.h +++ b/DataStructures/SearchEngine.h @@ -54,7 +54,7 @@ public: ShortestPathRouting shortest_path; AlternativeRouting alternative_path; - SearchEngine( DataFacadeT * facade ) + explicit SearchEngine( DataFacadeT * facade ) : facade (facade), shortest_path (facade, engine_working_data), diff --git a/DataStructures/SearchEngineData.h b/DataStructures/SearchEngineData.h index 5d3e68046..dd7ac5f50 100644 --- a/DataStructures/SearchEngineData.h +++ b/DataStructures/SearchEngineData.h @@ -41,7 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. struct _HeapData { NodeID parent; - _HeapData( NodeID p ) : parent(p) { } + /* explicit */ _HeapData( NodeID p ) : parent(p) { } }; // typedef StaticGraph QueryGraph; diff --git a/DataStructures/SharedMemoryVectorWrapper.h b/DataStructures/SharedMemoryVectorWrapper.h index 4524fa6c0..8ceff2489 100644 --- a/DataStructures/SharedMemoryVectorWrapper.h +++ b/DataStructures/SharedMemoryVectorWrapper.h @@ -41,7 +41,7 @@ template class ShMemIterator : public std::iterator { DataT * p; public: - ShMemIterator(DataT * x) : p(x) {} + explicit ShMemIterator(DataT * x) : p(x) {} ShMemIterator(const ShMemIterator & mit) : p(mit.p) {} ShMemIterator& operator++() { ++p; diff --git a/DataStructures/StaticKDTree.h b/DataStructures/StaticKDTree.h index 8a9e88876..200fc5cd5 100644 --- a/DataStructures/StaticKDTree.h +++ b/DataStructures/StaticKDTree.h @@ -99,7 +99,7 @@ public: } }; - StaticKDTree( std::vector< InputPoint > * points ){ + explicit StaticKDTree( std::vector< InputPoint > * points ){ BOOST_ASSERT( k > 0 ); BOOST_ASSERT ( points->size() > 0 ); size = points->size(); @@ -207,7 +207,7 @@ private: }; class Less { public: - Less( unsigned d ) { + explicit Less( unsigned d ) { dimension = d; BOOST_ASSERT( dimension < k ); } diff --git a/DataStructures/XORFastHashStorage.h b/DataStructures/XORFastHashStorage.h index e4e930fd9..ae5bf1f01 100644 --- a/DataStructures/XORFastHashStorage.h +++ b/DataStructures/XORFastHashStorage.h @@ -54,7 +54,7 @@ public: } }; - XORFastHashStorage( size_t ) : positions(2<<16), currentTimestamp(0) { } + explicit XORFastHashStorage( size_t ) : positions(2<<16), currentTimestamp(0) { } inline HashCell& operator[]( const NodeID node ) { unsigned short position = fastHash(node); diff --git a/Extractor/ExtractorCallbacks.cpp b/Extractor/ExtractorCallbacks.cpp index c1ef1326c..e97275749 100644 --- a/Extractor/ExtractorCallbacks.cpp +++ b/Extractor/ExtractorCallbacks.cpp @@ -25,10 +25,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "ExtractorCallbacks.h" + #include "ExtractionContainers.h" #include "ExtractionHelperFunctions.h" #include "ExtractionWay.h" -#include "ExtractorCallbacks.h" #include "../DataStructures/Restriction.h" #include "../Util/SimpleLogger.h" diff --git a/Extractor/ScriptingEnvironment.h b/Extractor/ScriptingEnvironment.h index de3e96e8d..579df1fea 100644 --- a/Extractor/ScriptingEnvironment.h +++ b/Extractor/ScriptingEnvironment.h @@ -35,7 +35,7 @@ struct lua_State; class ScriptingEnvironment { public: ScriptingEnvironment(); - ScriptingEnvironment(const char * fileName); + explicit ScriptingEnvironment(const char * fileName); virtual ~ScriptingEnvironment(); lua_State * getLuaStateForThreadID(const int); diff --git a/Plugins/BasePlugin.h b/Plugins/BasePlugin.h index bf1ecf90f..d60ce7534 100644 --- a/Plugins/BasePlugin.h +++ b/Plugins/BasePlugin.h @@ -28,10 +28,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef BASEPLUGIN_H_ #define BASEPLUGIN_H_ +#include "../Util/StringUtil.h" + #include #include #include +#include + #include #include diff --git a/Plugins/NearestPlugin.h b/Plugins/NearestPlugin.h index 5a4bcbab7..0543dffe0 100644 --- a/Plugins/NearestPlugin.h +++ b/Plugins/NearestPlugin.h @@ -41,7 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. template class NearestPlugin : public BasePlugin { public: - NearestPlugin(DataFacadeT * facade ) + explicit NearestPlugin(DataFacadeT * facade ) : facade(facade), descriptor_string("nearest") diff --git a/Plugins/TimestampPlugin.h b/Plugins/TimestampPlugin.h index 7d46a9c1a..df4233cd4 100644 --- a/Plugins/TimestampPlugin.h +++ b/Plugins/TimestampPlugin.h @@ -33,7 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. template class TimestampPlugin : public BasePlugin { public: - TimestampPlugin(const DataFacadeT * facade) + explicit TimestampPlugin(const DataFacadeT * facade) : facade(facade), descriptor_string("timestamp") { } const std::string & GetDescriptor() const { return descriptor_string; } diff --git a/Plugins/ViaRoutePlugin.h b/Plugins/ViaRoutePlugin.h index 6f2880e04..5f25f20bc 100644 --- a/Plugins/ViaRoutePlugin.h +++ b/Plugins/ViaRoutePlugin.h @@ -53,7 +53,7 @@ private: SearchEngine * search_engine_ptr; public: - ViaRoutePlugin(DataFacadeT * facade) + explicit ViaRoutePlugin(DataFacadeT * facade) : descriptor_string("viaroute"), facade(facade) diff --git a/Server/DataStructures/InternalDataFacade.h b/Server/DataStructures/InternalDataFacade.h index c6ae80832..b8a552cf3 100644 --- a/Server/DataStructures/InternalDataFacade.h +++ b/Server/DataStructures/InternalDataFacade.h @@ -207,7 +207,7 @@ public: delete m_static_rtree; } - InternalDataFacade( const ServerPaths & server_paths ) { + explicit InternalDataFacade( const ServerPaths & server_paths ) { //generate paths of data files if( server_paths.find("hsgrdata") == server_paths.end() ) { throw OSRMException("no hsgr file given in ini file"); diff --git a/Server/Server.h b/Server/Server.h index 96e07749b..bdb1ccc21 100644 --- a/Server/Server.h +++ b/Server/Server.h @@ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include #include #include @@ -72,7 +73,7 @@ public: void Run() { std::vector > threads; for (unsigned i = 0; i < threadPoolSize; ++i) { - boost::shared_ptr thread(new boost::thread(boost::bind(&boost::asio::io_service::run, &ioService))); + boost::shared_ptr thread = boost::make_shared(boost::bind(&boost::asio::io_service::run, &ioService)); threads.push_back(thread); } for (unsigned i = 0; i < threads.size(); ++i)