From 530242819d733d5f12c83d699ff1440041c31b42 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sat, 12 Jul 2014 17:17:09 +0400 Subject: [PATCH] libuavcan core now uses UAVCAN_ASSERT() instead of assert() (autoreplace) --- libuavcan/include/uavcan/data_type.hpp | 8 ++-- libuavcan/include/uavcan/driver/can.hpp | 4 +- libuavcan/include/uavcan/dynamic_memory.hpp | 10 ++-- libuavcan/include/uavcan/error.hpp | 2 +- libuavcan/include/uavcan/marshal/array.hpp | 28 +++++------ .../include/uavcan/marshal/integer_spec.hpp | 4 +- .../include/uavcan/marshal/scalar_codec.hpp | 4 +- .../include/uavcan/node/generic_publisher.hpp | 4 +- .../uavcan/node/generic_subscriber.hpp | 4 +- .../uavcan/node/global_data_type_registry.hpp | 4 +- libuavcan/include/uavcan/node/node.hpp | 2 +- libuavcan/include/uavcan/node/publisher.hpp | 4 +- .../include/uavcan/node/service_client.hpp | 14 +++--- .../include/uavcan/node/service_server.hpp | 4 +- .../protocol/global_time_sync_master.hpp | 2 +- libuavcan/include/uavcan/protocol/logger.hpp | 2 +- .../uavcan/protocol/node_status_provider.hpp | 2 +- .../uavcan/protocol/panic_listener.hpp | 4 +- libuavcan/include/uavcan/transport/can_io.hpp | 4 +- libuavcan/include/uavcan/transport/crc.hpp | 2 +- .../include/uavcan/transport/dispatcher.hpp | 2 +- libuavcan/include/uavcan/transport/frame.hpp | 8 ++-- .../transport/outgoing_transfer_registry.hpp | 8 ++-- .../include/uavcan/transport/transfer.hpp | 6 +-- .../uavcan/transport/transfer_buffer.hpp | 6 +-- .../uavcan/transport/transfer_listener.hpp | 6 +-- .../uavcan/transport/transfer_sender.hpp | 2 +- libuavcan/include/uavcan/util/bitset.hpp | 2 +- libuavcan/include/uavcan/util/linked_list.hpp | 4 +- libuavcan/include/uavcan/util/map.hpp | 10 ++-- libuavcan/src/driver/uc_can.cpp | 2 +- libuavcan/src/marshal/uc_bit_stream.cpp | 4 +- libuavcan/src/marshal/uc_scalar_codec.cpp | 6 +-- libuavcan/src/node/uc_generic_subscriber.cpp | 2 +- .../src/node/uc_global_data_type_registry.cpp | 28 +++++------ libuavcan/src/node/uc_scheduler.cpp | 14 +++--- libuavcan/src/node/uc_timer.cpp | 4 +- .../protocol/uc_data_type_info_provider.cpp | 6 +-- .../protocol/uc_global_time_sync_master.cpp | 14 +++--- .../protocol/uc_global_time_sync_slave.cpp | 4 +- .../protocol/uc_network_compat_checker.cpp | 4 +- .../src/protocol/uc_node_status_monitor.cpp | 8 ++-- .../src/protocol/uc_node_status_provider.cpp | 8 ++-- libuavcan/src/protocol/uc_param_server.cpp | 4 +- libuavcan/src/transport/uc_can_io.cpp | 20 ++++---- libuavcan/src/transport/uc_dispatcher.cpp | 22 ++++----- libuavcan/src/transport/uc_frame.cpp | 12 ++--- libuavcan/src/transport/uc_transfer.cpp | 2 +- .../src/transport/uc_transfer_buffer.cpp | 46 +++++++++---------- .../src/transport/uc_transfer_listener.cpp | 16 +++---- .../src/transport/uc_transfer_receiver.cpp | 4 +- .../src/transport/uc_transfer_sender.cpp | 12 ++--- libuavcan/src/uc_data_type.cpp | 4 +- libuavcan/src/uc_dynamic_memory.cpp | 2 +- libuavcan/src/uc_error.cpp | 2 +- 55 files changed, 208 insertions(+), 208 deletions(-) diff --git a/libuavcan/include/uavcan/data_type.hpp b/libuavcan/include/uavcan/data_type.hpp index 0e437e0669..dad710ed31 100644 --- a/libuavcan/include/uavcan/data_type.hpp +++ b/libuavcan/include/uavcan/data_type.hpp @@ -35,7 +35,7 @@ public: DataTypeID(uint16_t id) // Implicit : value_(id) { - assert(isValid()); + UAVCAN_ASSERT(isValid()); } bool isValid() const { return value_ <= Max; } @@ -120,9 +120,9 @@ public: , signature_(signature) , full_name_(name) { - assert(kind < NumDataTypeKinds); - assert(name); - assert(std::strlen(name) <= MaxFullNameLen); + UAVCAN_ASSERT(kind < NumDataTypeKinds); + UAVCAN_ASSERT(name); + UAVCAN_ASSERT(std::strlen(name) <= MaxFullNameLen); } DataTypeKind getKind() const { return kind_; } diff --git a/libuavcan/include/uavcan/driver/can.hpp b/libuavcan/include/uavcan/driver/can.hpp index 4b468eb1d2..5746134b69 100644 --- a/libuavcan/include/uavcan/driver/can.hpp +++ b/libuavcan/include/uavcan/driver/can.hpp @@ -41,8 +41,8 @@ struct UAVCAN_EXPORT CanFrame : id(arg_id) , dlc((data_len > MaxDataLen) ? MaxDataLen : data_len) { - assert(arg_data != NULL); - assert(data_len == dlc); + UAVCAN_ASSERT(arg_data != NULL); + UAVCAN_ASSERT(data_len == dlc); (void)copy(arg_data, arg_data + dlc, this->data); } diff --git a/libuavcan/include/uavcan/dynamic_memory.hpp b/libuavcan/include/uavcan/dynamic_memory.hpp index e6222ff105..bc47d6c114 100644 --- a/libuavcan/include/uavcan/dynamic_memory.hpp +++ b/libuavcan/include/uavcan/dynamic_memory.hpp @@ -116,7 +116,7 @@ public: , max_blocks_(max_blocks) , used_blocks_(0) { - assert(max_blocks_ > 0); + UAVCAN_ASSERT(max_blocks_ > 0); } virtual void* allocate(std::size_t size); @@ -136,11 +136,11 @@ public: template bool PoolManager::addPool(IPoolAllocator* pool) { - assert(pool); + UAVCAN_ASSERT(pool); bool retval = false; for (unsigned i = 0; i < MaxPools; i++) { - assert(pools_[i] != pool); + UAVCAN_ASSERT(pools_[i] != pool); if (pools_[i] == NULL || pools_[i] == pool) { pools_[i] = pool; @@ -179,7 +179,7 @@ void PoolManager::deallocate(const void* ptr) { if (pools_[i] == NULL) { - assert(0); + UAVCAN_ASSERT(0); break; } if (pools_[i]->isInPool(ptr)) @@ -283,7 +283,7 @@ unsigned PoolAllocator::getNumFreeBlocks() const while (p) { num++; - assert(num <= NumBlocks); + UAVCAN_ASSERT(num <= NumBlocks); p = p->next; } return num; diff --git a/libuavcan/include/uavcan/error.hpp b/libuavcan/include/uavcan/error.hpp index 5cf9129684..a6800676b8 100644 --- a/libuavcan/include/uavcan/error.hpp +++ b/libuavcan/include/uavcan/error.hpp @@ -32,7 +32,7 @@ const int16_t ErrPassiveMode = 11; /** * Fatal error handler. - * Throws std::runtime_error() if exceptions are available, otherwise calls assert(0) then std::abort(). + * Throws std::runtime_error() if exceptions are available, otherwise calls UAVCAN_ASSERT(0) then std::abort(). */ #if __GNUC__ __attribute__ ((noreturn)) diff --git a/libuavcan/include/uavcan/marshal/array.hpp b/libuavcan/include/uavcan/marshal/array.hpp index ca8cca9ee0..cef940ee67 100644 --- a/libuavcan/include/uavcan/marshal/array.hpp +++ b/libuavcan/include/uavcan/marshal/array.hpp @@ -51,7 +51,7 @@ protected: #if UAVCAN_EXCEPTIONS throw std::out_of_range("uavcan::Array"); #else - assert(0); + UAVCAN_ASSERT(0); return Size - 1; // Ha ha #endif } @@ -82,7 +82,7 @@ protected: #if UAVCAN_EXCEPTIONS throw std::out_of_range("uavcan::Array"); #else - assert(0); + UAVCAN_ASSERT(0); return (size_ == 0) ? 0 : (size_ - 1); #endif } @@ -91,7 +91,7 @@ protected: { if (size_ >= MaxSize) { - (void)validateRange(MaxSize); // Will throw, assert() or do nothing + (void)validateRange(MaxSize); // Will throw, UAVCAN_ASSERT() or do nothing } else { @@ -112,7 +112,7 @@ public: SizeType size() const { - assert(size_ ? ((size_ - 1u) <= (MaxSize - 1u)) : 1); // -Werror=type-limits + UAVCAN_ASSERT(size_ ? ((size_ - 1u) <= (MaxSize - 1u)) : 1); // -Werror=type-limits return size_; } @@ -168,7 +168,7 @@ public: const char* c_str() const { StaticAssert::check(); - assert(size() < (MaxSize + 1)); + UAVCAN_ASSERT(size() < (MaxSize + 1)); const_cast(data_)[size()] = 0; // Ad-hoc string termination return reinterpret_cast(data_); } @@ -245,7 +245,7 @@ class UAVCAN_EXPORT Array : public ArrayImpl int encodeImpl(ScalarCodec& codec, const TailArrayOptimizationMode tao_mode, FalseType) const /// Static { - assert(size() > 0); + UAVCAN_ASSERT(size() > 0); for (SizeType i = 0; i < size(); i++) { const bool last_item = i == (size() - 1); @@ -279,7 +279,7 @@ class UAVCAN_EXPORT Array : public ArrayImpl int decodeImpl(ScalarCodec& codec, const TailArrayOptimizationMode tao_mode, FalseType) /// Static { - assert(size() > 0); + UAVCAN_ASSERT(size() > 0); for (SizeType i = 0; i < size(); i++) { const bool last_item = i == (size() - 1); @@ -338,7 +338,7 @@ class UAVCAN_EXPORT Array : public ArrayImpl } return decodeImpl(codec, tao_mode, FalseType()); } - assert(0); // Unreachable + UAVCAN_ASSERT(0); // Unreachable return -ErrLogic; } @@ -615,13 +615,13 @@ public: if (!format) { - assert(0); + UAVCAN_ASSERT(0); return; } // Add some hardcore runtime checks for the format string correctness? ValueType* const ptr = Base::end(); - assert(capacity() >= size()); + UAVCAN_ASSERT(capacity() >= size()); const SizeType max_size = capacity() - size(); // We have one extra byte for the null terminator, hence +1 @@ -634,7 +634,7 @@ public: } if (ret < 0) { - assert(0); // Likely an invalid format string + UAVCAN_ASSERT(0); // Likely an invalid format string (*this) += format; // So we print it as is in release builds } } @@ -671,7 +671,7 @@ public: #if UAVCAN_EXCEPTIONS throw std::out_of_range("uavcan::Array::packSquareMatrix()"); #else - assert(0); + UAVCAN_ASSERT(0); this->clear(); #endif } @@ -698,7 +698,7 @@ public: #if UAVCAN_EXCEPTIONS throw std::out_of_range("uavcan::Array::packSquareMatrix()"); #else - assert(0); + UAVCAN_ASSERT(0); this->clear(); #endif } @@ -744,7 +744,7 @@ public: #if UAVCAN_EXCEPTIONS throw std::out_of_range("uavcan::Array::unpackSquareMatrix()"); #else - assert(0); + UAVCAN_ASSERT(0); #endif } } diff --git a/libuavcan/include/uavcan/marshal/integer_spec.hpp b/libuavcan/include/uavcan/marshal/integer_spec.hpp index ab6ea98028..179aaee3b0 100644 --- a/libuavcan/include/uavcan/marshal/integer_spec.hpp +++ b/libuavcan/include/uavcan/marshal/integer_spec.hpp @@ -92,9 +92,9 @@ private: { StaticAssert<(BitLen <= (sizeof(StorageType) * 8))>::check(); // coverity[result_independent_of_operands : FALSE] - assert(max() <= NumericTraits::max()); + UAVCAN_ASSERT(max() <= NumericTraits::max()); // coverity[result_independent_of_operands : FALSE] - assert(min() >= NumericTraits::min()); + UAVCAN_ASSERT(min() >= NumericTraits::min()); } public: diff --git a/libuavcan/include/uavcan/marshal/scalar_codec.hpp b/libuavcan/include/uavcan/marshal/scalar_codec.hpp index be0aa373ba..4c49ceeff6 100644 --- a/libuavcan/include/uavcan/marshal/scalar_codec.hpp +++ b/libuavcan/include/uavcan/marshal/scalar_codec.hpp @@ -32,9 +32,9 @@ class UAVCAN_EXPORT ScalarCodec #endif /* * I didn't have any big endian machine nearby, so big endian support wasn't tested yet. - * It is likely to be OK anyway, so feel free to remove this assert() as needed. + * It is likely to be OK anyway, so feel free to remove this UAVCAN_ASSERT() as needed. */ - assert(big_endian == false); + UAVCAN_ASSERT(big_endian == false); if (big_endian) { swapByteOrder(bytes, Size); diff --git a/libuavcan/include/uavcan/node/generic_publisher.hpp b/libuavcan/include/uavcan/node/generic_publisher.hpp index ef8a5a5646..f21b7b4898 100644 --- a/libuavcan/include/uavcan/node/generic_publisher.hpp +++ b/libuavcan/include/uavcan/node/generic_publisher.hpp @@ -33,7 +33,7 @@ protected: { setTxTimeout(tx_timeout); #if UAVCAN_DEBUG - assert(getTxTimeout() == tx_timeout); // Making sure default values are OK + UAVCAN_ASSERT(getTxTimeout() == tx_timeout); // Making sure default values are OK #endif } @@ -135,7 +135,7 @@ int GenericPublisher::doEncode(const DataStruct& message, const int encode_res = DataStruct::encode(message, codec); if (encode_res <= 0) { - assert(0); // Impossible, internal error + UAVCAN_ASSERT(0); // Impossible, internal error return -ErrInvalidMarshalData; } return encode_res; diff --git a/libuavcan/include/uavcan/node/generic_subscriber.hpp b/libuavcan/include/uavcan/node/generic_subscriber.hpp index d950a930e2..29b7cf6f18 100644 --- a/libuavcan/include/uavcan/node/generic_subscriber.hpp +++ b/libuavcan/include/uavcan/node/generic_subscriber.hpp @@ -28,7 +28,7 @@ class UAVCAN_EXPORT ReceivedDataStructure : public DataType_ { if (!transfer_) { - assert(0); + UAVCAN_ASSERT(0); return Ret(); } return (transfer_->*Fun)(); @@ -39,7 +39,7 @@ protected: void setTransfer(const IncomingTransfer* transfer) { - assert(transfer); + UAVCAN_ASSERT(transfer); transfer_ = transfer; } diff --git a/libuavcan/include/uavcan/node/global_data_type_registry.hpp b/libuavcan/include/uavcan/node/global_data_type_registry.hpp index e6bc11180e..41646751b1 100644 --- a/libuavcan/include/uavcan/node/global_data_type_registry.hpp +++ b/libuavcan/include/uavcan/node/global_data_type_registry.hpp @@ -39,11 +39,11 @@ class UAVCAN_EXPORT GlobalDataTypeRegistry : Noncopyable explicit EntryInsertionComparator(const Entry* dtd) : id((dtd == NULL) ? DataTypeID() : dtd->descriptor.getID()) { - assert(dtd != NULL); + UAVCAN_ASSERT(dtd != NULL); } bool operator()(const Entry* entry) const { - assert(entry != NULL); + UAVCAN_ASSERT(entry != NULL); return entry->descriptor.getID() > id; } }; diff --git a/libuavcan/include/uavcan/node/node.hpp b/libuavcan/include/uavcan/node/node.hpp index 97806663f5..8f39b06877 100644 --- a/libuavcan/include/uavcan/node/node.hpp +++ b/libuavcan/include/uavcan/node/node.hpp @@ -234,7 +234,7 @@ int Node= 0; return res; fail: - assert(res < 0); + UAVCAN_ASSERT(res < 0); return res; } diff --git a/libuavcan/include/uavcan/node/publisher.hpp b/libuavcan/include/uavcan/node/publisher.hpp index 7b98e95a64..a16c9eb5c7 100644 --- a/libuavcan/include/uavcan/node/publisher.hpp +++ b/libuavcan/include/uavcan/node/publisher.hpp @@ -22,7 +22,7 @@ public: : BaseType(node, tx_timeout, max_transfer_interval) { #if UAVCAN_DEBUG - assert(getTxTimeout() == tx_timeout); // Making sure default values are OK + UAVCAN_ASSERT(getTxTimeout() == tx_timeout); // Making sure default values are OK #endif StaticAssert::check(); } @@ -41,7 +41,7 @@ public: { if (!dst_node_id.isUnicast()) { - assert(0); + UAVCAN_ASSERT(0); return -ErrInvalidParam; } return BaseType::publish(message, TransferTypeMessageUnicast, dst_node_id); diff --git a/libuavcan/include/uavcan/node/service_client.hpp b/libuavcan/include/uavcan/node/service_client.hpp index 27ab81d2af..df199be2a7 100644 --- a/libuavcan/include/uavcan/node/service_client.hpp +++ b/libuavcan/include/uavcan/node/service_client.hpp @@ -44,8 +44,8 @@ struct UAVCAN_EXPORT ServiceCallResult , server_node_id(arg_server_node_id) , response(arg_response) { - assert(server_node_id.isUnicast()); - assert((status == Success) || (status == ErrorTimeout)); + UAVCAN_ASSERT(server_node_id.isUnicast()); + UAVCAN_ASSERT((status == Success) || (status == ErrorTimeout)); } bool isSuccessful() const { return status == Success; } @@ -141,7 +141,7 @@ public: { setRequestTimeout(getDefaultRequestTimeout()); #if UAVCAN_DEBUG - assert(getRequestTimeout() == getDefaultRequestTimeout()); // Making sure default values are OK + UAVCAN_ASSERT(getRequestTimeout() == getDefaultRequestTimeout()); // Making sure default values are OK #endif } @@ -194,7 +194,7 @@ void ServiceClient::invokeCallback(ServiceCallResultType& template void ServiceClient::handleReceivedDataStruct(ReceivedDataStructure& response) { - assert(response.getTransferType() == TransferTypeServiceResponse); + UAVCAN_ASSERT(response.getTransferType() == TransferTypeServiceResponse); const TransferListenerType* const listener = SubscriberType::getTransferListener(); if (listener) { @@ -205,7 +205,7 @@ void ServiceClient::handleReceivedDataStruct(ReceivedDataS } else { - assert(0); + UAVCAN_ASSERT(0); cancel(); } } @@ -227,7 +227,7 @@ void ServiceClient::handleDeadline(MonotonicTime) } else { - assert(0); + UAVCAN_ASSERT(0); cancel(); } } @@ -272,7 +272,7 @@ int ServiceClient::call(NodeID server_node_id, const Reque TransferListenerType* const tl = SubscriberType::getTransferListener(); if (!tl) { - assert(0); // Must have been created + UAVCAN_ASSERT(0); // Must have been created cancel(); return -ErrLogic; } diff --git a/libuavcan/include/uavcan/node/service_server.hpp b/libuavcan/include/uavcan/node/service_server.hpp index b7043e3a82..e2c92d304d 100644 --- a/libuavcan/include/uavcan/node/service_server.hpp +++ b/libuavcan/include/uavcan/node/service_server.hpp @@ -59,7 +59,7 @@ private: void handleReceivedDataStruct(ReceivedDataStructure& request) { - assert(request.getTransferType() == TransferTypeServiceRequest); + UAVCAN_ASSERT(request.getTransferType() == TransferTypeServiceRequest); if (try_implicit_cast(callback_, true)) { response_ = ResponseType(); // The application needs newly initialized structure @@ -87,7 +87,7 @@ public: , callback_() , response_failure_count_(0) { - assert(getTxTimeout() == getDefaultTxTimeout()); // Making sure it is valid + UAVCAN_ASSERT(getTxTimeout() == getDefaultTxTimeout()); // Making sure it is valid StaticAssert::check(); } diff --git a/libuavcan/include/uavcan/protocol/global_time_sync_master.hpp b/libuavcan/include/uavcan/protocol/global_time_sync_master.hpp index 662670f932..ceb4b68d21 100644 --- a/libuavcan/include/uavcan/protocol/global_time_sync_master.hpp +++ b/libuavcan/include/uavcan/protocol/global_time_sync_master.hpp @@ -30,7 +30,7 @@ class UAVCAN_EXPORT GlobalTimeSyncMaster : protected LoopbackFrameListenerBase : pub_(node) , iface_index_(iface_index) { - assert(iface_index < MaxCanIfaces); + UAVCAN_ASSERT(iface_index < MaxCanIfaces); } int init(); diff --git a/libuavcan/include/uavcan/protocol/logger.hpp b/libuavcan/include/uavcan/protocol/logger.hpp index 9a55f2a523..173e1af9b8 100644 --- a/libuavcan/include/uavcan/protocol/logger.hpp +++ b/libuavcan/include/uavcan/protocol/logger.hpp @@ -59,7 +59,7 @@ public: { level_ = protocol::debug::LogLevel::ERROR; setTxTimeout(MonotonicDuration::fromMSec(DefaultTxTimeoutMs)); - assert(getTxTimeout() == MonotonicDuration::fromMSec(DefaultTxTimeoutMs)); + UAVCAN_ASSERT(getTxTimeout() == MonotonicDuration::fromMSec(DefaultTxTimeoutMs)); } int init(); diff --git a/libuavcan/include/uavcan/protocol/node_status_provider.hpp b/libuavcan/include/uavcan/protocol/node_status_provider.hpp index 3fcc0a294b..ff950ed634 100644 --- a/libuavcan/include/uavcan/protocol/node_status_provider.hpp +++ b/libuavcan/include/uavcan/protocol/node_status_provider.hpp @@ -52,7 +52,7 @@ public: , gdr_sub_(node) , gni_srv_(node) { - assert(!creation_timestamp_.isZero()); + UAVCAN_ASSERT(!creation_timestamp_.isZero()); node_info_.uavcan_version.major = UAVCAN_VERSION_MAJOR; node_info_.uavcan_version.minor = UAVCAN_VERSION_MINOR; diff --git a/libuavcan/include/uavcan/protocol/panic_listener.hpp b/libuavcan/include/uavcan/protocol/panic_listener.hpp index f222fd7cf6..e00a797d9d 100644 --- a/libuavcan/include/uavcan/protocol/panic_listener.hpp +++ b/libuavcan/include/uavcan/protocol/panic_listener.hpp @@ -53,7 +53,7 @@ class UAVCAN_EXPORT PanicListener : Noncopyable } else { - assert(0); // This is a logic error because normally we shouldn't start with an invalid callback + UAVCAN_ASSERT(0); // This is a logic error because normally we shouldn't start with an invalid callback sub_.getNode().registerInternalFailure("PanicListener invalid callback"); } } @@ -70,7 +70,7 @@ class UAVCAN_EXPORT PanicListener : Noncopyable else { const MonotonicDuration diff = msg.getMonotonicTimestamp() - prev_msg_timestamp_; - assert(diff.isPositive() || diff.isZero()); + UAVCAN_ASSERT(diff.isPositive() || diff.isZero()); if (diff.toMSec() > protocol::Panic::MAX_INTERVAL_MS) { num_subsequent_msgs_ = 1; diff --git a/libuavcan/include/uavcan/transport/can_io.hpp b/libuavcan/include/uavcan/transport/can_io.hpp index 0fcc6e152a..3c39d1b0b3 100644 --- a/libuavcan/include/uavcan/transport/can_io.hpp +++ b/libuavcan/include/uavcan/transport/can_io.hpp @@ -56,7 +56,7 @@ public: , qos(uint8_t(arg_qos)) , flags(arg_flags) { - assert((qos == Volatile) || (qos == Persistent)); + UAVCAN_ASSERT((qos == Volatile) || (qos == Persistent)); IsDynamicallyAllocatable::check(); } @@ -82,7 +82,7 @@ private: explicit PriorityInsertionComparator(const CanFrame& frm) : frm_(frm) { } bool operator()(const Entry* entry) { - assert(entry); + UAVCAN_ASSERT(entry); return frm_.priorityHigherThan(entry->frame); } }; diff --git a/libuavcan/include/uavcan/transport/crc.hpp b/libuavcan/include/uavcan/transport/crc.hpp index 6b38c6e94c..c2380c5206 100644 --- a/libuavcan/include/uavcan/transport/crc.hpp +++ b/libuavcan/include/uavcan/transport/crc.hpp @@ -64,7 +64,7 @@ public: void add(const uint8_t* bytes, unsigned len) { - assert(bytes); + UAVCAN_ASSERT(bytes); while (len--) { add(*bytes++); diff --git a/libuavcan/include/uavcan/transport/dispatcher.hpp b/libuavcan/include/uavcan/transport/dispatcher.hpp index a36700c30c..07054754e5 100644 --- a/libuavcan/include/uavcan/transport/dispatcher.hpp +++ b/libuavcan/include/uavcan/transport/dispatcher.hpp @@ -73,7 +73,7 @@ class UAVCAN_EXPORT Dispatcher : Noncopyable explicit DataTypeIDInsertionComparator(DataTypeID id) : id_(id) { } bool operator()(const TransferListenerBase* listener) const { - assert(listener); + UAVCAN_ASSERT(listener); return id_ > listener->getDataTypeDescriptor().getID(); } }; diff --git a/libuavcan/include/uavcan/transport/frame.hpp b/libuavcan/include/uavcan/transport/frame.hpp index 026502fcf1..ab6e7607de 100644 --- a/libuavcan/include/uavcan/transport/frame.hpp +++ b/libuavcan/include/uavcan/transport/frame.hpp @@ -47,10 +47,10 @@ public: , transfer_id_(transfer_id) , last_frame_(last_frame) { - assert((transfer_type == TransferTypeMessageBroadcast) == dst_node_id.isBroadcast()); - assert(data_type_id.isValid()); - assert(src_node_id != dst_node_id); - assert(frame_index <= MaxIndex); + UAVCAN_ASSERT((transfer_type == TransferTypeMessageBroadcast) == dst_node_id.isBroadcast()); + UAVCAN_ASSERT(data_type_id.isValid()); + UAVCAN_ASSERT(src_node_id != dst_node_id); + UAVCAN_ASSERT(frame_index <= MaxIndex); } int getMaxPayloadLen() const; diff --git a/libuavcan/include/uavcan/transport/outgoing_transfer_registry.hpp b/libuavcan/include/uavcan/transport/outgoing_transfer_registry.hpp index 876da5c1d9..da6d0a1619 100644 --- a/libuavcan/include/uavcan/transport/outgoing_transfer_registry.hpp +++ b/libuavcan/include/uavcan/transport/outgoing_transfer_registry.hpp @@ -32,12 +32,12 @@ public: , transfer_type_(transfer_type) , destination_node_id_(destination_node_id) { - assert((transfer_type == TransferTypeMessageBroadcast) == destination_node_id.isBroadcast()); + UAVCAN_ASSERT((transfer_type == TransferTypeMessageBroadcast) == destination_node_id.isBroadcast()); /* * Service response transfers must use the same Transfer ID as matching service request transfer, * so this registry is not applicable for service response transfers at all. */ - assert(transfer_type != TransferTypeServiceResponse); + UAVCAN_ASSERT(transfer_type != TransferTypeServiceResponse); } DataTypeID getDataTypeID() const { return data_type_id_; } @@ -91,7 +91,7 @@ class UAVCAN_EXPORT OutgoingTransferRegistry : public IOutgoingTransferRegistry, bool operator()(const OutgoingTransferRegistryKey& key, const Value& value) const { (void)key; - assert(!value.deadline.isZero()); + UAVCAN_ASSERT(!value.deadline.isZero()); const bool expired = value.deadline <= ts_; if (expired) { @@ -142,7 +142,7 @@ template TransferID* OutgoingTransferRegistry::accessOrCreate(const OutgoingTransferRegistryKey& key, MonotonicTime new_deadline) { - assert(!new_deadline.isZero()); + UAVCAN_ASSERT(!new_deadline.isZero()); Value* p = map_.access(key); if (p == NULL) { diff --git a/libuavcan/include/uavcan/transport/transfer.hpp b/libuavcan/include/uavcan/transport/transfer.hpp index 07a7213300..76f0ac6257 100644 --- a/libuavcan/include/uavcan/transport/transfer.hpp +++ b/libuavcan/include/uavcan/transport/transfer.hpp @@ -41,7 +41,7 @@ public: : value_(value) { value_ &= Max; - assert(value == value_); + UAVCAN_ASSERT(value == value_); } bool operator!=(TransferID rhs) const { return !operator==(rhs); } @@ -54,7 +54,7 @@ public: uint8_t get() const { - assert(value_ <= Max); + UAVCAN_ASSERT(value_ <= Max); return value_; } @@ -81,7 +81,7 @@ public: NodeID(uint8_t value) // Implicit : value_(value) { - assert(isValid()); + UAVCAN_ASSERT(isValid()); } uint8_t get() const { return value_; } diff --git a/libuavcan/include/uavcan/transport/transfer_buffer.hpp b/libuavcan/include/uavcan/transport/transfer_buffer.hpp index db61104422..6f603aadd3 100644 --- a/libuavcan/include/uavcan/transport/transfer_buffer.hpp +++ b/libuavcan/include/uavcan/transport/transfer_buffer.hpp @@ -28,14 +28,14 @@ public: TransferBufferManagerKey() : transfer_type_(TransferType(0)) { - assert(isEmpty()); + UAVCAN_ASSERT(isEmpty()); } TransferBufferManagerKey(NodeID node_id, TransferType ttype) : node_id_(node_id) , transfer_type_(ttype) { - assert(!isEmpty()); + UAVCAN_ASSERT(!isEmpty()); } bool operator==(const TransferBufferManagerKey& rhs) const @@ -235,7 +235,7 @@ public: : bufmgr_(bufmgr) , key_(key) { - assert(!key.isEmpty()); + UAVCAN_ASSERT(!key.isEmpty()); } ITransferBuffer* access() { return bufmgr_.access(key_); } ITransferBuffer* create() { return bufmgr_.create(key_); } diff --git a/libuavcan/include/uavcan/transport/transfer_listener.hpp b/libuavcan/include/uavcan/transport/transfer_listener.hpp index 49c61cca40..e6f8fed42f 100644 --- a/libuavcan/include/uavcan/transport/transfer_listener.hpp +++ b/libuavcan/include/uavcan/transport/transfer_listener.hpp @@ -182,19 +182,19 @@ public: ExpectedResponseParams() { - assert(!src_node_id.isValid()); + UAVCAN_ASSERT(!src_node_id.isValid()); } ExpectedResponseParams(NodeID arg_src_node_id, TransferID arg_transfer_id) : src_node_id(arg_src_node_id) , transfer_id(arg_transfer_id) { - assert(src_node_id.isUnicast()); + UAVCAN_ASSERT(src_node_id.isUnicast()); } bool match(const RxFrame& frame) const { - assert(frame.getTransferType() == TransferTypeServiceResponse); + UAVCAN_ASSERT(frame.getTransferType() == TransferTypeServiceResponse); return (frame.getSrcNodeID() == src_node_id) && (frame.getTransferID() == transfer_id); } }; diff --git a/libuavcan/include/uavcan/transport/transfer_sender.hpp b/libuavcan/include/uavcan/transport/transfer_sender.hpp index 648d608c13..b727e56cda 100644 --- a/libuavcan/include/uavcan/transport/transfer_sender.hpp +++ b/libuavcan/include/uavcan/transport/transfer_sender.hpp @@ -54,7 +54,7 @@ public: uint8_t getIfaceMask() const { return iface_mask_; } void setIfaceMask(uint8_t iface_mask) { - assert(iface_mask); + UAVCAN_ASSERT(iface_mask); iface_mask_ = iface_mask; } diff --git a/libuavcan/include/uavcan/util/bitset.hpp b/libuavcan/include/uavcan/util/bitset.hpp index e979421c99..0855c21de6 100644 --- a/libuavcan/include/uavcan/util/bitset.hpp +++ b/libuavcan/include/uavcan/util/bitset.hpp @@ -27,7 +27,7 @@ class UAVCAN_EXPORT BitSet { if (inout_pos >= NumBits) { - assert(0); + UAVCAN_ASSERT(0); inout_pos = NumBits - 1; } } diff --git a/libuavcan/include/uavcan/util/linked_list.hpp b/libuavcan/include/uavcan/util/linked_list.hpp index 59c1ebb488..e5d8391e94 100644 --- a/libuavcan/include/uavcan/util/linked_list.hpp +++ b/libuavcan/include/uavcan/util/linked_list.hpp @@ -86,7 +86,7 @@ unsigned LinkedListRoot::getLength() const template void LinkedListRoot::insert(T* node) { - assert(node); + UAVCAN_ASSERT(node); remove(node); // Making sure there will be no loops node->setNextListNode(root_); root_ = node; @@ -96,7 +96,7 @@ template template void LinkedListRoot::insertBefore(T* node, Predicate predicate) { - assert(node); + UAVCAN_ASSERT(node); remove(node); if (root_ == NULL || predicate(root_)) diff --git a/libuavcan/include/uavcan/util/map.hpp b/libuavcan/include/uavcan/util/map.hpp index 0f912140d1..09853ea91c 100644 --- a/libuavcan/include/uavcan/util/map.hpp +++ b/libuavcan/include/uavcan/util/map.hpp @@ -108,7 +108,7 @@ protected: MapBase(IPoolAllocator& allocator) : allocator_(allocator) { - assert(Key() == Key()); + UAVCAN_ASSERT(Key() == Key()); } #else MapBase(KVPair* static_buf, unsigned num_static_entries, IPoolAllocator& allocator) @@ -116,7 +116,7 @@ protected: , static_(static_buf) , num_static_entries_(num_static_entries) { - assert(Key() == Key()); + UAVCAN_ASSERT(Key() == Key()); } #endif @@ -304,7 +304,7 @@ void MapBase::compact() template Value* MapBase::access(const Key& key) { - assert(!(key == Key())); + UAVCAN_ASSERT(!(key == Key())); KVPair* const kv = find(key); return kv ? &kv->value : NULL; } @@ -312,7 +312,7 @@ Value* MapBase::access(const Key& key) template Value* MapBase::insert(const Key& key, const Value& value) { - assert(!(key == Key())); + UAVCAN_ASSERT(!(key == Key())); remove(key); KVPair* const kv = find(Key()); @@ -335,7 +335,7 @@ Value* MapBase::insert(const Key& key, const Value& value) template void MapBase::remove(const Key& key) { - assert(!(key == Key())); + UAVCAN_ASSERT(!(key == Key())); KVPair* const kv = find(key); if (kv) { diff --git a/libuavcan/src/driver/uc_can.cpp b/libuavcan/src/driver/uc_can.cpp index f60696b79c..5df37bf28b 100644 --- a/libuavcan/src/driver/uc_can.cpp +++ b/libuavcan/src/driver/uc_can.cpp @@ -61,7 +61,7 @@ std::string CanFrame::toString(StringRepresentation mode) const { using namespace std; // For snprintf() - assert(mode == StrTight || mode == StrAligned); + UAVCAN_ASSERT(mode == StrTight || mode == StrAligned); static const unsigned AsciiColumnOffset = 36U; diff --git a/libuavcan/src/marshal/uc_bit_stream.cpp b/libuavcan/src/marshal/uc_bit_stream.cpp index ca7ccb463e..213bb3100c 100644 --- a/libuavcan/src/marshal/uc_bit_stream.cpp +++ b/libuavcan/src/marshal/uc_bit_stream.cpp @@ -19,7 +19,7 @@ int BitStream::write(const uint8_t* bytes, const int bitlen) // Tmp space must be large enough to accomodate new bits AND unaligned bits from the last write() const unsigned bytelen = bitlenToBytelen(bitlen + (bit_offset_ % 8)); - assert(MaxBytesPerRW >= bytelen); + UAVCAN_ASSERT(MaxBytesPerRW >= bytelen); tmp[0] = tmp[bytelen - 1] = 0; fill(tmp, tmp + bytelen, 0); @@ -57,7 +57,7 @@ int BitStream::read(uint8_t* bytes, const int bitlen) uint8_t tmp[MaxBytesPerRW + 1]; const unsigned bytelen = bitlenToBytelen(bitlen + (bit_offset_ % 8)); - assert(MaxBytesPerRW >= bytelen); + UAVCAN_ASSERT(MaxBytesPerRW >= bytelen); const int read_res = buf_.read(bit_offset_ / 8, tmp, bytelen); if (read_res < 0) diff --git a/libuavcan/src/marshal/uc_scalar_codec.cpp b/libuavcan/src/marshal/uc_scalar_codec.cpp index 7f523d8c97..b0807a8bcd 100644 --- a/libuavcan/src/marshal/uc_scalar_codec.cpp +++ b/libuavcan/src/marshal/uc_scalar_codec.cpp @@ -9,7 +9,7 @@ namespace uavcan void ScalarCodec::swapByteOrder(uint8_t* const bytes, const unsigned len) { - assert(bytes); + UAVCAN_ASSERT(bytes); for (int i = 0, j = len - 1; i < j; i++, j--) { const uint8_t c = bytes[i]; @@ -20,7 +20,7 @@ void ScalarCodec::swapByteOrder(uint8_t* const bytes, const unsigned len) int ScalarCodec::encodeBytesImpl(uint8_t* const bytes, const unsigned bitlen) { - assert(bytes); + UAVCAN_ASSERT(bytes); // Underlying stream class assumes that more significant bits have lower index, so we need to shift some. if (bitlen % 8) { @@ -31,7 +31,7 @@ int ScalarCodec::encodeBytesImpl(uint8_t* const bytes, const unsigned bitlen) int ScalarCodec::decodeBytesImpl(uint8_t* const bytes, const unsigned bitlen) { - assert(bytes); + UAVCAN_ASSERT(bytes); const int read_res = stream_.read(bytes, bitlen); if (read_res > 0) { diff --git a/libuavcan/src/node/uc_generic_subscriber.cpp b/libuavcan/src/node/uc_generic_subscriber.cpp index 2abd40c01b..4ec626cd10 100644 --- a/libuavcan/src/node/uc_generic_subscriber.cpp +++ b/libuavcan/src/node/uc_generic_subscriber.cpp @@ -12,7 +12,7 @@ int GenericSubscriberBase::genericStart(TransferListenerBase* listener, { if (listener == NULL) { - assert(0); + UAVCAN_ASSERT(0); return -ErrLogic; } stop(listener); diff --git a/libuavcan/src/node/uc_global_data_type_registry.cpp b/libuavcan/src/node/uc_global_data_type_registry.cpp index 29aafa6b7f..0295b0c588 100644 --- a/libuavcan/src/node/uc_global_data_type_registry.cpp +++ b/libuavcan/src/node/uc_global_data_type_registry.cpp @@ -22,7 +22,7 @@ GlobalDataTypeRegistry::List* GlobalDataTypeRegistry::selectList(DataTypeKind ki } else { - assert(0); + UAVCAN_ASSERT(0); return NULL; } } @@ -31,7 +31,7 @@ GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::remove(Entry* dtd) { if (!dtd) { - assert(0); + UAVCAN_ASSERT(0); return RegistResultInvalidParams; } if (isFrozen()) @@ -63,7 +63,7 @@ GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::registImpl(Entry* d { if (!dtd || (dtd->descriptor.getID() > DataTypeID::Max)) { - assert(0); + UAVCAN_ASSERT(0); return RegistResultInvalidParams; } if (isFrozen()) @@ -103,7 +103,7 @@ GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::registImpl(Entry* d const unsigned len_after = list->getLength(); if ((len_before + 1) != len_after) { - assert(0); + UAVCAN_ASSERT(0); std::abort(); } } @@ -114,7 +114,7 @@ GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::registImpl(Entry* d { if (id >= p->descriptor.getID().get()) { - assert(0); + UAVCAN_ASSERT(0); std::abort(); } id = p->descriptor.getID().get(); @@ -145,13 +145,13 @@ const DataTypeDescriptor* GlobalDataTypeRegistry::find(DataTypeKind kind, const { if (!name) { - assert(0); + UAVCAN_ASSERT(0); return NULL; } const List* list = selectList(kind); if (!list) { - assert(0); + UAVCAN_ASSERT(0); return NULL; } Entry* p = list->get(); @@ -171,7 +171,7 @@ const DataTypeDescriptor* GlobalDataTypeRegistry::find(DataTypeKind kind, DataTy const List* list = selectList(kind); if (!list) { - assert(0); + UAVCAN_ASSERT(0); return NULL; } Entry* p = list->get(); @@ -189,12 +189,12 @@ const DataTypeDescriptor* GlobalDataTypeRegistry::find(DataTypeKind kind, DataTy DataTypeSignature GlobalDataTypeRegistry::computeAggregateSignature(DataTypeKind kind, DataTypeIDMask& inout_id_mask) const { - assert(isFrozen()); // Computing the signature if the registry is not frozen is pointless + UAVCAN_ASSERT(isFrozen()); // Computing the signature if the registry is not frozen is pointless const List* list = selectList(kind); if (!list) { - assert(0); + UAVCAN_ASSERT(0); return DataTypeSignature(); } @@ -220,13 +220,13 @@ DataTypeSignature GlobalDataTypeRegistry::computeAggregateSignature(DataTypeKind signature_initialized = true; } - assert(prev_dtid < dtid); // Making sure that list is ordered properly + UAVCAN_ASSERT(prev_dtid < dtid); // Making sure that list is ordered properly prev_dtid++; while (prev_dtid < dtid) { inout_id_mask[prev_dtid++] = false; // Erasing bits for missing types } - assert(prev_dtid == dtid); + UAVCAN_ASSERT(prev_dtid == dtid); p = p->getNextListNode(); } @@ -245,13 +245,13 @@ void GlobalDataTypeRegistry::getDataTypeIDMask(DataTypeKind kind, DataTypeIDMask const List* list = selectList(kind); if (!list) { - assert(0); + UAVCAN_ASSERT(0); return; } Entry* p = list->get(); while (p) { - assert(p->descriptor.getKind() == kind); + UAVCAN_ASSERT(p->descriptor.getKind() == kind); mask[p->descriptor.getID().get()] = true; p = p->getNextListNode(); } diff --git a/libuavcan/src/node/uc_scheduler.cpp b/libuavcan/src/node/uc_scheduler.cpp index be22c21075..55ca4b1172 100644 --- a/libuavcan/src/node/uc_scheduler.cpp +++ b/libuavcan/src/node/uc_scheduler.cpp @@ -13,7 +13,7 @@ namespace uavcan */ void DeadlineHandler::startWithDeadline(MonotonicTime deadline) { - assert(!deadline.isZero()); + UAVCAN_ASSERT(!deadline.isZero()); stop(); deadline_ = deadline; scheduler_.getDeadlineScheduler().add(this); @@ -49,19 +49,19 @@ struct MonotonicDeadlineHandlerInsertionComparator void DeadlineScheduler::add(DeadlineHandler* mdh) { - assert(mdh); + UAVCAN_ASSERT(mdh); handlers_.insertBefore(mdh, MonotonicDeadlineHandlerInsertionComparator(mdh->getDeadline())); } void DeadlineScheduler::remove(DeadlineHandler* mdh) { - assert(mdh); + UAVCAN_ASSERT(mdh); handlers_.remove(mdh); } bool DeadlineScheduler::doesExist(const DeadlineHandler* mdh) const { - assert(mdh); + UAVCAN_ASSERT(mdh); const DeadlineHandler* p = handlers_.get(); #if UAVCAN_DEBUG MonotonicTime prev_deadline; @@ -96,7 +96,7 @@ MonotonicTime DeadlineScheduler::pollAndGetMonotonicTime(ISystemClock& sysclock) #if UAVCAN_DEBUG if (mdh->getNextListNode()) // Order check { - assert(mdh->getDeadline() <= mdh->getNextListNode()->getDeadline()); + UAVCAN_ASSERT(mdh->getDeadline() <= mdh->getNextListNode()->getDeadline()); } #endif @@ -109,7 +109,7 @@ MonotonicTime DeadlineScheduler::pollAndGetMonotonicTime(ISystemClock& sysclock) handlers_.remove(mdh); mdh->handleDeadline(ts); // This handler can be re-registered immediately } - assert(0); + UAVCAN_ASSERT(0); return MonotonicTime(); } @@ -156,7 +156,7 @@ int Scheduler::spin(MonotonicTime deadline) { if (inside_spin_) // Preventing recursive calls { - assert(0); + UAVCAN_ASSERT(0); return -ErrRecursiveCall; } inside_spin_ = true; diff --git a/libuavcan/src/node/uc_timer.cpp b/libuavcan/src/node/uc_timer.cpp index 24caa68694..0230198d86 100644 --- a/libuavcan/src/node/uc_timer.cpp +++ b/libuavcan/src/node/uc_timer.cpp @@ -12,7 +12,7 @@ namespace uavcan */ void TimerBase::handleDeadline(MonotonicTime current) { - assert(!isRunning()); + UAVCAN_ASSERT(!isRunning()); const MonotonicTime scheduled_time = getDeadline(); @@ -41,7 +41,7 @@ void TimerBase::startOneShotWithDelay(MonotonicDuration delay) void TimerBase::startPeriodic(MonotonicDuration period) { - assert(period < MonotonicDuration::getInfinite()); + UAVCAN_ASSERT(period < MonotonicDuration::getInfinite()); stop(); period_ = period; DeadlineHandler::startWithDelay(period); diff --git a/libuavcan/src/protocol/uc_data_type_info_provider.cpp b/libuavcan/src/protocol/uc_data_type_info_provider.cpp index a520795d46..38a0a023b5 100644 --- a/libuavcan/src/protocol/uc_data_type_info_provider.cpp +++ b/libuavcan/src/protocol/uc_data_type_info_provider.cpp @@ -78,7 +78,7 @@ void DataTypeInfoProvider::handleGetDataTypeInfoRequest(const protocol::GetDataT } else { - assert(0); // That means that GDTR somehow found a type of an unknown kind. The horror. + UAVCAN_ASSERT(0); // That means that GDTR somehow found a type of an unknown kind. The horror. } } @@ -99,11 +99,11 @@ int DataTypeInfoProvider::start() goto fail; } - assert(res >= 0); + UAVCAN_ASSERT(res >= 0); return res; fail: - assert(res < 0); + UAVCAN_ASSERT(res < 0); cats_srv_.stop(); gdti_srv_.stop(); return res; diff --git a/libuavcan/src/protocol/uc_global_time_sync_master.cpp b/libuavcan/src/protocol/uc_global_time_sync_master.cpp index 81f7216e3f..9fe1c495c3 100644 --- a/libuavcan/src/protocol/uc_global_time_sync_master.cpp +++ b/libuavcan/src/protocol/uc_global_time_sync_master.cpp @@ -21,7 +21,7 @@ int GlobalTimeSyncMaster::IfaceMaster::init() if (res >= 0) { TransferSender* const ts = pub_.getTransferSender(); - assert(ts != NULL); + UAVCAN_ASSERT(ts != NULL); ts->setIfaceMask(1 << iface_index_); ts->setCanIOFlags(CanIOFlagLoopback); } @@ -32,7 +32,7 @@ void GlobalTimeSyncMaster::IfaceMaster::setTxTimestamp(UtcTime ts) { if (ts.isZero()) { - assert(0); + UAVCAN_ASSERT(0); pub_.getNode().registerInternalFailure("GlobalTimeSyncMaster zero TX ts"); return; } @@ -47,12 +47,12 @@ void GlobalTimeSyncMaster::IfaceMaster::setTxTimestamp(UtcTime ts) int GlobalTimeSyncMaster::IfaceMaster::publish(TransferID tid, MonotonicTime current_time) { - assert(pub_.getTransferSender()->getCanIOFlags() == CanIOFlagLoopback); - assert(pub_.getTransferSender()->getIfaceMask() == (1 << iface_index_)); + UAVCAN_ASSERT(pub_.getTransferSender()->getCanIOFlags() == CanIOFlagLoopback); + UAVCAN_ASSERT(pub_.getTransferSender()->getIfaceMask() == (1 << iface_index_)); const MonotonicDuration since_prev_pub = current_time - iface_prev_pub_mono_; iface_prev_pub_mono_ = current_time; - assert(since_prev_pub.isPositive()); + UAVCAN_ASSERT(since_prev_pub.isPositive()); const bool long_period = since_prev_pub.toMSec() >= protocol::GlobalTimeSync::MAX_PUBLICATION_PERIOD_MS; protocol::GlobalTimeSync msg; @@ -82,7 +82,7 @@ void GlobalTimeSyncMaster::handleLoopbackFrame(const RxFrame& frame) } else { - assert(0); + UAVCAN_ASSERT(0); } } @@ -162,7 +162,7 @@ int GlobalTimeSyncMaster::publish() const MonotonicTime current_time = node_.getMonotonicTime(); { const MonotonicDuration since_prev_pub = current_time - prev_pub_mono_; - assert(since_prev_pub.isPositive()); + UAVCAN_ASSERT(since_prev_pub.isPositive()); if (since_prev_pub.toMSec() < protocol::GlobalTimeSync::MIN_PUBLICATION_PERIOD_MS) { UAVCAN_TRACE("GlobalTimeSyncMaster", "Publication skipped"); diff --git a/libuavcan/src/protocol/uc_global_time_sync_slave.cpp b/libuavcan/src/protocol/uc_global_time_sync_slave.cpp index f7b54a4d08..67fe307efe 100644 --- a/libuavcan/src/protocol/uc_global_time_sync_slave.cpp +++ b/libuavcan/src/protocol/uc_global_time_sync_slave.cpp @@ -11,7 +11,7 @@ namespace uavcan void GlobalTimeSyncSlave::adjustFromMsg(const ReceivedDataStructure& msg) { - assert(msg.prev_utc_usec > 0); + UAVCAN_ASSERT(msg.prev_utc_usec > 0); const UtcDuration adjustment = UtcTime::fromUSec(msg.prev_utc_usec) - prev_ts_utc_; UAVCAN_TRACE("GlobalTimeSyncSlave", "Adjustment: usec=%lli snid=%i iface=%i suppress=%i", @@ -42,7 +42,7 @@ void GlobalTimeSyncSlave::updateFromMsg(const ReceivedDataStructure& msg) { const MonotonicDuration since_prev_msg = msg.getMonotonicTimestamp() - prev_ts_mono_; - assert(!since_prev_msg.isNegative()); + UAVCAN_ASSERT(!since_prev_msg.isNegative()); const bool needs_init = !master_nid_.isValid() || prev_ts_mono_.isZero(); const bool switch_master = msg.getSrcNodeID() < master_nid_; diff --git a/libuavcan/src/protocol/uc_network_compat_checker.cpp b/libuavcan/src/protocol/uc_network_compat_checker.cpp index e82f8f4a33..4e0f9fe066 100644 --- a/libuavcan/src/protocol/uc_network_compat_checker.cpp +++ b/libuavcan/src/protocol/uc_network_compat_checker.cpp @@ -88,8 +88,8 @@ int NetworkCompatibilityChecker::checkOneNodeOneDataTypeKind(NodeID nid, DataTyp StaticAssert::check(); StaticAssert::check(); - assert(nid.isUnicast()); - assert(!cats_cln_.isPending()); + UAVCAN_ASSERT(nid.isUnicast()); + UAVCAN_ASSERT(!cats_cln_.isPending()); checking_dtkind_ = kind; protocol::ComputeAggregateTypeSignature::Request request; diff --git a/libuavcan/src/protocol/uc_node_status_monitor.cpp b/libuavcan/src/protocol/uc_node_status_monitor.cpp index bcffce097e..6bb5a6e81f 100644 --- a/libuavcan/src/protocol/uc_node_status_monitor.cpp +++ b/libuavcan/src/protocol/uc_node_status_monitor.cpp @@ -61,7 +61,7 @@ void NodeStatusMonitor::handleTimerEvent(const TimerEvent&) for (int i = 1; i <= NodeID::Max; i++) { const NodeID nid(i); - assert(nid.isUnicast()); + UAVCAN_ASSERT(nid.isUnicast()); Entry& entry = getEntry(nid); if (entry.time_since_last_update_ms100 >= 0 && entry.status_code != protocol::NodeStatus::STATUS_OFFLINE) @@ -97,7 +97,7 @@ void NodeStatusMonitor::forgetNode(NodeID node_id) } else { - assert(0); + UAVCAN_ASSERT(0); } } @@ -105,7 +105,7 @@ NodeStatusMonitor::NodeStatus NodeStatusMonitor::getNodeStatus(NodeID node_id) c { if (!node_id.isValid()) { - assert(0); + UAVCAN_ASSERT(0); return NodeStatus(); } NodeStatus status; @@ -126,7 +126,7 @@ NodeID NodeStatusMonitor::findNodeWithWorstStatus() const for (int i = 1; i <= NodeID::Max; i++) { const NodeID nid(i); - assert(nid.isUnicast()); + UAVCAN_ASSERT(nid.isUnicast()); const Entry& entry = getEntry(nid); if (entry.time_since_last_update_ms100 >= 0) { diff --git a/libuavcan/src/protocol/uc_node_status_provider.cpp b/libuavcan/src/protocol/uc_node_status_provider.cpp index c8d6b04816..983782ff98 100644 --- a/libuavcan/src/protocol/uc_node_status_provider.cpp +++ b/libuavcan/src/protocol/uc_node_status_provider.cpp @@ -18,10 +18,10 @@ bool NodeStatusProvider::isNodeInfoInitialized() const int NodeStatusProvider::publish() { const MonotonicDuration uptime = getNode().getMonotonicTime() - creation_timestamp_; - assert(uptime.isPositive()); + UAVCAN_ASSERT(uptime.isPositive()); node_info_.status.uptime_sec = uptime.toMSec() / 1000; - assert(node_info_.status.status_code <= protocol::NodeStatus::FieldTypes::status_code::max()); + UAVCAN_ASSERT(node_info_.status.status_code <= protocol::NodeStatus::FieldTypes::status_code::max()); return node_status_pub_.broadcast(node_info_.status); } @@ -50,7 +50,7 @@ void NodeStatusProvider::handleGetNodeInfoRequest(const protocol::GetNodeInfo::R protocol::GetNodeInfo::Response& rsp) { UAVCAN_TRACE("NodeStatusProvider", "Got GetNodeInfo request"); - assert(isNodeInfoInitialized()); + UAVCAN_ASSERT(isNodeInfoInitialized()); rsp = node_info_; } @@ -93,7 +93,7 @@ int NodeStatusProvider::startAndPublish() return res; fail: - assert(res < 0); + UAVCAN_ASSERT(res < 0); gdr_sub_.stop(); gni_srv_.stop(); TimerBase::stop(); diff --git a/libuavcan/src/protocol/uc_param_server.cpp b/libuavcan/src/protocol/uc_param_server.cpp index 7c2ae67816..0096239fa0 100644 --- a/libuavcan/src/protocol/uc_param_server.cpp +++ b/libuavcan/src/protocol/uc_param_server.cpp @@ -17,7 +17,7 @@ bool ParamServer::isValueNonEmpty(const protocol::param::Value& value) void ParamServer::handleGetSet(const protocol::param::GetSet::Request& in, protocol::param::GetSet::Response& out) { - assert(manager_ != NULL); + UAVCAN_ASSERT(manager_ != NULL); // Recover the name from index if (in.name.empty()) @@ -52,7 +52,7 @@ void ParamServer::handleGetSet(const protocol::param::GetSet::Request& in, proto void ParamServer::handleSaveErase(const protocol::param::SaveErase::Request& in, protocol::param::SaveErase::Response& out) { - assert(manager_ != NULL); + UAVCAN_ASSERT(manager_ != NULL); if (in.opcode == protocol::param::SaveErase::Request::OPCODE_SAVE) { diff --git a/libuavcan/src/transport/uc_can_io.cpp b/libuavcan/src/transport/uc_can_io.cpp index e3cc4570cd..00113ecf50 100644 --- a/libuavcan/src/transport/uc_can_io.cpp +++ b/libuavcan/src/transport/uc_can_io.cpp @@ -74,7 +74,7 @@ std::string CanTxQueue::Entry::toString() const } default: { - assert(0); + UAVCAN_ASSERT(0); str_qos = " "; break; } @@ -173,7 +173,7 @@ void CanTxQueue::push(const CanFrame& frame, MonotonicTime tx_deadline, Qos qos, return; // Seems that there is no memory at all. } Entry* entry = new (praw) Entry(frame, tx_deadline, qos, flags); - assert(entry); + UAVCAN_ASSERT(entry); queue_.insertBefore(entry, PriorityInsertionComparator(frame)); } @@ -203,7 +203,7 @@ void CanTxQueue::remove(Entry*& entry) { if (entry == NULL) { - assert(0); + UAVCAN_ASSERT(0); return; } queue_.remove(entry); @@ -225,11 +225,11 @@ bool CanTxQueue::topPriorityHigherOrEqual(const CanFrame& rhs_frame) const */ int CanIOManager::sendToIface(uint8_t iface_index, const CanFrame& frame, MonotonicTime tx_deadline, CanIOFlags flags) { - assert(iface_index < MaxCanIfaces); + UAVCAN_ASSERT(iface_index < MaxCanIfaces); ICanIface* const iface = driver_.getIface(iface_index); if (iface == NULL) { - assert(0); // Nonexistent interface + UAVCAN_ASSERT(0); // Nonexistent interface return -ErrLogic; } const int res = iface->send(frame, tx_deadline, flags); @@ -247,7 +247,7 @@ int CanIOManager::sendToIface(uint8_t iface_index, const CanFrame& frame, Monoto int CanIOManager::sendFromTxQueue(uint8_t iface_index) { - assert(iface_index < MaxCanIfaces); + UAVCAN_ASSERT(iface_index < MaxCanIfaces); CanTxQueue::Entry* entry = tx_queues_[iface_index]->peek(); if (entry == NULL) { @@ -317,7 +317,7 @@ CanIfacePerfCounters CanIOManager::getIfacePerfCounters(uint8_t iface_index) con ICanIface* const iface = driver_.getIface(iface_index); if (iface == NULL || iface_index >= MaxCanIfaces) { - assert(0); + UAVCAN_ASSERT(0); return CanIfacePerfCounters(); } CanIfacePerfCounters cnt; @@ -355,7 +355,7 @@ int CanIOManager::send(const CanFrame& frame, MonotonicTime tx_deadline, Monoton { return -ErrDriver; } - assert(masks.read == 0); + UAVCAN_ASSERT(masks.read == 0); } // Transmission @@ -446,13 +446,13 @@ int CanIOManager::receive(CanRxFrame& out_frame, MonotonicTime blocking_deadline ICanIface* const iface = driver_.getIface(i); if (iface == NULL) { - assert(0); // Nonexistent interface + UAVCAN_ASSERT(0); // Nonexistent interface continue; } const int res = iface->receive(out_frame, out_frame.ts_mono, out_frame.ts_utc, out_flags); if (res == 0) { - assert(0); // select() reported that iface has pending RX frames, but receive() returned none + UAVCAN_ASSERT(0); // select() reported that iface has pending RX frames, but receive() returned none continue; } out_frame.iface_index = i; diff --git a/libuavcan/src/transport/uc_dispatcher.cpp b/libuavcan/src/transport/uc_dispatcher.cpp index 29460c5cd6..4ce9bb3453 100644 --- a/libuavcan/src/transport/uc_dispatcher.cpp +++ b/libuavcan/src/transport/uc_dispatcher.cpp @@ -31,19 +31,19 @@ bool LoopbackFrameListenerBase::isListening() const */ void LoopbackFrameListenerRegistry::add(LoopbackFrameListenerBase* listener) { - assert(listener); + UAVCAN_ASSERT(listener); listeners_.insert(listener); } void LoopbackFrameListenerRegistry::remove(LoopbackFrameListenerBase* listener) { - assert(listener); + UAVCAN_ASSERT(listener); listeners_.remove(listener); } bool LoopbackFrameListenerRegistry::doesExist(const LoopbackFrameListenerBase* listener) const { - assert(listener); + UAVCAN_ASSERT(listener); const LoopbackFrameListenerBase* p = listeners_.get(); while (p) { @@ -180,7 +180,7 @@ void Dispatcher::handleFrame(const CanRxFrame& can_frame) } default: { - assert(0); + UAVCAN_ASSERT(0); break; } } @@ -192,10 +192,10 @@ void Dispatcher::handleLoopbackFrame(const CanRxFrame& can_frame) if (!frame.parse(can_frame)) { UAVCAN_TRACE("Dispatcher", "Invalid loopback CAN frame: %s", can_frame.toString().c_str()); - assert(0); // No way! + UAVCAN_ASSERT(0); // No way! return; } - assert(frame.getSrcNodeID() == getNodeID()); + UAVCAN_ASSERT(frame.getSrcNodeID() == getNodeID()); loopback_listeners_.invokeListeners(frame); } @@ -234,7 +234,7 @@ int Dispatcher::send(const Frame& frame, MonotonicTime tx_deadline, MonotonicTim { if (frame.getSrcNodeID() != getNodeID()) { - assert(0); + UAVCAN_ASSERT(0); return -ErrLogic; } @@ -242,7 +242,7 @@ int Dispatcher::send(const Frame& frame, MonotonicTime tx_deadline, MonotonicTim if (!frame.compile(can_frame)) { UAVCAN_TRACE("Dispatcher", "Unable to send: frame is malformed: %s", frame.toString().c_str()); - assert(0); + UAVCAN_ASSERT(0); return -ErrLogic; } return canio_.send(can_frame, tx_deadline, blocking_deadline, iface_mask, qos, flags); @@ -260,7 +260,7 @@ bool Dispatcher::registerMessageListener(TransferListenerBase* listener) { if (listener->getDataTypeDescriptor().getKind() != DataTypeKindMessage) { - assert(0); + UAVCAN_ASSERT(0); return false; } return lmsg_.add(listener, ListenerRegistry::ManyListeners); // Multiple subscribers are OK @@ -270,7 +270,7 @@ bool Dispatcher::registerServiceRequestListener(TransferListenerBase* listener) { if (listener->getDataTypeDescriptor().getKind() != DataTypeKindService) { - assert(0); + UAVCAN_ASSERT(0); return false; } return lsrv_req_.add(listener, ListenerRegistry::UniqueListener); // Only one server per data type @@ -280,7 +280,7 @@ bool Dispatcher::registerServiceResponseListener(TransferListenerBase* listener) { if (listener->getDataTypeDescriptor().getKind() != DataTypeKindService) { - assert(0); + UAVCAN_ASSERT(0); return false; } return lsrv_resp_.add(listener, ListenerRegistry::ManyListeners); // Multiple callers may call same srv diff --git a/libuavcan/src/transport/uc_frame.cpp b/libuavcan/src/transport/uc_frame.cpp index 20e9cfd525..58ad6ff945 100644 --- a/libuavcan/src/transport/uc_frame.cpp +++ b/libuavcan/src/transport/uc_frame.cpp @@ -27,7 +27,7 @@ int Frame::getMaxPayloadLen() const } default: { - assert(0); + UAVCAN_ASSERT(0); return -ErrLogic; } } @@ -61,7 +61,7 @@ bool Frame::parse(const CanFrame& can_frame) if (can_frame.dlc > sizeof(can_frame.data)) { - assert(0); // This is not a protocol error, so assert() is ok + UAVCAN_ASSERT(0); // This is not a protocol error, so UAVCAN_ASSERT() is ok return false; } @@ -124,7 +124,7 @@ bool Frame::compile(CanFrame& out_can_frame) const { if (!isValid()) { - assert(0); // This is an application error, so we need to maximize it. + UAVCAN_ASSERT(0); // This is an application error, so we need to maximize it. return false; } @@ -149,7 +149,7 @@ bool Frame::compile(CanFrame& out_can_frame) const case TransferTypeServiceRequest: case TransferTypeMessageUnicast: { - assert((payload_len_ + 1U) <= sizeof(out_can_frame.data)); + UAVCAN_ASSERT((payload_len_ + 1U) <= sizeof(out_can_frame.data)); out_can_frame.data[0] = dst_node_id_.get(); out_can_frame.dlc = payload_len_ + 1; (void)copy(payload_, payload_ + payload_len_, out_can_frame.data + 1); @@ -157,7 +157,7 @@ bool Frame::compile(CanFrame& out_can_frame) const } default: { - assert(0); + UAVCAN_ASSERT(0); return false; } } @@ -238,7 +238,7 @@ bool RxFrame::parse(const CanRxFrame& can_frame) } if (can_frame.ts_mono.isZero()) // Monotonic timestamps are mandatory. { - assert(0); // If it is not set, it's a driver failure. + UAVCAN_ASSERT(0); // If it is not set, it's a driver failure. return false; } ts_mono_ = can_frame.ts_mono; diff --git a/libuavcan/src/transport/uc_transfer.cpp b/libuavcan/src/transport/uc_transfer.cpp index 5a070939d6..51c850ea02 100644 --- a/libuavcan/src/transport/uc_transfer.cpp +++ b/libuavcan/src/transport/uc_transfer.cpp @@ -34,7 +34,7 @@ int TransferID::computeForwardDistance(TransferID rhs) const d += 1 << BitLen; } - assert(((get() + d) & Max) == rhs.get()); + UAVCAN_ASSERT(((get() + d) & Max) == rhs.get()); return d; } diff --git a/libuavcan/src/transport/uc_transfer_buffer.cpp b/libuavcan/src/transport/uc_transfer_buffer.cpp index ae5d4b8c45..192f43fdc2 100644 --- a/libuavcan/src/transport/uc_transfer_buffer.cpp +++ b/libuavcan/src/transport/uc_transfer_buffer.cpp @@ -47,7 +47,7 @@ void DynamicTransferBufferManagerEntry::Block::destroy(Block*& obj, IPoolAllocat void DynamicTransferBufferManagerEntry::Block::read(uint8_t*& outptr, unsigned target_offset, unsigned& total_offset, unsigned& left_to_read) { - assert(outptr); + UAVCAN_ASSERT(outptr); for (unsigned i = 0; (i < Block::Size) && (left_to_read > 0); i++, total_offset++) { if (total_offset >= target_offset) @@ -61,7 +61,7 @@ void DynamicTransferBufferManagerEntry::Block::read(uint8_t*& outptr, unsigned t void DynamicTransferBufferManagerEntry::Block::write(const uint8_t*& inptr, unsigned target_offset, unsigned& total_offset, unsigned& left_to_write) { - assert(inptr); + UAVCAN_ASSERT(inptr); for (unsigned i = 0; (i < Block::Size) && (left_to_write > 0); i++, total_offset++) { if (total_offset >= target_offset) @@ -118,7 +118,7 @@ int DynamicTransferBufferManagerEntry::read(unsigned offset, uint8_t* data, unsi { if (!data) { - assert(0); + UAVCAN_ASSERT(0); return -ErrInvalidParam; } if (offset >= max_write_pos_) @@ -129,7 +129,7 @@ int DynamicTransferBufferManagerEntry::read(unsigned offset, uint8_t* data, unsi { len = max_write_pos_ - offset; } - assert((offset + len) <= max_write_pos_); + UAVCAN_ASSERT((offset + len) <= max_write_pos_); // This shall be optimized. unsigned total_offset = 0; @@ -146,7 +146,7 @@ int DynamicTransferBufferManagerEntry::read(unsigned offset, uint8_t* data, unsi p = p->getNextListNode(); } - assert(left_to_read == 0); + UAVCAN_ASSERT(left_to_read == 0); return len; } @@ -154,7 +154,7 @@ int DynamicTransferBufferManagerEntry::write(unsigned offset, const uint8_t* dat { if (!data) { - assert(0); + UAVCAN_ASSERT(0); return -ErrInvalidParam; } @@ -166,7 +166,7 @@ int DynamicTransferBufferManagerEntry::write(unsigned offset, const uint8_t* dat { len = max_size_ - offset; } - assert((offset + len) <= max_size_); + UAVCAN_ASSERT((offset + len) <= max_size_); unsigned total_offset = 0; unsigned left_to_write = len; @@ -190,7 +190,7 @@ int DynamicTransferBufferManagerEntry::write(unsigned offset, const uint8_t* dat while (left_to_write > 0) { // cppcheck-suppress nullPointer - assert(p == NULL); + UAVCAN_ASSERT(p == NULL); // Allocating the chunk Block* new_block = Block::instantiate(allocator_); @@ -201,7 +201,7 @@ int DynamicTransferBufferManagerEntry::write(unsigned offset, const uint8_t* dat // Appending the chain with the new block if (last_written_block != NULL) { - assert(last_written_block->getNextListNode() == NULL); // Because it is last in the chain + UAVCAN_ASSERT(last_written_block->getNextListNode() == NULL); // Because it is last in the chain last_written_block->setNextListNode(new_block); new_block->setNextListNode(NULL); } @@ -227,7 +227,7 @@ int StaticTransferBufferImpl::read(unsigned offset, uint8_t* data, unsigned len) { if (!data) { - assert(0); + UAVCAN_ASSERT(0); return -ErrInvalidParam; } if (offset >= max_write_pos_) @@ -238,7 +238,7 @@ int StaticTransferBufferImpl::read(unsigned offset, uint8_t* data, unsigned len) { len = max_write_pos_ - offset; } - assert((offset + len) <= max_write_pos_); + UAVCAN_ASSERT((offset + len) <= max_write_pos_); (void)copy(data_ + offset, data_ + offset + len, data); return len; } @@ -247,7 +247,7 @@ int StaticTransferBufferImpl::write(unsigned offset, const uint8_t* data, unsign { if (!data) { - assert(0); + UAVCAN_ASSERT(0); return -ErrInvalidParam; } if (offset >= size_) @@ -258,7 +258,7 @@ int StaticTransferBufferImpl::write(unsigned offset, const uint8_t* data, unsign { len = size_ - offset; } - assert((offset + len) <= size_); + UAVCAN_ASSERT((offset + len) <= size_); (void)copy(data, data + len, data_ + offset); max_write_pos_ = max(offset + len, unsigned(max_write_pos_)); return len; @@ -294,7 +294,7 @@ bool StaticTransferBufferManagerEntryImpl::migrateFrom(const TransferBufferManag { if (tbme == NULL || tbme->isEmpty()) { - assert(0); + UAVCAN_ASSERT(0); return false; } @@ -347,7 +347,7 @@ DynamicTransferBufferManagerEntry* TransferBufferManagerImpl::findFirstDynamic(c DynamicTransferBufferManagerEntry* dyn = dynamic_buffers_.get(); while (dyn) { - assert(!dyn->isEmpty()); + UAVCAN_ASSERT(!dyn->isEmpty()); if (dyn->getKey() == key) { return dyn; @@ -367,11 +367,11 @@ void TransferBufferManagerImpl::optimizeStorage() break; } DynamicTransferBufferManagerEntry* dyn = dynamic_buffers_.get(); - assert(dyn); - assert(!dyn->isEmpty()); + UAVCAN_ASSERT(dyn); + UAVCAN_ASSERT(!dyn->isEmpty()); if (sb->migrateFrom(dyn)) { - assert(!dyn->isEmpty()); + UAVCAN_ASSERT(!dyn->isEmpty()); UAVCAN_TRACE("TransferBufferManager", "Storage optimization: Migrated %s", dyn->getKey().toString().c_str()); dynamic_buffers_.remove(dyn); @@ -384,7 +384,7 @@ void TransferBufferManagerImpl::optimizeStorage() */ UAVCAN_TRACE("TransferBufferManager", "Storage optimization: MIGRATION FAILURE %s MAXSIZE %u", dyn->getKey().toString().c_str(), max_buf_size_); - assert(0); + UAVCAN_ASSERT(0); sb->reset(); break; } @@ -407,7 +407,7 @@ ITransferBuffer* TransferBufferManagerImpl::access(const TransferBufferManagerKe { if (key.isEmpty()) { - assert(0); + UAVCAN_ASSERT(0); return NULL; } TransferBufferManagerEntry* tbme = findFirstStatic(key); @@ -422,7 +422,7 @@ ITransferBuffer* TransferBufferManagerImpl::create(const TransferBufferManagerKe { if (key.isEmpty()) { - assert(0); + UAVCAN_ASSERT(0); return NULL; } remove(key); @@ -449,7 +449,7 @@ ITransferBuffer* TransferBufferManagerImpl::create(const TransferBufferManagerKe if (tbme) { - assert(tbme->isEmpty()); + UAVCAN_ASSERT(tbme->isEmpty()); tbme->reset(key); } return tbme; @@ -457,7 +457,7 @@ ITransferBuffer* TransferBufferManagerImpl::create(const TransferBufferManagerKe void TransferBufferManagerImpl::remove(const TransferBufferManagerKey& key) { - assert(!key.isEmpty()); + UAVCAN_ASSERT(!key.isEmpty()); TransferBufferManagerEntry* const tbme = findFirstStatic(key); if (tbme) diff --git a/libuavcan/src/transport/uc_transfer_listener.cpp b/libuavcan/src/transport/uc_transfer_listener.cpp index 095a976036..de6c72c910 100644 --- a/libuavcan/src/transport/uc_transfer_listener.cpp +++ b/libuavcan/src/transport/uc_transfer_listener.cpp @@ -14,7 +14,7 @@ namespace uavcan */ int IncomingTransfer::write(unsigned, const uint8_t*, unsigned) { - assert(0); // Incoming transfer container is read-only + UAVCAN_ASSERT(0); // Incoming transfer container is read-only return -ErrLogic; } @@ -27,14 +27,14 @@ SingleFrameIncomingTransfer::SingleFrameIncomingTransfer(const RxFrame& frm) , payload_(frm.getPayloadPtr()) , payload_len_(frm.getPayloadLen()) { - assert(frm.isValid()); + UAVCAN_ASSERT(frm.isValid()); } int SingleFrameIncomingTransfer::read(unsigned offset, uint8_t* data, unsigned len) const { if (data == NULL) { - assert(0); + UAVCAN_ASSERT(0); return -ErrInvalidParam; } if (offset >= payload_len_) @@ -45,7 +45,7 @@ int SingleFrameIncomingTransfer::read(unsigned offset, uint8_t* data, unsigned l { len = payload_len_ - offset; } - assert((offset + len) <= payload_len_); + UAVCAN_ASSERT((offset + len) <= payload_len_); (void)copy(payload_ + offset, payload_ + offset + len, data); return len; } @@ -59,8 +59,8 @@ MultiFrameIncomingTransfer::MultiFrameIncomingTransfer(MonotonicTime ts_mono, Ut last_frame.getSrcNodeID(), last_frame.getIfaceIndex()) , buf_acc_(tba) { - assert(last_frame.isValid()); - assert(last_frame.isLast()); + UAVCAN_ASSERT(last_frame.isValid()); + UAVCAN_ASSERT(last_frame.isLast()); } int MultiFrameIncomingTransfer::read(unsigned offset, uint8_t* data, unsigned len) const @@ -166,7 +166,7 @@ void TransferListenerBase::handleReception(TransferReceiver& receiver, const RxF } default: { - assert(0); + UAVCAN_ASSERT(0); break; } } @@ -175,7 +175,7 @@ void TransferListenerBase::handleReception(TransferReceiver& receiver, const RxF void TransferListenerBase::cleanup(MonotonicTime ts) { receivers_.removeWhere(TimedOutReceiverPredicate(ts, bufmgr_)); - assert(receivers_.isEmpty() ? bufmgr_.isEmpty() : 1); + UAVCAN_ASSERT(receivers_.isEmpty() ? bufmgr_.isEmpty() : 1); } void TransferListenerBase::handleFrame(const RxFrame& frame) diff --git a/libuavcan/src/transport/uc_transfer_receiver.cpp b/libuavcan/src/transport/uc_transfer_receiver.cpp index 0ae5598ab1..7fff829a0f 100644 --- a/libuavcan/src/transport/uc_transfer_receiver.cpp +++ b/libuavcan/src/transport/uc_transfer_receiver.cpp @@ -24,7 +24,7 @@ void TransferReceiver::registerError() const } else { - assert(0); + UAVCAN_ASSERT(0); } } @@ -44,7 +44,7 @@ TransferReceiver::TidRelation TransferReceiver::getTidRelation(const RxFrame& fr void TransferReceiver::updateTransferTimings() { - assert(!this_transfer_ts_.isZero()); + UAVCAN_ASSERT(!this_transfer_ts_.isZero()); const MonotonicTime prev_prev_ts = prev_transfer_ts_; prev_transfer_ts_ = this_transfer_ts_; diff --git a/libuavcan/src/transport/uc_transfer_sender.cpp b/libuavcan/src/transport/uc_transfer_sender.cpp index 712e8202bd..f91e48b5e3 100644 --- a/libuavcan/src/transport/uc_transfer_sender.cpp +++ b/libuavcan/src/transport/uc_transfer_sender.cpp @@ -33,13 +33,13 @@ int TransferSender::send(const uint8_t* payload, int payload_len, MonotonicTime const int res = frame.setPayload(payload, payload_len); if (res != payload_len) { - assert(0); + UAVCAN_ASSERT(0); UAVCAN_TRACE("TransferSender", "Frame payload write failure, %i", res); registerError(); return (res < 0) ? res : -ErrLogic; } frame.makeLast(); - assert(frame.isLast() && frame.isFirst()); + UAVCAN_ASSERT(frame.isLast() && frame.isFirst()); return dispatcher_.send(frame, tx_deadline, blocking_deadline, qos_, flags_, iface_mask_); } else // Multi Frame Transfer @@ -64,7 +64,7 @@ int TransferSender::send(const uint8_t* payload, int payload_len, MonotonicTime return write_res; } offset = write_res - 2; - assert(payload_len > offset); + UAVCAN_ASSERT(payload_len > offset); } int next_frame_index = 1; @@ -93,7 +93,7 @@ int TransferSender::send(const uint8_t* payload, int payload_len, MonotonicTime } offset += write_res; - assert(offset <= payload_len); + UAVCAN_ASSERT(offset <= payload_len); if (offset >= payload_len) { frame.makeLast(); @@ -101,7 +101,7 @@ int TransferSender::send(const uint8_t* payload, int payload_len, MonotonicTime } } - assert(0); + UAVCAN_ASSERT(0); return -ErrLogic; // Return path analysis is apparently broken. There should be no warning, this 'return' is unreachable. } @@ -110,7 +110,7 @@ int TransferSender::send(const uint8_t* payload, int payload_len, MonotonicTime { const OutgoingTransferRegistryKey otr_key(data_type_.getID(), transfer_type, dst_node_id); - assert(!tx_deadline.isZero()); + UAVCAN_ASSERT(!tx_deadline.isZero()); const MonotonicTime otr_deadline = tx_deadline + max_transfer_interval_; TransferID* const tid = dispatcher_.getOutgoingTransferRegistry().accessOrCreate(otr_key, otr_deadline); diff --git a/libuavcan/src/uc_data_type.cpp b/libuavcan/src/uc_data_type.cpp index c90509e2f6..1e0453eb15 100644 --- a/libuavcan/src/uc_data_type.cpp +++ b/libuavcan/src/uc_data_type.cpp @@ -36,7 +36,7 @@ void DataTypeSignatureCRC::add(uint8_t byte) void DataTypeSignatureCRC::add(const uint8_t* bytes, unsigned len) { - assert(bytes); + UAVCAN_ASSERT(bytes); while (len--) { add(*bytes++); @@ -106,7 +106,7 @@ std::string DataTypeDescriptor::toString() const } default: { - assert(0); + UAVCAN_ASSERT(0); break; } } diff --git a/libuavcan/src/uc_dynamic_memory.cpp b/libuavcan/src/uc_dynamic_memory.cpp index 6e8564aff1..d85eca5317 100644 --- a/libuavcan/src/uc_dynamic_memory.cpp +++ b/libuavcan/src/uc_dynamic_memory.cpp @@ -26,7 +26,7 @@ void LimitedPoolAllocator::deallocate(const void* ptr) { allocator_.deallocate(ptr); - assert(used_blocks_ > 0); + UAVCAN_ASSERT(used_blocks_ > 0); if (used_blocks_ > 0) { used_blocks_--; diff --git a/libuavcan/src/uc_error.cpp b/libuavcan/src/uc_error.cpp index bfa15bc9f0..59b1aad88b 100644 --- a/libuavcan/src/uc_error.cpp +++ b/libuavcan/src/uc_error.cpp @@ -23,7 +23,7 @@ void handleFatalError(const char* msg) throw std::runtime_error(msg); #else (void)msg; - assert(0); + UAVCAN_ASSERT(0); std::abort(); #endif }