From 1853f5c73c7ee438541766db1f99cd30f97734ec Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Fri, 18 Apr 2014 19:37:08 +0400 Subject: [PATCH] Explicit constructors --- libuavcan/include/uavcan/data_type.hpp | 2 +- libuavcan/include/uavcan/map.hpp | 4 ++-- libuavcan/include/uavcan/marshal/bit_stream.hpp | 2 +- libuavcan/include/uavcan/marshal/char_array_formatter.hpp | 2 +- libuavcan/include/uavcan/marshal/scalar_codec.hpp | 2 +- libuavcan/include/uavcan/node/generic_subscriber.hpp | 2 +- libuavcan/include/uavcan/node/global_data_type_registry.hpp | 2 +- libuavcan/include/uavcan/node/service_client.hpp | 2 +- .../include/uavcan/protocol/network_compat_checker.hpp | 2 +- libuavcan/include/uavcan/transport/can_io.hpp | 2 +- libuavcan/include/uavcan/transport/dispatcher.hpp | 4 ++-- .../include/uavcan/transport/outgoing_transfer_registry.hpp | 4 ++-- libuavcan/include/uavcan/transport/transfer.hpp | 2 +- libuavcan/include/uavcan/transport/transfer_buffer.hpp | 6 +++--- libuavcan/include/uavcan/transport/transfer_listener.hpp | 2 +- libuavcan/include/uavcan/util/lazy_constructor.hpp | 2 +- libuavcan/src/node/uc_scheduler.cpp | 2 +- libuavcan_drivers/linux/include/uavcan_linux/clock.hpp | 2 +- libuavcan_drivers/linux/include/uavcan_linux/exception.hpp | 2 +- libuavcan_drivers/linux/include/uavcan_linux/helpers.hpp | 4 ++-- 20 files changed, 26 insertions(+), 26 deletions(-) diff --git a/libuavcan/include/uavcan/data_type.hpp b/libuavcan/include/uavcan/data_type.hpp index bfb2f58e79..d06c3440f3 100644 --- a/libuavcan/include/uavcan/data_type.hpp +++ b/libuavcan/include/uavcan/data_type.hpp @@ -33,7 +33,7 @@ public: DataTypeID() : value_(0xFFFF) { } - DataTypeID(uint16_t id) + DataTypeID(uint16_t id) // Implicit : value_(id) { assert(isValid()); diff --git a/libuavcan/include/uavcan/map.hpp b/libuavcan/include/uavcan/map.hpp index 306e2cfd57..eddd29d656 100644 --- a/libuavcan/include/uavcan/map.hpp +++ b/libuavcan/include/uavcan/map.hpp @@ -164,7 +164,7 @@ public: #if !UAVCAN_TINY // This instantiation will not be valid in UAVCAN_TINY mode - Map(IPoolAllocator& allocator) + explicit Map(IPoolAllocator& allocator) : MapBase(static_, NumStaticEntries, allocator) { } @@ -178,7 +178,7 @@ template class UAVCAN_EXPORT Map : public MapBase { public: - Map(IPoolAllocator& allocator) + explicit Map(IPoolAllocator& allocator) #if UAVCAN_TINY : MapBase(allocator) #else diff --git a/libuavcan/include/uavcan/marshal/bit_stream.hpp b/libuavcan/include/uavcan/marshal/bit_stream.hpp index 8de28542f8..07172a7929 100644 --- a/libuavcan/include/uavcan/marshal/bit_stream.hpp +++ b/libuavcan/include/uavcan/marshal/bit_stream.hpp @@ -42,7 +42,7 @@ public: ResultOk = 1 }; - BitStream(ITransferBuffer& buf) + explicit BitStream(ITransferBuffer& buf) : buf_(buf) , bit_offset_(0) , byte_cache_(0) diff --git a/libuavcan/include/uavcan/marshal/char_array_formatter.hpp b/libuavcan/include/uavcan/marshal/char_array_formatter.hpp index da00c33d8d..76c3948ad0 100644 --- a/libuavcan/include/uavcan/marshal/char_array_formatter.hpp +++ b/libuavcan/include/uavcan/marshal/char_array_formatter.hpp @@ -68,7 +68,7 @@ class UAVCAN_EXPORT CharArrayFormatter public: typedef ArrayType_ ArrayType; - CharArrayFormatter(ArrayType& array) + explicit CharArrayFormatter(ArrayType& array) : array_(array) { } diff --git a/libuavcan/include/uavcan/marshal/scalar_codec.hpp b/libuavcan/include/uavcan/marshal/scalar_codec.hpp index 4ec4430646..6e4ef5d4b0 100644 --- a/libuavcan/include/uavcan/marshal/scalar_codec.hpp +++ b/libuavcan/include/uavcan/marshal/scalar_codec.hpp @@ -84,7 +84,7 @@ class UAVCAN_EXPORT ScalarCodec int decodeBytesImpl(uint8_t* bytes, unsigned bitlen); public: - ScalarCodec(BitStream& stream) + explicit ScalarCodec(BitStream& stream) : stream_(stream) { } diff --git a/libuavcan/include/uavcan/node/generic_subscriber.hpp b/libuavcan/include/uavcan/node/generic_subscriber.hpp index 6e6c00a4ac..ba2c815128 100644 --- a/libuavcan/include/uavcan/node/generic_subscriber.hpp +++ b/libuavcan/include/uavcan/node/generic_subscriber.hpp @@ -74,7 +74,7 @@ protected: INode& node_; uint32_t failure_count_; - GenericSubscriberBase(INode& node) + explicit GenericSubscriberBase(INode& node) : node_(node) , failure_count_(0) { } diff --git a/libuavcan/include/uavcan/node/global_data_type_registry.hpp b/libuavcan/include/uavcan/node/global_data_type_registry.hpp index 43350ce6f4..fb4fde6599 100644 --- a/libuavcan/include/uavcan/node/global_data_type_registry.hpp +++ b/libuavcan/include/uavcan/node/global_data_type_registry.hpp @@ -37,7 +37,7 @@ class UAVCAN_EXPORT GlobalDataTypeRegistry : Noncopyable struct EntryInsertionComparator { const DataTypeID id; - EntryInsertionComparator(Entry* dtd) : id(dtd->descriptor.getID()) { } + explicit EntryInsertionComparator(Entry* dtd) : id(dtd->descriptor.getID()) { } bool operator()(const Entry* entry) const { assert(entry); diff --git a/libuavcan/include/uavcan/node/service_client.hpp b/libuavcan/include/uavcan/node/service_client.hpp index 6d8fa138cf..a68db41cb6 100644 --- a/libuavcan/include/uavcan/node/service_client.hpp +++ b/libuavcan/include/uavcan/node/service_client.hpp @@ -75,7 +75,7 @@ protected: MonotonicDuration request_timeout_; bool pending_; - ServiceClientBase(INode& node) + explicit ServiceClientBase(INode& node) : DeadlineHandler(node.getScheduler()) , request_timeout_(getDefaultRequestTimeout()) , pending_(false) diff --git a/libuavcan/include/uavcan/protocol/network_compat_checker.hpp b/libuavcan/include/uavcan/protocol/network_compat_checker.hpp index e13448202e..da8444d397 100644 --- a/libuavcan/include/uavcan/protocol/network_compat_checker.hpp +++ b/libuavcan/include/uavcan/protocol/network_compat_checker.hpp @@ -59,7 +59,7 @@ class UAVCAN_EXPORT NetworkCompatibilityChecker : Noncopyable int checkNodes(); public: - NetworkCompatibilityChecker(INode& node) + explicit NetworkCompatibilityChecker(INode& node) : ns_sub_(node) , cats_cln_(node) , checking_dtkind_(DataTypeKindService) diff --git a/libuavcan/include/uavcan/transport/can_io.hpp b/libuavcan/include/uavcan/transport/can_io.hpp index 927f2c2995..c39d370cb9 100644 --- a/libuavcan/include/uavcan/transport/can_io.hpp +++ b/libuavcan/include/uavcan/transport/can_io.hpp @@ -79,7 +79,7 @@ private: { const CanFrame& frm_; public: - PriorityInsertionComparator(const CanFrame& frm) : frm_(frm) { } + explicit PriorityInsertionComparator(const CanFrame& frm) : frm_(frm) { } bool operator()(const Entry* entry) { assert(entry); diff --git a/libuavcan/include/uavcan/transport/dispatcher.hpp b/libuavcan/include/uavcan/transport/dispatcher.hpp index 50c4d1f3c8..ec35205885 100644 --- a/libuavcan/include/uavcan/transport/dispatcher.hpp +++ b/libuavcan/include/uavcan/transport/dispatcher.hpp @@ -24,7 +24,7 @@ class UAVCAN_EXPORT LoopbackFrameListenerBase : public LinkedListNode map_; public: - OutgoingTransferRegistry(IPoolAllocator& allocator) + explicit OutgoingTransferRegistry(IPoolAllocator& allocator) : map_(allocator) { } diff --git a/libuavcan/include/uavcan/transport/transfer.hpp b/libuavcan/include/uavcan/transport/transfer.hpp index fba31ceb88..31e15471bb 100644 --- a/libuavcan/include/uavcan/transport/transfer.hpp +++ b/libuavcan/include/uavcan/transport/transfer.hpp @@ -82,7 +82,7 @@ public: NodeID() : value_(ValueInvalid) { } - NodeID(uint8_t value) + NodeID(uint8_t value) // Implicit : value_(value) { assert(isValid()); diff --git a/libuavcan/include/uavcan/transport/transfer_buffer.hpp b/libuavcan/include/uavcan/transport/transfer_buffer.hpp index fa7711e087..cfbbe32d6a 100644 --- a/libuavcan/include/uavcan/transport/transfer_buffer.hpp +++ b/libuavcan/include/uavcan/transport/transfer_buffer.hpp @@ -79,7 +79,7 @@ protected: public: TransferBufferManagerEntry() { } - TransferBufferManagerEntry(const TransferBufferManagerKey& key) + explicit TransferBufferManagerEntry(const TransferBufferManagerKey& key) : key_(key) { } @@ -298,7 +298,7 @@ class UAVCAN_EXPORT TransferBufferManager : public TransferBufferManagerImpl } public: - TransferBufferManager(IPoolAllocator& allocator) + explicit TransferBufferManager(IPoolAllocator& allocator) : TransferBufferManagerImpl(MaxBufSize, allocator) { #if UAVCAN_TINY @@ -317,7 +317,7 @@ class UAVCAN_EXPORT TransferBufferManager : public TransferBuffer } public: - TransferBufferManager(IPoolAllocator& allocator) + explicit TransferBufferManager(IPoolAllocator& allocator) : TransferBufferManagerImpl(MaxBufSize, allocator) { StaticAssert<(MaxBufSize > 0)>::check(); diff --git a/libuavcan/include/uavcan/transport/transfer_listener.hpp b/libuavcan/include/uavcan/transport/transfer_listener.hpp index 38a45bcdcf..dfea4c0b52 100644 --- a/libuavcan/include/uavcan/transport/transfer_listener.hpp +++ b/libuavcan/include/uavcan/transport/transfer_listener.hpp @@ -66,7 +66,7 @@ class UAVCAN_EXPORT SingleFrameIncomingTransfer : public IncomingTransfer const uint8_t* const payload_; const uint8_t payload_len_; public: - SingleFrameIncomingTransfer(const RxFrame& frm); + explicit SingleFrameIncomingTransfer(const RxFrame& frm); int read(unsigned offset, uint8_t* data, unsigned len) const; }; diff --git a/libuavcan/include/uavcan/util/lazy_constructor.hpp b/libuavcan/include/uavcan/util/lazy_constructor.hpp index 784474dd6d..7c628974cf 100644 --- a/libuavcan/include/uavcan/util/lazy_constructor.hpp +++ b/libuavcan/include/uavcan/util/lazy_constructor.hpp @@ -56,7 +56,7 @@ public: std::fill(data_.pool, data_.pool + sizeof(T), 0); } - LazyConstructor(const LazyConstructor& rhs) + LazyConstructor(const LazyConstructor& rhs) // Implicit : ptr_(NULL) { std::fill(data_.pool, data_.pool + sizeof(T), 0); diff --git a/libuavcan/src/node/uc_scheduler.cpp b/libuavcan/src/node/uc_scheduler.cpp index 1f5aeb41e9..c3691b75a1 100644 --- a/libuavcan/src/node/uc_scheduler.cpp +++ b/libuavcan/src/node/uc_scheduler.cpp @@ -40,7 +40,7 @@ bool DeadlineHandler::isRunning() const struct MonotonicDeadlineHandlerInsertionComparator { const MonotonicTime ts; - MonotonicDeadlineHandlerInsertionComparator(MonotonicTime ts) : ts(ts) { } + explicit MonotonicDeadlineHandlerInsertionComparator(MonotonicTime ts) : ts(ts) { } bool operator()(const DeadlineHandler* t) const { return t->getDeadline() > ts; diff --git a/libuavcan_drivers/linux/include/uavcan_linux/clock.hpp b/libuavcan_drivers/linux/include/uavcan_linux/clock.hpp index 954269e84f..4fd2e5196d 100644 --- a/libuavcan_drivers/linux/include/uavcan_linux/clock.hpp +++ b/libuavcan_drivers/linux/include/uavcan_linux/clock.hpp @@ -61,7 +61,7 @@ class SystemClock : public uavcan::ISystemClock } public: - SystemClock(ClockAdjustmentMode adj_mode = detectPreferredClockAdjustmentMode()) + explicit SystemClock(ClockAdjustmentMode adj_mode = detectPreferredClockAdjustmentMode()) : gradual_adj_limit_(uavcan::UtcDuration::fromMSec(4000)) , adj_mode_(adj_mode) , step_adj_cnt_(0) diff --git a/libuavcan_drivers/linux/include/uavcan_linux/exception.hpp b/libuavcan_drivers/linux/include/uavcan_linux/exception.hpp index 966c95c55f..c639f62ae0 100644 --- a/libuavcan_drivers/linux/include/uavcan_linux/exception.hpp +++ b/libuavcan_drivers/linux/include/uavcan_linux/exception.hpp @@ -15,7 +15,7 @@ class Exception : public std::runtime_error const int errno_; public: - Exception(const std::string& descr) + explicit Exception(const std::string& descr) : std::runtime_error(descr) , errno_(errno) { } diff --git a/libuavcan_drivers/linux/include/uavcan_linux/helpers.hpp b/libuavcan_drivers/linux/include/uavcan_linux/helpers.hpp index e9a0411226..472da5d901 100644 --- a/libuavcan_drivers/linux/include/uavcan_linux/helpers.hpp +++ b/libuavcan_drivers/linux/include/uavcan_linux/helpers.hpp @@ -34,7 +34,7 @@ struct DriverPack SystemClock clock; SocketCanDriver can; - DriverPack(ClockAdjustmentMode clock_adjustment_mode) + explicit DriverPack(ClockAdjustmentMode clock_adjustment_mode) : clock(clock_adjustment_mode) , can(clock) { } @@ -75,7 +75,7 @@ public: /** * Takes ownership of the driver container. */ - Node(DriverPackPtr driver_pack) + explicit Node(DriverPackPtr driver_pack) : uavcan::Node(driver_pack->can, driver_pack->clock) , driver_pack_(driver_pack) {