AP_HAL_SITL: handle uninitialised file descriptor

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

View File

@ -323,6 +323,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);
@ -343,6 +346,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;