mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-19 02:53:34 +08:00
Minor source reorganization; few dangerous C functions replaced with safer std:: alternatives
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <stdint.h>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
namespace uavcan
|
||||
@@ -31,7 +31,7 @@ struct CanFrame
|
||||
: id(0)
|
||||
, dlc(0)
|
||||
{
|
||||
std::memset(data, 0, sizeof(data));
|
||||
std::fill(data, data + sizeof(data), 0);
|
||||
}
|
||||
|
||||
CanFrame(uint32_t id, const uint8_t* data, unsigned int dlc)
|
||||
@@ -39,13 +39,13 @@ struct CanFrame
|
||||
, dlc(dlc)
|
||||
{
|
||||
assert(data && dlc <= 8);
|
||||
std::memmove(this->data, data, dlc);
|
||||
std::copy(data, data + dlc, this->data);
|
||||
}
|
||||
|
||||
bool operator!=(const CanFrame& rhs) const { return !operator==(rhs); }
|
||||
bool operator==(const CanFrame& rhs) const
|
||||
{
|
||||
return (id == rhs.id) && (dlc == rhs.dlc) && (memcmp(data, rhs.data, dlc) == 0);
|
||||
return (id == rhs.id) && (dlc == rhs.dlc) && std::equal(data, data + dlc, rhs.data);
|
||||
}
|
||||
|
||||
bool isExtended() const { return id & FLAG_EFF; }
|
||||
|
||||
-1
@@ -6,7 +6,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <stdint.h>
|
||||
#include <uavcan/internal/linked_list.hpp>
|
||||
#include <uavcan/internal/dynamic_memory.hpp>
|
||||
@@ -18,6 +18,8 @@ namespace uavcan
|
||||
class ISystemClock
|
||||
{
|
||||
public:
|
||||
virtual ~ISystemClock() { }
|
||||
|
||||
/**
|
||||
* Monototic system clock in microseconds.
|
||||
* This shall never jump during UTC timestamp adjustments; the base time is irrelevant.
|
||||
|
||||
Reference in New Issue
Block a user