mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 05:03:35 +08:00
Strict sign conversions
This commit is contained in:
@@ -540,16 +540,16 @@ public:
|
||||
{
|
||||
if (new_size > size())
|
||||
{
|
||||
unsigned cnt = new_size - size();
|
||||
while (cnt--)
|
||||
SizeType cnt = SizeType(new_size - size());
|
||||
while (cnt-- > 0)
|
||||
{
|
||||
push_back(filler);
|
||||
}
|
||||
}
|
||||
else if (new_size < size())
|
||||
{
|
||||
unsigned cnt = size() - new_size;
|
||||
while (cnt--)
|
||||
SizeType cnt = SizeType(size() - new_size);
|
||||
while (cnt-- > 0)
|
||||
{
|
||||
pop_back();
|
||||
}
|
||||
@@ -623,7 +623,7 @@ public:
|
||||
}
|
||||
while (*ch)
|
||||
{
|
||||
push_back(*ch++);
|
||||
push_back(ValueType(*ch++)); // Value type is likely to be unsigned char, so conversion may be required.
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -642,7 +642,7 @@ public:
|
||||
}
|
||||
while (*ch)
|
||||
{
|
||||
push_back(*ch++);
|
||||
push_back(ValueType(*ch++));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
namespace uavcan
|
||||
{
|
||||
|
||||
void bitarrayCopy(const unsigned char* src_org, int src_offset, int src_len, unsigned char* dst_org, int dst_offset);
|
||||
void bitarrayCopy(const unsigned char* src_org, unsigned src_offset, unsigned src_len,
|
||||
unsigned char* dst_org, unsigned dst_offset);
|
||||
|
||||
/**
|
||||
* This class treats a chunk of memory as an array of bits.
|
||||
@@ -24,13 +25,13 @@ class UAVCAN_EXPORT BitStream
|
||||
static const unsigned MaxBytesPerRW = 16;
|
||||
|
||||
ITransferBuffer& buf_;
|
||||
int bit_offset_;
|
||||
unsigned bit_offset_;
|
||||
uint8_t byte_cache_;
|
||||
|
||||
static inline unsigned bitlenToBytelen(unsigned bits) { return (bits + 7) / 8; }
|
||||
|
||||
static inline void copyBitArray(const uint8_t* src_org, int src_offset, int src_len,
|
||||
uint8_t* dst_org, int dst_offset)
|
||||
static inline void copyBitArray(const uint8_t* src_org, unsigned src_offset, unsigned src_len,
|
||||
uint8_t* dst_org, unsigned dst_offset)
|
||||
{
|
||||
bitarrayCopy(reinterpret_cast<const unsigned char*>(src_org), src_offset, src_len,
|
||||
reinterpret_cast<unsigned char*>(dst_org), dst_offset);
|
||||
@@ -64,8 +65,8 @@ public:
|
||||
* Zero - Out of buffer space
|
||||
* Positive - OK
|
||||
*/
|
||||
int write(const uint8_t* bytes, const int bitlen);
|
||||
int read(uint8_t* bytes, const int bitlen);
|
||||
int write(const uint8_t* bytes, const unsigned bitlen);
|
||||
int read(uint8_t* bytes, const unsigned bitlen);
|
||||
|
||||
#if UAVCAN_TOSTRING
|
||||
std::string toString() const;
|
||||
|
||||
@@ -86,7 +86,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
static void truncate(StorageType& value) { value &= mask(); }
|
||||
static void truncate(StorageType& value) { value = value & StorageType(mask()); }
|
||||
|
||||
static void validate()
|
||||
{
|
||||
|
||||
@@ -140,12 +140,12 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (uint64_t(usec_ + r.toUSec()) < usec_)
|
||||
if (uint64_t(int64_t(usec_) + r.toUSec()) < usec_)
|
||||
{
|
||||
return fromUSec(NumericTraits<uint64_t>::max());
|
||||
}
|
||||
}
|
||||
return fromUSec(usec_ + r.toUSec());
|
||||
return fromUSec(uint64_t(int64_t(usec_) + r.toUSec()));
|
||||
}
|
||||
|
||||
T operator-(const D& r) const
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
}
|
||||
D operator-(const T& r) const
|
||||
{
|
||||
return D::fromUSec((usec_ > r.usec_) ? (usec_ - r.usec_) : -(r.usec_ - usec_));
|
||||
return D::fromUSec((usec_ > r.usec_) ? int64_t(usec_ - r.usec_) : -int64_t(r.usec_ - usec_));
|
||||
}
|
||||
|
||||
T& operator+=(const D& r)
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
#else
|
||||
void add(uint8_t byte)
|
||||
{
|
||||
value_ = ((value_ << 8) ^ Table[((value_ >> 8) ^ byte) & 0xFFU]) & 0xFFFFU;
|
||||
value_ = uint16_t(uint16_t((value_ << 8) ^ Table[uint16_t((value_ >> 8) ^ byte) & 0xFFU]) & 0xFFFFU);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ class UAVCAN_EXPORT Dispatcher : Noncopyable
|
||||
void cleanup(MonotonicTime ts);
|
||||
void handleFrame(const RxFrame& frame);
|
||||
|
||||
int getNumEntries() const { return list_.getLength(); }
|
||||
unsigned getNumEntries() const { return list_.getLength(); }
|
||||
};
|
||||
|
||||
ListenerRegistry lmsg_;
|
||||
@@ -137,9 +137,9 @@ public:
|
||||
bool hasPublisher(DataTypeID dtid) const;
|
||||
bool hasServer(DataTypeID dtid) const;
|
||||
|
||||
int getNumMessageListeners() const { return lmsg_.getNumEntries(); }
|
||||
int getNumServiceRequestListeners() const { return lsrv_req_.getNumEntries(); }
|
||||
int getNumServiceResponseListeners() const { return lsrv_resp_.getNumEntries(); }
|
||||
unsigned getNumMessageListeners() const { return lmsg_.getNumEntries(); }
|
||||
unsigned getNumServiceRequestListeners() const { return lsrv_req_.getNumEntries(); }
|
||||
unsigned getNumServiceResponseListeners() const { return lsrv_resp_.getNumEntries(); }
|
||||
|
||||
IOutgoingTransferRegistry& getOutgoingTransferRegistry() { return outgoing_transfer_reg_; }
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
* Send with explicit Transfer ID.
|
||||
* Should be used only for service responses, where response TID should match request TID.
|
||||
*/
|
||||
int send(const uint8_t* payload, int payload_len, MonotonicTime tx_deadline,
|
||||
int send(const uint8_t* payload, unsigned payload_len, MonotonicTime tx_deadline,
|
||||
MonotonicTime blocking_deadline, TransferType transfer_type, NodeID dst_node_id,
|
||||
TransferID tid);
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
* Send with automatic Transfer ID.
|
||||
* TID is managed by OutgoingTransferRegistry.
|
||||
*/
|
||||
int send(const uint8_t* payload, int payload_len, MonotonicTime tx_deadline,
|
||||
int send(const uint8_t* payload, unsigned payload_len, MonotonicTime tx_deadline,
|
||||
MonotonicTime blocking_deadline, TransferType transfer_type, NodeID dst_node_id);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user