diff --git a/cpp/devices/ctapdriver.cpp b/cpp/devices/ctapdriver.cpp index 9a1ce0d53b..6796c60752 100644 --- a/cpp/devices/ctapdriver.cpp +++ b/cpp/devices/ctapdriver.cpp @@ -371,7 +371,7 @@ bool CTapDriver::Disable() const return result; } -void CTapDriver::Flush() +void CTapDriver::Flush() const { while (PendingPackets()) { array m_garbage_buffer; @@ -386,11 +386,6 @@ void CTapDriver::GetMacAddr(uint8_t *mac) const memcpy(mac, m_MacAddr.data(), m_MacAddr.size()); } -//--------------------------------------------------------------------------- -// -// Receive -// -//--------------------------------------------------------------------------- bool CTapDriver::PendingPackets() const { assert(m_hTAP != -1); @@ -402,11 +397,7 @@ bool CTapDriver::PendingPackets() const fds.revents = 0; poll(&fds, 1, 0); spdlog::trace(to_string(fds.revents) + " revents"); - if (!(fds.revents & POLLIN)) { - return false; - } else { - return true; - } + return !(fds.revents & POLLIN); } // See https://stackoverflow.com/questions/21001659/crc32-algorithm-implementation-in-c-without-a-look-up-table-and-with-a-public-li diff --git a/cpp/devices/ctapdriver.h b/cpp/devices/ctapdriver.h index 073a59823d..b5dab6cee3 100644 --- a/cpp/devices/ctapdriver.h +++ b/cpp/devices/ctapdriver.h @@ -37,7 +37,7 @@ class CTapDriver bool PendingPackets() const; // Check if there are IP packets available bool Enable() const; // Enable the piscsi0 interface bool Disable() const; // Disable the piscsi0 interface - void Flush(); // Purge all of the packets that are waiting to be processed + void Flush() const; // Purge all of the packets that are waiting to be processed static uint32_t Crc32(span);