Skip to content

Commit

Permalink
Use isNotEmpty() instead of !isEmpty()
Browse files Browse the repository at this point in the history
  • Loading branch information
strongly-typed committed May 18, 2023
1 parent 49afc81 commit 5bf59a8
Show file tree
Hide file tree
Showing 28 changed files with 52 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/modm/communication/rpr/interface_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ template <typename Device, std::size_t N>
void
modm::rpr::Interface<Device, N>::popMessage(Queue &queue)
{
if (!queue.isEmpty())
if (queue.isNotEmpty())
{
// deallocate the external buffer
Message message = queue.get();
Expand Down
2 changes: 1 addition & 1 deletion src/modm/communication/xpcc/backend/can/connector_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ xpcc::CanConnector<Driver>::sendWaitingMessages()
}
else if (canDriver->getBusState() != Driver::BusState::Connected) {
// No connection to the CAN bus, drop all messages which should be send
while (!sendList.isEmpty()) {
while (sendList.isNotEmpty()) {
sendList.removeFront();
}
return;
Expand Down
3 changes: 3 additions & 0 deletions src/modm/container/doubly_linked_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ namespace modm
inline bool
isEmpty() const;

inline bool
isNotEmpty() const { return (not isEmpty()); }

/**
* \brief Get number of items in the list
*
Expand Down
6 changes: 6 additions & 0 deletions src/modm/container/dynamic_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ namespace modm
return (this->size == 0);
}

inline bool
isNotEmpty() const
{
return not isEmpty();
}

/**
* \brief Return size
*
Expand Down
3 changes: 3 additions & 0 deletions src/modm/container/linked_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ namespace modm
inline bool
isEmpty() const;

inline bool
isNotEmpty() const { return (not isEmpty()); }

/**
* \brief Get number of elements
*
Expand Down
2 changes: 1 addition & 1 deletion src/modm/container/linked_list_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ template <typename T, typename Allocator>
void
modm::LinkedList<T, Allocator>::removeAll()
{
while (!this->isEmpty()) {
while (this->isNotEmpty()) {
this->removeFront();
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/modm/container/stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ namespace modm
return c.isEmpty();
}

inline bool
isNotEmpty()
{
return not c.isEmpty();
}

bool
isFull()
{
Expand Down
4 changes: 2 additions & 2 deletions src/modm/platform/can/lpc/c_can.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ modm::platform::Can::CAN_tx(uint8_t /* msg_obj_num */)
// All message objects empty. Otherwise the order of messages
// is not maintained

while (!txQueue.isEmpty())
while (txQueue.isNotEmpty())
{
// Still messages in the queue.

Expand Down Expand Up @@ -349,7 +349,7 @@ bool
modm::platform::Can::isMessageAvailable()
{
%% if options["buffer.rx"] > 0
return !rxQueue.isEmpty();
return rxQueue.isNotEmpty();
%% else
/* Check if new data is available in the Message
* Objects 1 to 16. */
Expand Down
2 changes: 1 addition & 1 deletion src/modm/platform/i2c/stm32/i2c_master.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ modm::platform::I2cMaster{{ id }}::reset()
if (transaction) transaction->detaching(DetachCause::ErrorCondition);
transaction = nullptr;
// remove all queued transactions
while(!queue.isEmpty())
while(queue.isNotEmpty())
{
ConfiguredTransaction next = queue.get();
if (next.transaction) next.transaction->detaching(DetachCause::ErrorCondition);
Expand Down
2 changes: 1 addition & 1 deletion src/modm/platform/uart/at90_tiny_mega/uart_rx.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ std::size_t
modm::platform::Uart{{ id }}::discardReceiveBuffer()
{
std::size_t i(0);
while(!rxBuffer.isEmpty())
while(rxBuffer.isNotEmpty())
{
rxBuffer.pop();
++i;
Expand Down
2 changes: 1 addition & 1 deletion src/modm/platform/uart/at90_tiny_mega/uart_tx.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ modm::platform::Uart{{ id }}::discardTransmitBuffer()
}

std::size_t i = 0;
while(!txBuffer.isEmpty())
while(txBuffer.isNotEmpty())
{
txBuffer.pop();
++i;
Expand Down
4 changes: 2 additions & 2 deletions src/modm/platform/uart/cortex/itm.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Itm::discardTransmitBuffer()
{
%% if options["buffer.tx"]
std::size_t count = 0;
for(; not txBuffer.isEmpty(); txBuffer.pop())
for(; txBuffer.isNotEmpty(); txBuffer.pop())
++count;
return count;
%% else
Expand Down Expand Up @@ -180,7 +180,7 @@ Itm::update()
static uint32_t buffer{0};
static uint8_t size{0};

while (not txBuffer.isEmpty() and size < 4)
while (txBuffer.isNotEmpty() and size < 4)
{
const uint8_t data = txBuffer.get();
txBuffer.pop();
Expand Down
6 changes: 3 additions & 3 deletions src/modm/platform/uart/lpc/uart.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ bool
modm::platform::Uart1::read(uint8_t& data)
{
%% if options["buffer.rx"] > 16
if (not rxBuffer.isEmpty())
if (rxBuffer.isNotEmpty())
{
data = rxBuffer.get();
rxBuffer.pop();
Expand Down Expand Up @@ -298,7 +298,7 @@ modm::platform::Uart1::discardReceiveBuffer()
{
std::size_t count(0);
%% if options["buffer.rx"] > 16
while(!rxBuffer.isEmpty())
while(rxBuffer.isNotEmpty())
{
++count;
rxBuffer.pop();
Expand Down Expand Up @@ -346,7 +346,7 @@ MODM_ISR(UART)
return;
}

while (!txBuffer.isEmpty() and (charsLeft-- > 0))
while (txBuffer.isNotEmpty() and (charsLeft-- > 0))
{
// Write to the hardware buffer
LPC_UART->THR = txBuffer.get();
Expand Down
4 changes: 2 additions & 2 deletions src/modm/platform/uart/rp/uart.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ modm::platform::Uart{{ id }}::discardReceiveBuffer()
{
std::size_t count(0);
%% if options["buffer.rx"] > fifo_size
while(!rxBuffer.isEmpty())
while(rxBuffer.isNotEmpty())
{
++count;
rxBuffer.pop();
Expand All @@ -253,7 +253,7 @@ MODM_ISR(UART{{ id }}_IRQ)
%% if options["buffer.tx"] > fifo_size
if (IValue & UART_UARTMIS_TXMIS_BITS)
{
while (!txBuffer.isEmpty() and !tx_fifo_full())
while (txBuffer.isNotEmpty() and !tx_fifo_full())
{
// Write to the hardware buffer
uart{{ id }}_hw->dr = txBuffer.get();
Expand Down
4 changes: 2 additions & 2 deletions src/modm/platform/uart/stm32/uart.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ std::size_t
std::size_t count = 0;
// disable interrupt since buffer will be cleared
{{ hal }}::disableInterrupt({{ hal }}::Interrupt::TxEmpty);
while(!txBuffer.isEmpty()) {
while(txBuffer.isNotEmpty()) {
++count;
txBuffer.pop();
}
Expand Down Expand Up @@ -202,7 +202,7 @@ std::size_t
{
%% if options["buffer.rx"]
std::size_t count = 0;
while(!rxBuffer.isEmpty()) {
while(rxBuffer.isNotEmpty()) {
++count;
rxBuffer.pop();
}
Expand Down
2 changes: 1 addition & 1 deletion src/modm/platform/uart/xmega/uart_buffered_rx.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ std::size_t
modm::platform::Uart{{ id }}::discardReceiveBuffer()
{
std::size_t i(0);
while(!rxBuffer.isEmpty())
while(rxBuffer.isNotEmpty())
{
rxBuffer.pop();
++i;
Expand Down
2 changes: 1 addition & 1 deletion src/modm/platform/uart/xmega/uart_buffered_tx.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ modm::platform::Uart{{ id }}::discardTransmitBuffer()
}

std::size_t i = 0;
while(!txBuffer.isEmpty())
while(txBuffer.isNotEmpty())
{
txBuffer.pop();
++i;
Expand Down
6 changes: 3 additions & 3 deletions src/modm/platform/uart/xmega/uart_flow.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ modm::platform::BufferedUartFlow{{ id }}::read(uint8_t& c)
// Small hack: When the AVR stopped transmission due to a high RTS signal try to resume
// transmission now when RTS is low again and there is something to send.
// TODO: can be removed if RTS interrupt is included.
if (!RTS::read() && !txBuffer.isEmpty()) {
if ((not RTS::read()) && txBuffer.isNotEmpty()) {
// enable DRE interrupt to resume transmission
USART{{ id }}_CTRLA = USART_RXCINTLVL_MED_gc | USART_DREINTLVL_MED_gc;
}
Expand Down Expand Up @@ -219,7 +219,7 @@ uint8_t
modm::platform::BufferedUartFlow{{ id }}::flushReceiveBuffer()
{
uint8_t i = 0;
while(!rxBuffer.isEmpty()) {
while(rxBuffer.isNotEmpty()) {
rxBuffer.pop();
++i;
}
Expand All @@ -236,7 +236,7 @@ modm::platform::BufferedUartFlow{{ id }}::flushReceiveBuffer()
//modm::platform::BufferedUartFlow{{ id }}::flushTransmitBuffer()
//{
// uint8_t i(0);
// while(!txBuffer.isEmpty()) {
// while(txBuffer.isNotEmpty()) {
// txBuffer.pop();
// ++i;
// }
Expand Down
2 changes: 1 addition & 1 deletion src/modm/ui/gui/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ modm::gui::View::update()

modm::gui::inputQueue* input_queue = this->stack->getInputQueue();

while(!input_queue->isEmpty()) {
while(input_queue->isNotEmpty()) {

// pop input event
ev = input_queue->get();
Expand Down
1 change: 1 addition & 0 deletions test/modm/architecture/driver/atomic/atomic_queue_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ AtomicQueueTest::testQueue()
modm::atomic::Queue<int16_t, 3> queue;

TEST_ASSERT_TRUE(queue.isEmpty());
TEST_ASSERT_FALSE(queue.isNotEmpty());
TEST_ASSERT_EQUALS(queue.getMaxSize(), 3);

TEST_ASSERT_TRUE(queue.push(1));
Expand Down
2 changes: 1 addition & 1 deletion test/modm/communication/xpcc/fake_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ FakeBackend::sendPacket(const xpcc::Header &header,
bool
FakeBackend::isPacketAvailable() const
{
return !this->messagesToReceive.isEmpty();
return this->messagesToReceive.isNotEmpty();
}

const xpcc::Header&
Expand Down
1 change: 1 addition & 0 deletions test/modm/container/bounded_deque_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ BoundedDequeTest::testForward()
modm::BoundedDeque<int16_t, 3> deque;

TEST_ASSERT_TRUE(deque.isEmpty());
TEST_ASSERT_FALSE(deque.isNotEmpty());
TEST_ASSERT_EQUALS(deque.getMaxSize(), 3U);

TEST_ASSERT_EQUALS(deque.getSize(), 0U);
Expand Down
1 change: 1 addition & 0 deletions test/modm/container/bounded_queue_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ BoundedQueueTest::testQueue()
modm::BoundedQueue<int16_t, 5> queue;

TEST_ASSERT_TRUE(queue.isEmpty());
TEST_ASSERT_FALSE(queue.isNotEmpty());

TEST_ASSERT_EQUALS(queue.getMaxSize(), 5U);

Expand Down
1 change: 1 addition & 0 deletions test/modm/container/bounded_stack_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ BoundedStackTest::testStack()
modm::BoundedStack<int16_t, 3> stack;

TEST_ASSERT_TRUE(stack.isEmpty());
TEST_ASSERT_FALSE(stack.isNotEmpty());
TEST_ASSERT_EQUALS(stack.getMaxSize(), 3U);

TEST_ASSERT_TRUE(stack.push(1));
Expand Down
1 change: 1 addition & 0 deletions test/modm/container/doubly_linked_list_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ DoublyLinkedListTest::testConstructor()
modm::DoublyLinkedList< unittest::CountType > list;

TEST_ASSERT_TRUE(list.isEmpty());
TEST_ASSERT_FALSE(list.isNotEmpty());
TEST_ASSERT_EQUALS(unittest::CountType::numberOfDefaultConstructorCalls, 0U);
}

Expand Down
1 change: 1 addition & 0 deletions test/modm/container/dynamic_array_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ DynamicArrayTest::testDefaultConstrutor()
Container array;

TEST_ASSERT_TRUE(array.isEmpty());
TEST_ASSERT_FALSE(array.isNotEmpty());
TEST_ASSERT_EQUALS(array.getSize(), 0U);
}

Expand Down
1 change: 1 addition & 0 deletions test/modm/container/linked_list_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ LinkedListTest::testConstructor()
modm::LinkedList< unittest::CountType > list;

TEST_ASSERT_TRUE(list.isEmpty());
TEST_ASSERT_FALSE(list.isNotEmpty());
TEST_ASSERT_EQUALS(unittest::CountType::numberOfDefaultConstructorCalls, 0U);
}

Expand Down
6 changes: 3 additions & 3 deletions test/modm/mock/spi_master.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ modm_test::platform::SpiMaster::transfer(uint8_t data)
{
txBuffer.append(data);

if(!rxBuffer.isEmpty()) {
if(rxBuffer.isNotEmpty()) {
tmp = rxBuffer.getFront();
rxBuffer.removeFront();
}
Expand Down Expand Up @@ -77,14 +77,14 @@ modm_test::platform::SpiMaster::transfer(uint8_t * tx, uint8_t * rx, std::size_t
}

if(rx != nullptr) {
if(!rxBuffer.isEmpty()) {
if(rxBuffer.isNotEmpty()) {
rx[i] = rxBuffer.getFront();
}
else {
rx[i] = 0;
}
}
if(!rxBuffer.isEmpty()) {
if(rxBuffer.isNotEmpty()) {
rxBuffer.removeFront();
}
}
Expand Down

0 comments on commit 5bf59a8

Please sign in to comment.