AP_HAL_Linux: reducing indenting by linearizing the logic

This commit is contained in:
Eugene Shamaev 2018-03-09 10:30:45 +02:00 committed by Tom Pittenger
parent 70a23724b5
commit 7dd8308a8c
1 changed files with 13 additions and 9 deletions

View File

@ -83,7 +83,10 @@ static uavcan::CanFrame makeUavcanFrame(const can_frame& sockcan_frame)
bool CAN::begin(uint32_t bitrate) bool CAN::begin(uint32_t bitrate)
{ {
if (_initialized) return _initialized; if (_initialized) {
return _initialized;
}
// TODO: Add possibility change bitrate // TODO: Add possibility change bitrate
_fd = openSocket(HAL_BOARD_CAN_IFACE_NAME); _fd = openSocket(HAL_BOARD_CAN_IFACE_NAME);
if (_fd > 0) { if (_fd > 0) {
@ -537,15 +540,16 @@ int16_t CANManager::select(uavcan::CanSelectMasks& inout_masks,
IfaceWrapper* pollfd_index_to_iface[uavcan::MaxCanIfaces] = {}; IfaceWrapper* pollfd_index_to_iface[uavcan::MaxCanIfaces] = {};
for (unsigned i = 0; i < _ifaces.size(); i++) { for (unsigned i = 0; i < _ifaces.size(); i++) {
if (!_ifaces[i]->isDown()) { if (_ifaces[i]->isDown()) {
pollfds[num_pollfds].fd = _ifaces[i]->getFileDescriptor(); continue;
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++;
} }
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) { if (num_pollfds == 0) {