mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 06:13:35 +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:
@@ -39,7 +39,7 @@ class UAVCAN_EXPORT DataTypeInfoProvider : Noncopyable
|
||||
/*
|
||||
* Asking the Global Data Type Registry for the matching type descriptor, either by name or by ID
|
||||
*/
|
||||
const DataTypeDescriptor* desc = NULL;
|
||||
const DataTypeDescriptor* desc = UAVCAN_NULLPTR;
|
||||
|
||||
if (request.name.empty())
|
||||
{
|
||||
@@ -62,7 +62,7 @@ class UAVCAN_EXPORT DataTypeInfoProvider : Noncopyable
|
||||
desc = GlobalDataTypeRegistry::instance().find(request.name.c_str());
|
||||
}
|
||||
|
||||
if (desc == NULL)
|
||||
if (desc == UAVCAN_NULLPTR)
|
||||
{
|
||||
UAVCAN_TRACE("DataTypeInfoProvider",
|
||||
"Cannot process GetDataTypeInfo for nonexistent type: dtid=%i dtk=%i name='%s'",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -226,7 +226,7 @@ class FirmwareUpdateTrigger : public INodeInfoListener,
|
||||
|
||||
void trySetPendingNode(const NodeID node_id, const FirmwareFilePath& path)
|
||||
{
|
||||
if (NULL != pending_nodes_.insert(node_id, path))
|
||||
if (UAVCAN_NULLPTR != pending_nodes_.insert(node_id, path))
|
||||
{
|
||||
if (!TimerBase::isRunning())
|
||||
{
|
||||
@@ -285,7 +285,7 @@ class FirmwareUpdateTrigger : public INodeInfoListener,
|
||||
}
|
||||
|
||||
FirmwareFilePath* const old_path = pending_nodes_.access(result.getCallID().server_node_id);
|
||||
if (old_path == NULL)
|
||||
if (old_path == UAVCAN_NULLPTR)
|
||||
{
|
||||
// The entry has been removed, assuming that it's not needed anymore
|
||||
return;
|
||||
@@ -304,7 +304,7 @@ class FirmwareUpdateTrigger : public INodeInfoListener,
|
||||
}
|
||||
else
|
||||
{
|
||||
UAVCAN_ASSERT(old_path != NULL);
|
||||
UAVCAN_ASSERT(old_path != UAVCAN_NULLPTR);
|
||||
UAVCAN_ASSERT(TimerBase::isRunning());
|
||||
// We won't have to call trySetPendingNode(), because we'll directly update the old path via the pointer
|
||||
|
||||
@@ -336,7 +336,7 @@ class FirmwareUpdateTrigger : public INodeInfoListener,
|
||||
}
|
||||
|
||||
FirmwareFilePath* const path = pending_nodes_.access(node_id);
|
||||
if (path == NULL)
|
||||
if (path == UAVCAN_NULLPTR)
|
||||
{
|
||||
UAVCAN_ASSERT(0); // pickNextNodeID() returned a node ID that is not present in the map
|
||||
return;
|
||||
@@ -367,7 +367,7 @@ public:
|
||||
: TimerBase(node)
|
||||
, begin_fw_update_client_(node)
|
||||
, checker_(checker)
|
||||
, node_info_retriever_(NULL)
|
||||
, node_info_retriever_(UAVCAN_NULLPTR)
|
||||
, pending_nodes_(node.getAllocator())
|
||||
, request_interval_(MonotonicDuration::fromMSec(DefaultRequestIntervalMs))
|
||||
, last_queried_node_id_(0)
|
||||
@@ -375,7 +375,7 @@ public:
|
||||
|
||||
~FirmwareUpdateTrigger()
|
||||
{
|
||||
if (node_info_retriever_ != NULL)
|
||||
if (node_info_retriever_ != UAVCAN_NULLPTR)
|
||||
{
|
||||
node_info_retriever_->removeListener(this);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ class UAVCAN_EXPORT GlobalTimeSyncMaster : protected LoopbackFrameListenerBase
|
||||
const MonotonicTime otr_deadline = node_.getMonotonicTime() + max_transfer_interval;
|
||||
TransferID* const tid_ptr =
|
||||
node_.getDispatcher().getOutgoingTransferRegistry().accessOrCreate(otr_key, otr_deadline);
|
||||
if (tid_ptr == NULL)
|
||||
if (tid_ptr == UAVCAN_NULLPTR)
|
||||
{
|
||||
return -ErrMemory;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ public:
|
||||
// Data type ID
|
||||
const DataTypeDescriptor* const desc =
|
||||
GlobalDataTypeRegistry::instance().find(DataTypeKindMessage, protocol::GlobalTimeSync::getDataTypeFullName());
|
||||
if (desc == NULL)
|
||||
if (desc == UAVCAN_NULLPTR)
|
||||
{
|
||||
return -ErrUnknownDataType;
|
||||
}
|
||||
|
||||
@@ -76,13 +76,13 @@ private:
|
||||
|
||||
LogLevel getExternalSinkLevel() const
|
||||
{
|
||||
return (external_sink_ == NULL) ? getLogLevelAboveAll() : external_sink_->getLogLevel();
|
||||
return (external_sink_ == UAVCAN_NULLPTR) ? getLogLevelAboveAll() : external_sink_->getLogLevel();
|
||||
}
|
||||
|
||||
public:
|
||||
explicit Logger(INode& node)
|
||||
: logmsg_pub_(node)
|
||||
, external_sink_(NULL)
|
||||
, external_sink_(UAVCAN_NULLPTR)
|
||||
{
|
||||
level_ = protocol::debug::LogLevel::ERROR;
|
||||
setTxTimeout(MonotonicDuration::fromMSec(DefaultTxTimeoutMs));
|
||||
|
||||
@@ -131,7 +131,7 @@ private:
|
||||
|
||||
bool operator()(INodeInfoListener* key)
|
||||
{
|
||||
UAVCAN_ASSERT(key != NULL);
|
||||
UAVCAN_ASSERT(key != UAVCAN_NULLPTR);
|
||||
key->handleNodeInfoRetrieved(node_id, node_info);
|
||||
return false;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ private:
|
||||
|
||||
bool operator()(INodeInfoListener* key)
|
||||
{
|
||||
UAVCAN_ASSERT(key != NULL);
|
||||
UAVCAN_ASSERT(key != UAVCAN_NULLPTR);
|
||||
(key->*method)(event);
|
||||
return false;
|
||||
}
|
||||
@@ -385,10 +385,10 @@ public:
|
||||
*/
|
||||
int addListener(INodeInfoListener* listener)
|
||||
{
|
||||
if (listener != NULL)
|
||||
if (listener != UAVCAN_NULLPTR)
|
||||
{
|
||||
removeListener(listener);
|
||||
return (NULL == listeners_.emplace(listener)) ? -ErrMemory : 0;
|
||||
return (UAVCAN_NULLPTR == listeners_.emplace(listener)) ? -ErrMemory : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -402,7 +402,7 @@ public:
|
||||
*/
|
||||
void removeListener(INodeInfoListener* listener)
|
||||
{
|
||||
if (listener != NULL)
|
||||
if (listener != UAVCAN_NULLPTR)
|
||||
{
|
||||
listeners_.removeAll(listener);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class UAVCAN_EXPORT ParamServer
|
||||
|
||||
void handleGetSet(const protocol::param::GetSet::Request& in, protocol::param::GetSet::Response& out)
|
||||
{
|
||||
UAVCAN_ASSERT(manager_ != NULL);
|
||||
UAVCAN_ASSERT(manager_ != UAVCAN_NULLPTR);
|
||||
|
||||
// Recover the name from index
|
||||
if (in.name.empty())
|
||||
@@ -131,7 +131,7 @@ class UAVCAN_EXPORT ParamServer
|
||||
void handleExecuteOpcode(const protocol::param::ExecuteOpcode::Request& in,
|
||||
protocol::param::ExecuteOpcode::Response& out)
|
||||
{
|
||||
UAVCAN_ASSERT(manager_ != NULL);
|
||||
UAVCAN_ASSERT(manager_ != UAVCAN_NULLPTR);
|
||||
|
||||
if (in.opcode == protocol::param::ExecuteOpcode::Request::OPCODE_SAVE)
|
||||
{
|
||||
@@ -152,7 +152,7 @@ public:
|
||||
explicit ParamServer(INode& node)
|
||||
: get_set_srv_(node)
|
||||
, save_erase_srv_(node)
|
||||
, manager_(NULL)
|
||||
, manager_(UAVCAN_NULLPTR)
|
||||
{ }
|
||||
|
||||
/**
|
||||
@@ -161,7 +161,7 @@ public:
|
||||
*/
|
||||
int start(IParamManager* manager)
|
||||
{
|
||||
if (manager == NULL)
|
||||
if (manager == UAVCAN_NULLPTR)
|
||||
{
|
||||
return -ErrInvalidParam;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class UAVCAN_EXPORT RestartRequestServer : Noncopyable
|
||||
public:
|
||||
explicit RestartRequestServer(INode& node)
|
||||
: srv_(node)
|
||||
, handler_(NULL)
|
||||
, handler_(UAVCAN_NULLPTR)
|
||||
{ }
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user