mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 04:53:34 +08:00
Added -Wzero-as-null-pointer-constant, replaced NULL --> UAVCAN_NULLPTR. All changes are automatic, no manual edits to the library code.
This commit is contained in:
@@ -77,7 +77,7 @@ struct HasIsCloseMethod
|
||||
|
||||
template <typename U, typename R> static NotApplicable test(...);
|
||||
|
||||
enum { Result = sizeof(test<This, Rhs>(NULL)) };
|
||||
enum { Result = sizeof(test<This, Rhs>(UAVCAN_NULLPTR)) };
|
||||
};
|
||||
|
||||
/// First stage: bool L::isClose(R)
|
||||
|
||||
@@ -60,13 +60,13 @@ class UAVCAN_EXPORT LazyConstructor
|
||||
|
||||
public:
|
||||
LazyConstructor()
|
||||
: ptr_(NULL)
|
||||
: ptr_(UAVCAN_NULLPTR)
|
||||
{
|
||||
fill(data_.pool, data_.pool + sizeof(T), uint8_t(0));
|
||||
}
|
||||
|
||||
LazyConstructor(const LazyConstructor<T>& rhs) // Implicit
|
||||
: ptr_(NULL)
|
||||
: ptr_(UAVCAN_NULLPTR)
|
||||
{
|
||||
fill(data_.pool, data_.pool + sizeof(T), uint8_t(0));
|
||||
if (rhs)
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool isConstructed() const { return ptr_ != NULL; }
|
||||
bool isConstructed() const { return ptr_ != UAVCAN_NULLPTR; }
|
||||
|
||||
operator T*() const { return ptr_; }
|
||||
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
{
|
||||
ptr_->~T();
|
||||
}
|
||||
ptr_ = NULL;
|
||||
ptr_ = UAVCAN_NULLPTR;
|
||||
fill(data_.pool, data_.pool + sizeof(T), uint8_t(0));
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class UAVCAN_EXPORT LinkedListNode
|
||||
|
||||
protected:
|
||||
LinkedListNode()
|
||||
: next_(NULL)
|
||||
: next_(UAVCAN_NULLPTR)
|
||||
{ }
|
||||
|
||||
~LinkedListNode() { }
|
||||
@@ -46,11 +46,11 @@ class UAVCAN_EXPORT LinkedListRoot
|
||||
|
||||
public:
|
||||
LinkedListRoot()
|
||||
: root_(NULL)
|
||||
: root_(UAVCAN_NULLPTR)
|
||||
{ }
|
||||
|
||||
T* get() const { return root_; }
|
||||
bool isEmpty() const { return get() == NULL; }
|
||||
bool isEmpty() const { return get() == UAVCAN_NULLPTR; }
|
||||
|
||||
/**
|
||||
* Complexity: O(N)
|
||||
@@ -100,7 +100,7 @@ unsigned LinkedListRoot<T>::getLength() const
|
||||
template <typename T>
|
||||
void LinkedListRoot<T>::insert(T* node)
|
||||
{
|
||||
if (node == NULL)
|
||||
if (node == UAVCAN_NULLPTR)
|
||||
{
|
||||
UAVCAN_ASSERT(0);
|
||||
return;
|
||||
@@ -114,7 +114,7 @@ template <typename T>
|
||||
template <typename Predicate>
|
||||
void LinkedListRoot<T>::insertBefore(T* node, Predicate predicate)
|
||||
{
|
||||
if (node == NULL)
|
||||
if (node == UAVCAN_NULLPTR)
|
||||
{
|
||||
UAVCAN_ASSERT(0);
|
||||
return;
|
||||
@@ -122,7 +122,7 @@ void LinkedListRoot<T>::insertBefore(T* node, Predicate predicate)
|
||||
|
||||
remove(node);
|
||||
|
||||
if (root_ == NULL || predicate(root_))
|
||||
if (root_ == UAVCAN_NULLPTR || predicate(root_))
|
||||
{
|
||||
node->setNextListNode(root_);
|
||||
root_ = node;
|
||||
@@ -146,7 +146,7 @@ void LinkedListRoot<T>::insertBefore(T* node, Predicate predicate)
|
||||
template <typename T>
|
||||
void LinkedListRoot<T>::remove(const T* node)
|
||||
{
|
||||
if (root_ == NULL || node == NULL)
|
||||
if (root_ == UAVCAN_NULLPTR || node == UAVCAN_NULLPTR)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,20 +66,20 @@ private:
|
||||
static KVGroup* instantiate(IPoolAllocator& allocator)
|
||||
{
|
||||
void* const praw = allocator.allocate(sizeof(KVGroup));
|
||||
if (praw == NULL)
|
||||
if (praw == UAVCAN_NULLPTR)
|
||||
{
|
||||
return NULL;
|
||||
return UAVCAN_NULLPTR;
|
||||
}
|
||||
return new (praw) KVGroup();
|
||||
}
|
||||
|
||||
static void destroy(KVGroup*& obj, IPoolAllocator& allocator)
|
||||
{
|
||||
if (obj != NULL)
|
||||
if (obj != UAVCAN_NULLPTR)
|
||||
{
|
||||
obj->~KVGroup();
|
||||
allocator.deallocate(obj);
|
||||
obj = NULL;
|
||||
obj = UAVCAN_NULLPTR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ private:
|
||||
return kvs + i;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return UAVCAN_NULLPTR;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
/**
|
||||
* Complexity is O(1).
|
||||
*/
|
||||
bool isEmpty() const { return find(YesPredicate()) == NULL; }
|
||||
bool isEmpty() const { return find(YesPredicate()) == UAVCAN_NULLPTR; }
|
||||
|
||||
/**
|
||||
* Complexity is O(N).
|
||||
@@ -193,7 +193,7 @@ typename Map<Key, Value>::KVPair* Map<Key, Value>::findKey(const Key& key)
|
||||
}
|
||||
p = p->getNextListNode();
|
||||
}
|
||||
return NULL;
|
||||
return UAVCAN_NULLPTR;
|
||||
}
|
||||
|
||||
template <typename Key, typename Value>
|
||||
@@ -226,7 +226,7 @@ Value* Map<Key, Value>::access(const Key& key)
|
||||
{
|
||||
UAVCAN_ASSERT(!(key == Key()));
|
||||
KVPair* const kv = findKey(key);
|
||||
return kv ? &kv->value : NULL;
|
||||
return kv ? &kv->value : UAVCAN_NULLPTR;
|
||||
}
|
||||
|
||||
template <typename Key, typename Value>
|
||||
@@ -243,9 +243,9 @@ Value* Map<Key, Value>::insert(const Key& key, const Value& value)
|
||||
}
|
||||
|
||||
KVGroup* const kvg = KVGroup::instantiate(allocator_);
|
||||
if (kvg == NULL)
|
||||
if (kvg == UAVCAN_NULLPTR)
|
||||
{
|
||||
return NULL;
|
||||
return UAVCAN_NULLPTR;
|
||||
}
|
||||
list_.insert(kvg);
|
||||
kvg->kvs[0] = KVPair(key, value);
|
||||
@@ -271,7 +271,7 @@ void Map<Key, Value>::removeAllWhere(Predicate predicate)
|
||||
unsigned num_removed = 0;
|
||||
|
||||
KVGroup* p = list_.get();
|
||||
while (p != NULL)
|
||||
while (p != UAVCAN_NULLPTR)
|
||||
{
|
||||
KVGroup* const next_group = p->getNextListNode();
|
||||
|
||||
@@ -302,7 +302,7 @@ template <typename Predicate>
|
||||
const Key* Map<Key, Value>::find(Predicate predicate) const
|
||||
{
|
||||
KVGroup* p = list_.get();
|
||||
while (p != NULL)
|
||||
while (p != UAVCAN_NULLPTR)
|
||||
{
|
||||
KVGroup* const next_group = p->getNextListNode();
|
||||
|
||||
@@ -320,7 +320,7 @@ const Key* Map<Key, Value>::find(Predicate predicate) const
|
||||
|
||||
p = next_group;
|
||||
}
|
||||
return NULL;
|
||||
return UAVCAN_NULLPTR;
|
||||
}
|
||||
|
||||
template <typename Key, typename Value>
|
||||
@@ -334,7 +334,7 @@ typename Map<Key, Value>::KVPair* Map<Key, Value>::getByIndex(unsigned index)
|
||||
{
|
||||
// Slowly crawling through the dynamic storage
|
||||
KVGroup* p = list_.get();
|
||||
while (p != NULL)
|
||||
while (p != UAVCAN_NULLPTR)
|
||||
{
|
||||
KVGroup* const next_group = p->getNextListNode();
|
||||
|
||||
@@ -354,7 +354,7 @@ typename Map<Key, Value>::KVPair* Map<Key, Value>::getByIndex(unsigned index)
|
||||
p = next_group;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return UAVCAN_NULLPTR;
|
||||
}
|
||||
|
||||
template <typename Key, typename Value>
|
||||
|
||||
@@ -49,21 +49,21 @@ class UAVCAN_EXPORT Multiset : Noncopyable
|
||||
#endif
|
||||
|
||||
Item()
|
||||
: ptr(NULL)
|
||||
: ptr(UAVCAN_NULLPTR)
|
||||
{
|
||||
fill_n(pool, sizeof(pool), static_cast<unsigned char>(0));
|
||||
}
|
||||
|
||||
~Item() { destroy(); }
|
||||
|
||||
bool isConstructed() const { return ptr != NULL; }
|
||||
bool isConstructed() const { return ptr != UAVCAN_NULLPTR; }
|
||||
|
||||
void destroy()
|
||||
{
|
||||
if (ptr != NULL)
|
||||
if (ptr != UAVCAN_NULLPTR)
|
||||
{
|
||||
ptr->~T();
|
||||
ptr = NULL;
|
||||
ptr = UAVCAN_NULLPTR;
|
||||
fill_n(pool, sizeof(pool), static_cast<unsigned char>(0));
|
||||
}
|
||||
}
|
||||
@@ -85,20 +85,20 @@ private:
|
||||
static Chunk* instantiate(IPoolAllocator& allocator)
|
||||
{
|
||||
void* const praw = allocator.allocate(sizeof(Chunk));
|
||||
if (praw == NULL)
|
||||
if (praw == UAVCAN_NULLPTR)
|
||||
{
|
||||
return NULL;
|
||||
return UAVCAN_NULLPTR;
|
||||
}
|
||||
return new (praw) Chunk();
|
||||
}
|
||||
|
||||
static void destroy(Chunk*& obj, IPoolAllocator& allocator)
|
||||
{
|
||||
if (obj != NULL)
|
||||
if (obj != UAVCAN_NULLPTR)
|
||||
{
|
||||
obj->~Chunk();
|
||||
allocator.deallocate(obj);
|
||||
obj = NULL;
|
||||
obj = UAVCAN_NULLPTR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ private:
|
||||
return items + i;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return UAVCAN_NULLPTR;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -199,17 +199,17 @@ public:
|
||||
|
||||
/**
|
||||
* Creates one item in-place and returns a pointer to it.
|
||||
* If creation fails due to lack of memory, NULL will be returned.
|
||||
* If creation fails due to lack of memory, UAVCAN_NULLPTR will be returned.
|
||||
* Complexity is O(N).
|
||||
*/
|
||||
T* emplace()
|
||||
{
|
||||
Item* const item = findOrCreateFreeSlot();
|
||||
if (item == NULL)
|
||||
if (item == UAVCAN_NULLPTR)
|
||||
{
|
||||
return NULL;
|
||||
return UAVCAN_NULLPTR;
|
||||
}
|
||||
UAVCAN_ASSERT(item->ptr == NULL);
|
||||
UAVCAN_ASSERT(item->ptr == UAVCAN_NULLPTR);
|
||||
item->ptr = new (item->pool) T();
|
||||
return item->ptr;
|
||||
}
|
||||
@@ -218,11 +218,11 @@ public:
|
||||
T* emplace(P1 p1)
|
||||
{
|
||||
Item* const item = findOrCreateFreeSlot();
|
||||
if (item == NULL)
|
||||
if (item == UAVCAN_NULLPTR)
|
||||
{
|
||||
return NULL;
|
||||
return UAVCAN_NULLPTR;
|
||||
}
|
||||
UAVCAN_ASSERT(item->ptr == NULL);
|
||||
UAVCAN_ASSERT(item->ptr == UAVCAN_NULLPTR);
|
||||
item->ptr = new (item->pool) T(p1);
|
||||
return item->ptr;
|
||||
}
|
||||
@@ -231,11 +231,11 @@ public:
|
||||
T* emplace(P1 p1, P2 p2)
|
||||
{
|
||||
Item* const item = findOrCreateFreeSlot();
|
||||
if (item == NULL)
|
||||
if (item == UAVCAN_NULLPTR)
|
||||
{
|
||||
return NULL;
|
||||
return UAVCAN_NULLPTR;
|
||||
}
|
||||
UAVCAN_ASSERT(item->ptr == NULL);
|
||||
UAVCAN_ASSERT(item->ptr == UAVCAN_NULLPTR);
|
||||
item->ptr = new (item->pool) T(p1, p2);
|
||||
return item->ptr;
|
||||
}
|
||||
@@ -244,11 +244,11 @@ public:
|
||||
T* emplace(P1 p1, P2 p2, P3 p3)
|
||||
{
|
||||
Item* const item = findOrCreateFreeSlot();
|
||||
if (item == NULL)
|
||||
if (item == UAVCAN_NULLPTR)
|
||||
{
|
||||
return NULL;
|
||||
return UAVCAN_NULLPTR;
|
||||
}
|
||||
UAVCAN_ASSERT(item->ptr == NULL);
|
||||
UAVCAN_ASSERT(item->ptr == UAVCAN_NULLPTR);
|
||||
item->ptr = new (item->pool) T(p1, p2, p3);
|
||||
return item->ptr;
|
||||
}
|
||||
@@ -324,7 +324,7 @@ public:
|
||||
/**
|
||||
* Complexity is O(1).
|
||||
*/
|
||||
bool isEmpty() const { return find(YesPredicate()) == NULL; }
|
||||
bool isEmpty() const { return find(YesPredicate()) == UAVCAN_NULLPTR; }
|
||||
|
||||
/**
|
||||
* Counts number of items stored.
|
||||
@@ -347,7 +347,7 @@ typename Multiset<T>::Item* Multiset<T>::findOrCreateFreeSlot()
|
||||
while (p)
|
||||
{
|
||||
Item* const dyn = p->findFreeSlot();
|
||||
if (dyn != NULL)
|
||||
if (dyn != UAVCAN_NULLPTR)
|
||||
{
|
||||
return dyn;
|
||||
}
|
||||
@@ -357,9 +357,9 @@ typename Multiset<T>::Item* Multiset<T>::findOrCreateFreeSlot()
|
||||
|
||||
// Create new chunk
|
||||
Chunk* const chunk = Chunk::instantiate(allocator_);
|
||||
if (chunk == NULL)
|
||||
if (chunk == UAVCAN_NULLPTR)
|
||||
{
|
||||
return NULL;
|
||||
return UAVCAN_NULLPTR;
|
||||
}
|
||||
list_.insert(chunk);
|
||||
return &chunk->items[0];
|
||||
@@ -397,7 +397,7 @@ void Multiset<T>::removeWhere(Predicate predicate, const RemoveStrategy strategy
|
||||
unsigned num_removed = 0;
|
||||
|
||||
Chunk* p = list_.get();
|
||||
while (p != NULL)
|
||||
while (p != UAVCAN_NULLPTR)
|
||||
{
|
||||
Chunk* const next_chunk = p->getNextListNode(); // For the case if the current entry gets modified
|
||||
|
||||
@@ -437,7 +437,7 @@ template <typename Predicate>
|
||||
T* Multiset<T>::find(Predicate predicate)
|
||||
{
|
||||
Chunk* p = list_.get();
|
||||
while (p != NULL)
|
||||
while (p != UAVCAN_NULLPTR)
|
||||
{
|
||||
Chunk* const next_chunk = p->getNextListNode(); // For the case if the current entry gets modified
|
||||
|
||||
@@ -454,7 +454,7 @@ T* Multiset<T>::find(Predicate predicate)
|
||||
|
||||
p = next_chunk;
|
||||
}
|
||||
return NULL;
|
||||
return UAVCAN_NULLPTR;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
||||
Reference in New Issue
Block a user