mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 16:03: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:
@@ -108,7 +108,7 @@ class Server : public AbstractServer
|
||||
return;
|
||||
}
|
||||
|
||||
const int res = storage_.add(node_id, (unique_id_or_null == NULL) ? UniqueID() : *unique_id_or_null);
|
||||
const int res = storage_.add(node_id, (unique_id_or_null == UAVCAN_NULLPTR) ? UniqueID() : *unique_id_or_null);
|
||||
if (res < 0)
|
||||
{
|
||||
tracer_.onEvent(TraceError, res);
|
||||
|
||||
+6
-6
@@ -84,7 +84,7 @@ private:
|
||||
return &servers_[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return UAVCAN_NULLPTR;
|
||||
}
|
||||
|
||||
virtual void handleTimerEvent(const TimerEvent&)
|
||||
@@ -338,7 +338,7 @@ public:
|
||||
Log::Index getServerNextIndex(NodeID server_node_id) const
|
||||
{
|
||||
const Server* const s = findServer(server_node_id);
|
||||
if (s != NULL)
|
||||
if (s != UAVCAN_NULLPTR)
|
||||
{
|
||||
return s->next_index;
|
||||
}
|
||||
@@ -349,7 +349,7 @@ public:
|
||||
void incrementServerNextIndexBy(NodeID server_node_id, Log::Index increment)
|
||||
{
|
||||
Server* const s = findServer(server_node_id);
|
||||
if (s != NULL)
|
||||
if (s != UAVCAN_NULLPTR)
|
||||
{
|
||||
s->next_index = Log::Index(s->next_index + increment);
|
||||
}
|
||||
@@ -362,7 +362,7 @@ public:
|
||||
void decrementServerNextIndex(NodeID server_node_id)
|
||||
{
|
||||
Server* const s = findServer(server_node_id);
|
||||
if (s != NULL)
|
||||
if (s != UAVCAN_NULLPTR)
|
||||
{
|
||||
s->next_index--;
|
||||
}
|
||||
@@ -378,7 +378,7 @@ public:
|
||||
Log::Index getServerMatchIndex(NodeID server_node_id) const
|
||||
{
|
||||
const Server* const s = findServer(server_node_id);
|
||||
if (s != NULL)
|
||||
if (s != UAVCAN_NULLPTR)
|
||||
{
|
||||
return s->match_index;
|
||||
}
|
||||
@@ -389,7 +389,7 @@ public:
|
||||
void setServerMatchIndex(NodeID server_node_id, Log::Index match_index)
|
||||
{
|
||||
Server* const s = findServer(server_node_id);
|
||||
if (s != NULL)
|
||||
if (s != UAVCAN_NULLPTR)
|
||||
{
|
||||
s->match_index = match_index;
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ public:
|
||||
const Entry* getEntryAtIndex(Index index) const
|
||||
{
|
||||
UAVCAN_ASSERT(last_index_ < Capacity);
|
||||
return (index <= last_index_) ? &entries_[index] : NULL;
|
||||
return (index <= last_index_) ? &entries_[index] : UAVCAN_NULLPTR;
|
||||
}
|
||||
|
||||
Index getLastIndex() const { return last_index_; }
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ public:
|
||||
}
|
||||
|
||||
const Entry* const last_entry = log_.getEntryAtIndex(log_.getLastIndex());
|
||||
if (last_entry == NULL)
|
||||
if (last_entry == UAVCAN_NULLPTR)
|
||||
{
|
||||
UAVCAN_ASSERT(0);
|
||||
return -ErrLogic;
|
||||
|
||||
@@ -143,9 +143,10 @@ private:
|
||||
UAVCAN_ASSERT(commit_index_ <= persistent_state_.getLog().getLastIndex());
|
||||
|
||||
// Term
|
||||
UAVCAN_ASSERT(persistent_state_.getLog().getEntryAtIndex(persistent_state_.getLog().getLastIndex()) != NULL);
|
||||
UAVCAN_ASSERT(persistent_state_.getLog().getEntryAtIndex(persistent_state_.getLog().getLastIndex())->term
|
||||
<= persistent_state_.getCurrentTerm());
|
||||
UAVCAN_ASSERT(persistent_state_.getLog().getEntryAtIndex(persistent_state_.getLog().getLastIndex()) !=
|
||||
UAVCAN_NULLPTR);
|
||||
UAVCAN_ASSERT(persistent_state_.getLog().getEntryAtIndex(persistent_state_.getLog().getLastIndex())->term <=
|
||||
persistent_state_.getCurrentTerm());
|
||||
|
||||
// Elections
|
||||
UAVCAN_ASSERT(server_state_ != ServerStateCandidate || !request_vote_client_.hasPendingCalls() ||
|
||||
@@ -281,7 +282,7 @@ private:
|
||||
req.prev_log_index = Log::Index(cluster_.getServerNextIndex(node_id) - 1U);
|
||||
|
||||
const Entry* const entry = persistent_state_.getLog().getEntryAtIndex(req.prev_log_index);
|
||||
if (entry == NULL)
|
||||
if (entry == UAVCAN_NULLPTR)
|
||||
{
|
||||
UAVCAN_ASSERT(0);
|
||||
handlePersistentStateUpdateError(-ErrLogic);
|
||||
@@ -470,7 +471,7 @@ private:
|
||||
* Reject the request if the assumed log index does not exist on the local node.
|
||||
*/
|
||||
const Entry* const prev_entry = persistent_state_.getLog().getEntryAtIndex(request.prev_log_index);
|
||||
if (prev_entry == NULL)
|
||||
if (prev_entry == UAVCAN_NULLPTR)
|
||||
{
|
||||
response.setResponseEnabled(true);
|
||||
return;
|
||||
@@ -880,7 +881,7 @@ public:
|
||||
for (int index = static_cast<int>(persistent_state_.getLog().getLastIndex()); index >= 0; index--)
|
||||
{
|
||||
const Entry* const entry = persistent_state_.getLog().getEntryAtIndex(Log::Index(index));
|
||||
UAVCAN_ASSERT(entry != NULL);
|
||||
UAVCAN_ASSERT(entry != UAVCAN_NULLPTR);
|
||||
const LogEntryInfo info(*entry, Log::Index(index) <= commit_index_);
|
||||
if (predicate(info))
|
||||
{
|
||||
|
||||
@@ -154,7 +154,7 @@ class UAVCAN_EXPORT Server : public AbstractServer
|
||||
return;
|
||||
}
|
||||
|
||||
const UniqueID uid = (unique_id_or_null == NULL) ? UniqueID() : *unique_id_or_null;
|
||||
const UniqueID uid = (unique_id_or_null == UAVCAN_NULLPTR) ? UniqueID() : *unique_id_or_null;
|
||||
|
||||
if (raft_core_.isLeader())
|
||||
{
|
||||
@@ -327,8 +327,8 @@ struct StateReport
|
||||
, num_unknown_nodes (s.getNodeDiscoverer().getNumUnknownNodes())
|
||||
{
|
||||
const Entry* const e = s.getRaftCore().getPersistentState().getLog().getEntryAtIndex(last_log_index);
|
||||
UAVCAN_ASSERT(e != NULL);
|
||||
if (e != NULL)
|
||||
UAVCAN_ASSERT(e != UAVCAN_NULLPTR);
|
||||
if (e != UAVCAN_NULLPTR)
|
||||
{
|
||||
last_log_term = e->term;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
* This method will be called when a new node responds to GetNodeInfo request.
|
||||
* If this method fails to register the node, the node will be queried again later and this method will be
|
||||
* invoked again.
|
||||
* Unique ID will be NULL if the node is assumed to not implement the GetNodeInfo service.
|
||||
* Unique ID will be UAVCAN_NULLPTR if the node is assumed to not implement the GetNodeInfo service.
|
||||
*/
|
||||
virtual void handleNewNodeDiscovery(const UniqueID* unique_id_or_null, NodeID node_id) = 0;
|
||||
|
||||
@@ -123,7 +123,7 @@ class NodeDiscoverer : TimerBase
|
||||
{
|
||||
// This essentially means that we pick first available node. Remember that the map is unordered.
|
||||
const NodeMap::KVPair* const pair = node_map_.getByIndex(0);
|
||||
return (pair == NULL) ? NodeID() : pair->key;
|
||||
return (pair == UAVCAN_NULLPTR) ? NodeID() : pair->key;
|
||||
}
|
||||
|
||||
bool needToQuery(NodeID node_id)
|
||||
@@ -190,7 +190,7 @@ class NodeDiscoverer : TimerBase
|
||||
|
||||
void finalizeNodeDiscovery(const UniqueID* unique_id_or_null, NodeID node_id)
|
||||
{
|
||||
trace(TraceDiscoveryNodeFinalized, node_id.get() | ((unique_id_or_null == NULL) ? 0U : 0x100U));
|
||||
trace(TraceDiscoveryNodeFinalized, node_id.get() | ((unique_id_or_null == UAVCAN_NULLPTR) ? 0U : 0x100U));
|
||||
removeNode(node_id);
|
||||
/*
|
||||
* It is paramount to check if the server is still interested to receive this data.
|
||||
@@ -216,7 +216,7 @@ class NodeDiscoverer : TimerBase
|
||||
trace(TraceDiscoveryGetNodeInfoFailure, result.getCallID().server_node_id.get());
|
||||
|
||||
NodeData* const data = node_map_.access(result.getCallID().server_node_id);
|
||||
if (data == NULL)
|
||||
if (data == UAVCAN_NULLPTR)
|
||||
{
|
||||
return; // Probably it is a known node now
|
||||
}
|
||||
@@ -227,7 +227,7 @@ class NodeDiscoverer : TimerBase
|
||||
data->num_get_node_info_attempts++;
|
||||
if (data->num_get_node_info_attempts >= MaxAttemptsToGetNodeInfo)
|
||||
{
|
||||
finalizeNodeDiscovery(NULL, result.getCallID().server_node_id);
|
||||
finalizeNodeDiscovery(UAVCAN_NULLPTR, result.getCallID().server_node_id);
|
||||
// Warning: data pointer is invalidated now
|
||||
}
|
||||
}
|
||||
@@ -272,18 +272,18 @@ class NodeDiscoverer : TimerBase
|
||||
}
|
||||
|
||||
NodeData* data = node_map_.access(msg.getSrcNodeID());
|
||||
if (data == NULL)
|
||||
if (data == UAVCAN_NULLPTR)
|
||||
{
|
||||
trace(TraceDiscoveryNewNodeFound, msg.getSrcNodeID().get());
|
||||
|
||||
data = node_map_.insert(msg.getSrcNodeID(), NodeData());
|
||||
if (data == NULL)
|
||||
if (data == UAVCAN_NULLPTR)
|
||||
{
|
||||
getNode().registerInternalFailure("NodeDiscoverer OOM");
|
||||
return;
|
||||
}
|
||||
}
|
||||
UAVCAN_ASSERT(data != NULL);
|
||||
UAVCAN_ASSERT(data != UAVCAN_NULLPTR);
|
||||
|
||||
if (msg.uptime_sec < data->last_seen_uptime)
|
||||
{
|
||||
|
||||
@@ -28,8 +28,8 @@ public:
|
||||
: owner_(owner)
|
||||
, is_node_id_taken_(is_node_id_taken)
|
||||
{
|
||||
UAVCAN_ASSERT(owner_ != NULL);
|
||||
UAVCAN_ASSERT(is_node_id_taken_ != NULL);
|
||||
UAVCAN_ASSERT(owner_ != UAVCAN_NULLPTR);
|
||||
UAVCAN_ASSERT(is_node_id_taken_ != UAVCAN_NULLPTR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -123,11 +123,11 @@ public:
|
||||
#endif
|
||||
|
||||
#if UAVCAN_CPP_VERSION >= UAVCAN_CPP11
|
||||
const unsigned long long x = std::strtoull(val.c_str(), NULL, 10);
|
||||
const unsigned long long x = std::strtoull(val.c_str(), UAVCAN_NULLPTR, 10);
|
||||
#else
|
||||
// There was no strtoull() before C++11, so we need to resort to strtoul()
|
||||
StaticAssert<(sizeof(unsigned long) >= sizeof(uint32_t))>::check();
|
||||
const unsigned long x = std::strtoul(val.c_str(), NULL, 10);
|
||||
const unsigned long x = std::strtoul(val.c_str(), UAVCAN_NULLPTR, 10);
|
||||
#endif
|
||||
|
||||
#if UAVCAN_CPP_VERSION >= UAVCAN_CPP11
|
||||
|
||||
Reference in New Issue
Block a user