AP_HAL_Linux: reducing indenting by linearizing the logic
This commit is contained in:
parent
70a23724b5
commit
7dd8308a8c
@ -83,7 +83,10 @@ static uavcan::CanFrame makeUavcanFrame(const can_frame& sockcan_frame)
|
||||
|
||||
bool CAN::begin(uint32_t bitrate)
|
||||
{
|
||||
if (_initialized) return _initialized;
|
||||
if (_initialized) {
|
||||
return _initialized;
|
||||
}
|
||||
|
||||
// TODO: Add possibility change bitrate
|
||||
_fd = openSocket(HAL_BOARD_CAN_IFACE_NAME);
|
||||
if (_fd > 0) {
|
||||
@ -537,15 +540,16 @@ int16_t CANManager::select(uavcan::CanSelectMasks& inout_masks,
|
||||
IfaceWrapper* pollfd_index_to_iface[uavcan::MaxCanIfaces] = {};
|
||||
|
||||
for (unsigned i = 0; i < _ifaces.size(); i++) {
|
||||
if (!_ifaces[i]->isDown()) {
|
||||
pollfds[num_pollfds].fd = _ifaces[i]->getFileDescriptor();
|
||||
pollfds[num_pollfds].events = POLLIN;
|
||||
if (_ifaces[i]->hasReadyTx() || (inout_masks.write & (1U << i))) {
|
||||
pollfds[num_pollfds].events |= POLLOUT;
|
||||
}
|
||||
pollfd_index_to_iface[num_pollfds] = _ifaces[i].get();
|
||||
num_pollfds++;
|
||||
if (_ifaces[i]->isDown()) {
|
||||
continue;
|
||||
}
|
||||
pollfds[num_pollfds].fd = _ifaces[i]->getFileDescriptor();
|
||||
pollfds[num_pollfds].events = POLLIN;
|
||||
if (_ifaces[i]->hasReadyTx() || (inout_masks.write & (1U << i))) {
|
||||
pollfds[num_pollfds].events |= POLLOUT;
|
||||
}
|
||||
pollfd_index_to_iface[num_pollfds] = _ifaces[i].get();
|
||||
num_pollfds++;
|
||||
}
|
||||
|
||||
if (num_pollfds == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user