Coverity scan code annotations and modeling file

This commit is contained in:
Pavel Kirienko
2014-04-18 15:16:22 +04:00
parent c17a2bbd5b
commit b5f67403dd
5 changed files with 58 additions and 0 deletions
@@ -23,7 +23,9 @@ class UAVCAN_EXPORT IPoolAllocator
public:
virtual ~IPoolAllocator() { }
// coverity[+alloc]
virtual void* allocate(std::size_t size) = 0;
// coverity[+free : arg-0]
virtual void deallocate(const void* ptr) = 0;
virtual bool isInPool(const void* ptr) const = 0;
@@ -53,7 +55,9 @@ public:
bool addPool(IPoolAllocator* pool);
// coverity[+alloc]
void* allocate(std::size_t size);
// coverity[+free : arg-0]
void deallocate(const void* ptr);
bool isInPool(const void* ptr) const;
@@ -86,7 +90,9 @@ public:
PoolAllocator();
// coverity[+alloc]
void* allocate(std::size_t size);
// coverity[+free : arg-0]
void deallocate(const void* ptr);
bool isInPool(const void* ptr) const;
@@ -114,7 +120,9 @@ public:
assert(max_blocks_ > 0);
}
// coverity[+alloc]
void* allocate(std::size_t size);
// coverity[+free : arg-0]
void deallocate(const void* ptr);
bool isInPool(const void* ptr) const;
@@ -232,6 +240,7 @@ PoolAllocator<PoolSize, BlockSize>::PoolAllocator()
std::memset(pool_.bytes, 0, PoolSize);
for (unsigned i = 0; (i + 1) < (NumBlocks - 1 + 1); i++) // -Werror=type-limits
{
// coverity[dead_error_line : FALSE]
free_list_[i].next = free_list_ + i + 1;
}
free_list_[NumBlocks - 1].next = NULL;
+1
View File
@@ -36,6 +36,7 @@ enum
__attribute__ ((noreturn))
#endif
UAVCAN_EXPORT
// coverity[+kill]
void handleFatalError(const char* msg);
}
@@ -360,6 +360,7 @@ class UAVCAN_EXPORT Array : public ArrayImpl<T, ArrayMode, MaxSize_>
#if UAVCAN_CPP_VERSION >= UAVCAN_CPP11
const bool nan = std::isnan(*it);
#else
// coverity[same_on_both_sides : FALSE]
const bool nan = (*it) != (*it);
#endif
if (!nan)
@@ -78,7 +78,9 @@ private:
static void validate()
{
StaticAssert<(BitLen <= (sizeof(StorageType) * 8))>::check();
// coverity[result_independent_of_operands : FALSE]
assert(max() <= std::numeric_limits<StorageType>::max());
// coverity[result_independent_of_operands : FALSE]
assert(min() >= std::numeric_limits<StorageType>::min());
}