From 5cd0aff0d3b4e735d85b160525ebc4ba952bf7ac Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sun, 20 Apr 2014 21:33:51 +0400 Subject: [PATCH] GDTR list integrity check (debug builds only) --- libuavcan/src/node/uc_global_data_type_registry.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libuavcan/src/node/uc_global_data_type_registry.cpp b/libuavcan/src/node/uc_global_data_type_registry.cpp index 1af1c8ab08..fdf0b94921 100644 --- a/libuavcan/src/node/uc_global_data_type_registry.cpp +++ b/libuavcan/src/node/uc_global_data_type_registry.cpp @@ -95,9 +95,20 @@ GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::registImpl(Entry* d p = p->getNextListNode(); } } +#if UAVCAN_DEBUG + const unsigned len_before = list->getLength(); +#endif list->insertBefore(dtd, EntryInsertionComparator(dtd)); #if UAVCAN_DEBUG + { // List integrity check + const unsigned len_after = list->getLength(); + if (len_before >= len_after) + { + assert(0); + std::abort(); + } + } { // Order check Entry* p = list->get(); int id = -1;