mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 04:13:34 +08:00
libuavcan core now uses UAVCAN_ASSERT() instead of assert() (autoreplace)
This commit is contained in:
@@ -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_; }
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <unsigned MaxPools>
|
||||
bool PoolManager<MaxPools>::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<MaxPools>::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<PoolSize, BlockSize>::getNumFreeBlocks() const
|
||||
while (p)
|
||||
{
|
||||
num++;
|
||||
assert(num <= NumBlocks);
|
||||
UAVCAN_ASSERT(num <= NumBlocks);
|
||||
p = p->next;
|
||||
}
|
||||
return num;
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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<IsStringLike>::check();
|
||||
assert(size() < (MaxSize + 1));
|
||||
UAVCAN_ASSERT(size() < (MaxSize + 1));
|
||||
const_cast<BufferType&>(data_)[size()] = 0; // Ad-hoc string termination
|
||||
return reinterpret_cast<const char*>(data_);
|
||||
}
|
||||
@@ -245,7 +245,7 @@ class UAVCAN_EXPORT Array : public ArrayImpl<T, ArrayMode, MaxSize_>
|
||||
|
||||
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<T, ArrayMode, MaxSize_>
|
||||
|
||||
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<T, ArrayMode, MaxSize_>
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,9 +92,9 @@ private:
|
||||
{
|
||||
StaticAssert<(BitLen <= (sizeof(StorageType) * 8))>::check();
|
||||
// coverity[result_independent_of_operands : FALSE]
|
||||
assert(max() <= NumericTraits<StorageType>::max());
|
||||
UAVCAN_ASSERT(max() <= NumericTraits<StorageType>::max());
|
||||
// coverity[result_independent_of_operands : FALSE]
|
||||
assert(min() >= NumericTraits<StorageType>::min());
|
||||
UAVCAN_ASSERT(min() >= NumericTraits<StorageType>::min());
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<DataSpec, DataStruct>::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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -234,7 +234,7 @@ int Node<MemPoolSize_, OutgoingTransferRegistryStaticEntries, OutgoingTransferMa
|
||||
started_ = res >= 0;
|
||||
return res;
|
||||
fail:
|
||||
assert(res < 0);
|
||||
UAVCAN_ASSERT(res < 0);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<DataTypeKind(DataType::DataTypeKind) == DataTypeKindMessage>::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);
|
||||
|
||||
@@ -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<DataType_, Callback_>::invokeCallback(ServiceCallResultType&
|
||||
template <typename DataType_, typename Callback_>
|
||||
void ServiceClient<DataType_, Callback_>::handleReceivedDataStruct(ReceivedDataStructure<ResponseType>& response)
|
||||
{
|
||||
assert(response.getTransferType() == TransferTypeServiceResponse);
|
||||
UAVCAN_ASSERT(response.getTransferType() == TransferTypeServiceResponse);
|
||||
const TransferListenerType* const listener = SubscriberType::getTransferListener();
|
||||
if (listener)
|
||||
{
|
||||
@@ -205,7 +205,7 @@ void ServiceClient<DataType_, Callback_>::handleReceivedDataStruct(ReceivedDataS
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
UAVCAN_ASSERT(0);
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
@@ -227,7 +227,7 @@ void ServiceClient<DataType_, Callback_>::handleDeadline(MonotonicTime)
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
UAVCAN_ASSERT(0);
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
@@ -272,7 +272,7 @@ int ServiceClient<DataType_, Callback_>::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;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ private:
|
||||
|
||||
void handleReceivedDataStruct(ReceivedDataStructure<RequestType>& request)
|
||||
{
|
||||
assert(request.getTransferType() == TransferTypeServiceRequest);
|
||||
UAVCAN_ASSERT(request.getTransferType() == TransferTypeServiceRequest);
|
||||
if (try_implicit_cast<bool>(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<DataTypeKind(DataType::DataTypeKind) == DataTypeKindService>::check();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<Entry>::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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
|
||||
void add(const uint8_t* bytes, unsigned len)
|
||||
{
|
||||
assert(bytes);
|
||||
UAVCAN_ASSERT(bytes);
|
||||
while (len--)
|
||||
{
|
||||
add(*bytes++);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 <int NumStaticEntries>
|
||||
TransferID* OutgoingTransferRegistry<NumStaticEntries>::accessOrCreate(const OutgoingTransferRegistryKey& key,
|
||||
MonotonicTime new_deadline)
|
||||
{
|
||||
assert(!new_deadline.isZero());
|
||||
UAVCAN_ASSERT(!new_deadline.isZero());
|
||||
Value* p = map_.access(key);
|
||||
if (p == NULL)
|
||||
{
|
||||
|
||||
@@ -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_; }
|
||||
|
||||
@@ -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_); }
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class UAVCAN_EXPORT BitSet
|
||||
{
|
||||
if (inout_pos >= NumBits)
|
||||
{
|
||||
assert(0);
|
||||
UAVCAN_ASSERT(0);
|
||||
inout_pos = NumBits - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ unsigned LinkedListRoot<T>::getLength() const
|
||||
template <typename T>
|
||||
void LinkedListRoot<T>::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 <typename T>
|
||||
template <typename Predicate>
|
||||
void LinkedListRoot<T>::insertBefore(T* node, Predicate predicate)
|
||||
{
|
||||
assert(node);
|
||||
UAVCAN_ASSERT(node);
|
||||
remove(node);
|
||||
|
||||
if (root_ == NULL || predicate(root_))
|
||||
|
||||
@@ -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<Key, Value>::compact()
|
||||
template <typename Key, typename Value>
|
||||
Value* MapBase<Key, Value>::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<Key, Value>::access(const Key& key)
|
||||
template <typename Key, typename Value>
|
||||
Value* MapBase<Key, Value>::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<Key, Value>::insert(const Key& key, const Value& value)
|
||||
template <typename Key, typename Value>
|
||||
void MapBase<Key, Value>::remove(const Key& key)
|
||||
{
|
||||
assert(!(key == Key()));
|
||||
UAVCAN_ASSERT(!(key == Key()));
|
||||
KVPair* const kv = find(key);
|
||||
if (kv)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ int GenericSubscriberBase::genericStart(TransferListenerBase* listener,
|
||||
{
|
||||
if (listener == NULL)
|
||||
{
|
||||
assert(0);
|
||||
UAVCAN_ASSERT(0);
|
||||
return -ErrLogic;
|
||||
}
|
||||
stop(listener);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace uavcan
|
||||
|
||||
void GlobalTimeSyncSlave::adjustFromMsg(const ReceivedDataStructure<protocol::GlobalTimeSync>& 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<protocol::Gl
|
||||
void GlobalTimeSyncSlave::processMsg(const ReceivedDataStructure<protocol::GlobalTimeSync>& 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_;
|
||||
|
||||
@@ -88,8 +88,8 @@ int NetworkCompatibilityChecker::checkOneNodeOneDataTypeKind(NodeID nid, DataTyp
|
||||
StaticAssert<DataTypeKindMessage == int(protocol::DataTypeKind::MESSAGE)>::check();
|
||||
StaticAssert<DataTypeKindService == int(protocol::DataTypeKind::SERVICE)>::check();
|
||||
|
||||
assert(nid.isUnicast());
|
||||
assert(!cats_cln_.isPending());
|
||||
UAVCAN_ASSERT(nid.isUnicast());
|
||||
UAVCAN_ASSERT(!cats_cln_.isPending());
|
||||
|
||||
checking_dtkind_ = kind;
|
||||
protocol::ComputeAggregateTypeSignature::Request request;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -74,7 +74,7 @@ std::string CanTxQueue::Entry::toString() const
|
||||
}
|
||||
default:
|
||||
{
|
||||
assert(0);
|
||||
UAVCAN_ASSERT(0);
|
||||
str_qos = "<?WTF?> ";
|
||||
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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_--;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user