AP_HAL_Linux: handle uninitialised soCAN file descriptor

This commit is contained in:
bugobliterator 2020-11-11 12:06:19 +05:30 committed by Andrew Tridgell
parent eea6b4c9b9
commit d0cf3365ee
1 changed files with 6 additions and 0 deletions

View File

@ -319,6 +319,9 @@ bool CANIface::_pollRead()
int CANIface::_write(const AP_HAL::CANFrame& frame) const
{
if (_fd < 0) {
return -1;
}
errno = 0;
const can_frame sockcan_frame = makeSocketCanFrame(frame);
@ -339,6 +342,9 @@ int CANIface::_write(const AP_HAL::CANFrame& frame) const
int CANIface::_read(AP_HAL::CANFrame& frame, uint64_t& timestamp_us, bool& loopback) const
{
if (_fd < 0) {
return -1;
}
auto iov = iovec();
auto sockcan_frame = can_frame();
iov.iov_base = &sockcan_frame;