mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 17:53:38 +08:00
Fixed type signedness through the entire codebase; driver interfaces do not use starndard types now
This commit is contained in:
@@ -32,12 +32,12 @@ std::string CanFrame::toString(StringRepresentation mode) const
|
||||
|
||||
if (id & FlagEFF)
|
||||
{
|
||||
wpos += snprintf(wpos, epos - wpos, "0x%08x ", (unsigned int)(id & MaskExtID));
|
||||
wpos += snprintf(wpos, epos - wpos, "0x%08x ", unsigned(id & MaskExtID));
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* const fmt = (mode == StrAligned) ? " 0x%03x " : "0x%03x ";
|
||||
wpos += snprintf(wpos, epos - wpos, fmt, (unsigned int)(id & MaskStdID));
|
||||
wpos += snprintf(wpos, epos - wpos, fmt, unsigned(id & MaskStdID));
|
||||
}
|
||||
|
||||
if (id & FlagRTR)
|
||||
@@ -53,7 +53,7 @@ std::string CanFrame::toString(StringRepresentation mode) const
|
||||
{
|
||||
for (int dlen = 0; dlen < dlc; dlen++) // hex bytes
|
||||
{
|
||||
wpos += snprintf(wpos, epos - wpos, " %02x", (unsigned int)data[dlen]);
|
||||
wpos += snprintf(wpos, epos - wpos, " %02x", unsigned(data[dlen]));
|
||||
}
|
||||
|
||||
while (mode == StrAligned && wpos < buf + ASCII_COLUMN_OFFSET) // alignment
|
||||
|
||||
@@ -212,9 +212,9 @@ bool CanTxQueue::topPriorityHigherOrEqual(const CanFrame& rhs_frame) const
|
||||
/*
|
||||
* CanIOManager
|
||||
*/
|
||||
int CanIOManager::sendToIface(int iface_index, const CanFrame& frame, MonotonicTime tx_deadline, CanIOFlags flags)
|
||||
int CanIOManager::sendToIface(uint8_t iface_index, const CanFrame& frame, MonotonicTime tx_deadline, CanIOFlags flags)
|
||||
{
|
||||
assert(iface_index >= 0 && iface_index < MaxCanIfaces);
|
||||
assert(iface_index < MaxCanIfaces);
|
||||
ICanIface* const iface = driver_.getIface(iface_index);
|
||||
if (iface == NULL)
|
||||
{
|
||||
@@ -234,9 +234,9 @@ int CanIOManager::sendToIface(int iface_index, const CanFrame& frame, MonotonicT
|
||||
return res;
|
||||
}
|
||||
|
||||
int CanIOManager::sendFromTxQueue(int iface_index)
|
||||
int CanIOManager::sendFromTxQueue(uint8_t iface_index)
|
||||
{
|
||||
assert(iface_index >= 0 && iface_index < MaxCanIfaces);
|
||||
assert(iface_index < MaxCanIfaces);
|
||||
CanTxQueue::Entry* entry = tx_queues_[iface_index].peek();
|
||||
if (entry == NULL)
|
||||
{
|
||||
@@ -250,10 +250,10 @@ int CanIOManager::sendFromTxQueue(int iface_index)
|
||||
return res;
|
||||
}
|
||||
|
||||
int CanIOManager::makePendingTxMask() const
|
||||
uint8_t CanIOManager::makePendingTxMask() const
|
||||
{
|
||||
int write_mask = 0;
|
||||
for (int i = 0; i < getNumIfaces(); i++)
|
||||
uint8_t write_mask = 0;
|
||||
for (uint8_t i = 0; i < getNumIfaces(); i++)
|
||||
{
|
||||
if (!tx_queues_[i].isEmpty())
|
||||
{
|
||||
@@ -263,17 +263,17 @@ int CanIOManager::makePendingTxMask() const
|
||||
return write_mask;
|
||||
}
|
||||
|
||||
int CanIOManager::getNumIfaces() const
|
||||
uint8_t CanIOManager::getNumIfaces() const
|
||||
{
|
||||
const int num = driver_.getNumIfaces();
|
||||
const uint8_t num = driver_.getNumIfaces();
|
||||
assert(num > 0 && num <= MaxCanIfaces);
|
||||
return std::min(std::max(num, 0), (int)MaxCanIfaces);
|
||||
return std::min(std::max(num, uint8_t(0)), uint8_t(MaxCanIfaces));
|
||||
}
|
||||
|
||||
CanIfacePerfCounters CanIOManager::getIfacePerfCounters(int iface_index) const
|
||||
CanIfacePerfCounters CanIOManager::getIfacePerfCounters(uint8_t iface_index) const
|
||||
{
|
||||
ICanIface* const iface = driver_.getIface(iface_index);
|
||||
if (iface == NULL || iface_index >= MaxCanIfaces || iface_index < 0)
|
||||
if (iface == NULL || iface_index >= MaxCanIfaces)
|
||||
{
|
||||
assert(0);
|
||||
return CanIfacePerfCounters();
|
||||
@@ -286,10 +286,10 @@ CanIfacePerfCounters CanIOManager::getIfacePerfCounters(int iface_index) const
|
||||
}
|
||||
|
||||
int CanIOManager::send(const CanFrame& frame, MonotonicTime tx_deadline, MonotonicTime blocking_deadline,
|
||||
int iface_mask, CanTxQueue::Qos qos, CanIOFlags flags)
|
||||
uint8_t iface_mask, CanTxQueue::Qos qos, CanIOFlags flags)
|
||||
{
|
||||
const int num_ifaces = getNumIfaces();
|
||||
const int all_ifaces_mask = (1 << num_ifaces) - 1;
|
||||
const uint8_t num_ifaces = getNumIfaces();
|
||||
const uint8_t all_ifaces_mask = (1U << num_ifaces) - 1;
|
||||
iface_mask &= all_ifaces_mask;
|
||||
|
||||
if (blocking_deadline > tx_deadline)
|
||||
@@ -317,7 +317,7 @@ int CanIOManager::send(const CanFrame& frame, MonotonicTime tx_deadline, Monoton
|
||||
}
|
||||
|
||||
// Transmission
|
||||
for (int i = 0; i < num_ifaces; i++)
|
||||
for (uint8_t i = 0; i < num_ifaces; i++)
|
||||
{
|
||||
if (masks.write & (1 << i))
|
||||
{
|
||||
@@ -357,7 +357,7 @@ int CanIOManager::send(const CanFrame& frame, MonotonicTime tx_deadline, Monoton
|
||||
UAVCAN_TRACE("CanIOManager", "Send: Premature timeout in select(), will try again");
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < num_ifaces; i++)
|
||||
for (uint8_t i = 0; i < num_ifaces; i++)
|
||||
{
|
||||
if (iface_mask & (1 << i))
|
||||
{
|
||||
@@ -372,7 +372,7 @@ int CanIOManager::send(const CanFrame& frame, MonotonicTime tx_deadline, Monoton
|
||||
|
||||
int CanIOManager::receive(CanRxFrame& out_frame, MonotonicTime blocking_deadline, CanIOFlags& out_flags)
|
||||
{
|
||||
const int num_ifaces = getNumIfaces();
|
||||
const uint8_t num_ifaces = getNumIfaces();
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -388,7 +388,7 @@ int CanIOManager::receive(CanRxFrame& out_frame, MonotonicTime blocking_deadline
|
||||
}
|
||||
|
||||
// Write - if buffers are not empty, one frame will be sent for each iface per one receive() call
|
||||
for (int i = 0; i < num_ifaces; i++)
|
||||
for (uint8_t i = 0; i < num_ifaces; i++)
|
||||
{
|
||||
if (masks.write & (1 << i))
|
||||
{
|
||||
@@ -397,7 +397,7 @@ int CanIOManager::receive(CanRxFrame& out_frame, MonotonicTime blocking_deadline
|
||||
}
|
||||
|
||||
// Read
|
||||
for (int i = 0; i < num_ifaces; i++)
|
||||
for (uint8_t i = 0; i < num_ifaces; i++)
|
||||
{
|
||||
if (masks.read & (1 << i))
|
||||
{
|
||||
|
||||
@@ -33,14 +33,16 @@ int Frame::getMaxPayloadLen() const
|
||||
}
|
||||
}
|
||||
|
||||
int Frame::setPayload(const uint8_t* data, int len)
|
||||
int Frame::setPayload(const uint8_t* data, unsigned len)
|
||||
{
|
||||
len = std::min(getMaxPayloadLen(), len);
|
||||
if (len >= 0)
|
||||
const int maxlen = getMaxPayloadLen();
|
||||
if (maxlen < 0)
|
||||
{
|
||||
std::copy(data, data + len, payload_);
|
||||
payload_len_ = len;
|
||||
return maxlen;
|
||||
}
|
||||
len = std::min(unsigned(maxlen), len);
|
||||
std::copy(data, data + len, payload_);
|
||||
payload_len_ = len;
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,11 +43,11 @@ void DynamicTransferBufferManagerEntry::Block::destroy(Block*& obj, IAllocator&
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicTransferBufferManagerEntry::Block::read(uint8_t*& outptr, unsigned int target_offset,
|
||||
unsigned int& total_offset, unsigned int& left_to_read)
|
||||
void DynamicTransferBufferManagerEntry::Block::read(uint8_t*& outptr, unsigned target_offset,
|
||||
unsigned& total_offset, unsigned& left_to_read)
|
||||
{
|
||||
assert(outptr);
|
||||
for (int i = 0; (i < Block::Size) && (left_to_read > 0); i++, total_offset++)
|
||||
for (unsigned i = 0; (i < Block::Size) && (left_to_read > 0); i++, total_offset++)
|
||||
{
|
||||
if (total_offset >= target_offset)
|
||||
{
|
||||
@@ -57,11 +57,11 @@ void DynamicTransferBufferManagerEntry::Block::read(uint8_t*& outptr, unsigned i
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicTransferBufferManagerEntry::Block::write(const uint8_t*& inptr, unsigned int target_offset,
|
||||
unsigned int& total_offset, unsigned int& left_to_write)
|
||||
void DynamicTransferBufferManagerEntry::Block::write(const uint8_t*& inptr, unsigned target_offset,
|
||||
unsigned& total_offset, unsigned& left_to_write)
|
||||
{
|
||||
assert(inptr);
|
||||
for (int i = 0; (i < Block::Size) && (left_to_write > 0); i++, total_offset++)
|
||||
for (unsigned i = 0; (i < Block::Size) && (left_to_write > 0); i++, total_offset++)
|
||||
{
|
||||
if (total_offset >= target_offset)
|
||||
{
|
||||
@@ -75,7 +75,7 @@ void DynamicTransferBufferManagerEntry::Block::write(const uint8_t*& inptr, unsi
|
||||
* DynamicTransferBuffer
|
||||
*/
|
||||
DynamicTransferBufferManagerEntry* DynamicTransferBufferManagerEntry::instantiate(IAllocator& allocator,
|
||||
unsigned int max_size)
|
||||
unsigned max_size)
|
||||
{
|
||||
void* const praw = allocator.allocate(sizeof(DynamicTransferBufferManagerEntry));
|
||||
if (praw == NULL)
|
||||
@@ -108,7 +108,7 @@ void DynamicTransferBufferManagerEntry::resetImpl()
|
||||
}
|
||||
}
|
||||
|
||||
int DynamicTransferBufferManagerEntry::read(unsigned int offset, uint8_t* data, unsigned int len) const
|
||||
int DynamicTransferBufferManagerEntry::read(unsigned offset, uint8_t* data, unsigned len) const
|
||||
{
|
||||
if (!data)
|
||||
{
|
||||
@@ -126,7 +126,8 @@ int DynamicTransferBufferManagerEntry::read(unsigned int offset, uint8_t* data,
|
||||
assert((offset + len) <= max_write_pos_);
|
||||
|
||||
// This shall be optimized.
|
||||
unsigned int total_offset = 0, left_to_read = len;
|
||||
unsigned total_offset = 0;
|
||||
unsigned left_to_read = len;
|
||||
uint8_t* outptr = data;
|
||||
Block* p = blocks_.get();
|
||||
while (p)
|
||||
@@ -143,7 +144,7 @@ int DynamicTransferBufferManagerEntry::read(unsigned int offset, uint8_t* data,
|
||||
return len;
|
||||
}
|
||||
|
||||
int DynamicTransferBufferManagerEntry::write(unsigned int offset, const uint8_t* data, unsigned int len)
|
||||
int DynamicTransferBufferManagerEntry::write(unsigned offset, const uint8_t* data, unsigned len)
|
||||
{
|
||||
if (!data)
|
||||
{
|
||||
@@ -161,8 +162,8 @@ int DynamicTransferBufferManagerEntry::write(unsigned int offset, const uint8_t*
|
||||
}
|
||||
assert((offset + len) <= max_size_);
|
||||
|
||||
unsigned int total_offset = 0;
|
||||
unsigned int left_to_write = len;
|
||||
unsigned total_offset = 0;
|
||||
unsigned left_to_write = len;
|
||||
const uint8_t* inptr = data;
|
||||
Block* p = blocks_.get();
|
||||
Block* last_written_block = NULL;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace uavcan
|
||||
/*
|
||||
* IncomingTransfer
|
||||
*/
|
||||
int IncomingTransfer::write(unsigned int, const uint8_t*, unsigned int)
|
||||
int IncomingTransfer::write(unsigned, const uint8_t*, unsigned)
|
||||
{
|
||||
assert(0); // Incoming transfer container is read-only
|
||||
return -ErrLogic;
|
||||
@@ -30,7 +30,7 @@ SingleFrameIncomingTransfer::SingleFrameIncomingTransfer(const RxFrame& frm)
|
||||
assert(frm.isValid());
|
||||
}
|
||||
|
||||
int SingleFrameIncomingTransfer::read(unsigned int offset, uint8_t* data, unsigned int len) const
|
||||
int SingleFrameIncomingTransfer::read(unsigned offset, uint8_t* data, unsigned len) const
|
||||
{
|
||||
if (data == NULL)
|
||||
{
|
||||
@@ -63,7 +63,7 @@ MultiFrameIncomingTransfer::MultiFrameIncomingTransfer(MonotonicTime ts_mono, Ut
|
||||
assert(last_frame.isLast());
|
||||
}
|
||||
|
||||
int MultiFrameIncomingTransfer::read(unsigned int offset, uint8_t* data, unsigned int len) const
|
||||
int MultiFrameIncomingTransfer::read(unsigned offset, uint8_t* data, unsigned len) const
|
||||
{
|
||||
const ITransferBuffer* const tbb = const_cast<TransferBufferAccessor&>(buf_acc_).access();
|
||||
if (tbb == NULL)
|
||||
@@ -80,7 +80,7 @@ int MultiFrameIncomingTransfer::read(unsigned int offset, uint8_t* data, unsigne
|
||||
bool TransferListenerBase::checkPayloadCrc(const uint16_t compare_with, const ITransferBuffer& tbb) const
|
||||
{
|
||||
TransferCRC crc = crc_base_;
|
||||
unsigned int offset = 0;
|
||||
unsigned offset = 0;
|
||||
while (true)
|
||||
{
|
||||
uint8_t buf[16];
|
||||
|
||||
Reference in New Issue
Block a user