Skip to content

Commit a98d04c

Browse files
Use isNotEmpty() instead of !isEmpty()
1 parent 9dc4f19 commit a98d04c

28 files changed

+52
-27
lines changed

src/modm/communication/rpr/interface_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ template <typename Device, std::size_t N>
467467
void
468468
modm::rpr::Interface<Device, N>::popMessage(Queue &queue)
469469
{
470-
if (!queue.isEmpty())
470+
if (queue.isNotEmpty())
471471
{
472472
// deallocate the external buffer
473473
Message message = queue.get();

src/modm/communication/xpcc/backend/can/connector_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ xpcc::CanConnector<Driver>::sendWaitingMessages()
123123
}
124124
else if (canDriver->getBusState() != Driver::BusState::Connected) {
125125
// No connection to the CAN bus, drop all messages which should be send
126-
while (!sendList.isEmpty()) {
126+
while (sendList.isNotEmpty()) {
127127
sendList.removeFront();
128128
}
129129
return;

src/modm/container/doubly_linked_list.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ namespace modm
4242
inline bool
4343
isEmpty() const;
4444

45+
inline bool
46+
isNotEmpty() const { return (not isEmpty()); }
47+
4548
/**
4649
* \brief Get number of items in the list
4750
*

src/modm/container/dynamic_array.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ namespace modm
104104
return (this->size == 0);
105105
}
106106

107+
inline bool
108+
isNotEmpty() const
109+
{
110+
return not isEmpty();
111+
}
112+
107113
/**
108114
* \brief Return size
109115
*

src/modm/container/linked_list.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ namespace modm
5050
inline bool
5151
isEmpty() const;
5252

53+
inline bool
54+
isNotEmpty() const { return (not isEmpty()); }
55+
5356
/**
5457
* \brief Get number of elements
5558
*

src/modm/container/linked_list_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ template <typename T, typename Allocator>
179179
void
180180
modm::LinkedList<T, Allocator>::removeAll()
181181
{
182-
while (!this->isEmpty()) {
182+
while (this->isNotEmpty()) {
183183
this->removeFront();
184184
}
185185
}

src/modm/container/stack.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ namespace modm
4747
return c.isEmpty();
4848
}
4949

50+
inline bool
51+
isNotEmpty()
52+
{
53+
return not c.isEmpty();
54+
}
55+
5056
bool
5157
isFull()
5258
{

src/modm/platform/can/lpc/c_can.cpp.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ modm::platform::Can::CAN_tx(uint8_t /* msg_obj_num */)
162162
// All message objects empty. Otherwise the order of messages
163163
// is not maintained
164164

165-
while (!txQueue.isEmpty())
165+
while (txQueue.isNotEmpty())
166166
{
167167
// Still messages in the queue.
168168

@@ -349,7 +349,7 @@ bool
349349
modm::platform::Can::isMessageAvailable()
350350
{
351351
%% if options["buffer.rx"] > 0
352-
return !rxQueue.isEmpty();
352+
return rxQueue.isNotEmpty();
353353
%% else
354354
/* Check if new data is available in the Message
355355
* Objects 1 to 16. */

src/modm/platform/i2c/stm32/i2c_master.cpp.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ modm::platform::I2cMaster{{ id }}::reset()
622622
if (transaction) transaction->detaching(DetachCause::ErrorCondition);
623623
transaction = nullptr;
624624
// remove all queued transactions
625-
while(!queue.isEmpty())
625+
while(queue.isNotEmpty())
626626
{
627627
ConfiguredTransaction next = queue.get();
628628
if (next.transaction) next.transaction->detaching(DetachCause::ErrorCondition);

src/modm/platform/uart/at90_tiny_mega/uart_rx.cpp.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ std::size_t
101101
modm::platform::Uart{{ id }}::discardReceiveBuffer()
102102
{
103103
std::size_t i(0);
104-
while(!rxBuffer.isEmpty())
104+
while(rxBuffer.isNotEmpty())
105105
{
106106
rxBuffer.pop();
107107
++i;

src/modm/platform/uart/at90_tiny_mega/uart_tx.cpp.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ modm::platform::Uart{{ id }}::discardTransmitBuffer()
126126
}
127127

128128
std::size_t i = 0;
129-
while(!txBuffer.isEmpty())
129+
while(txBuffer.isNotEmpty())
130130
{
131131
txBuffer.pop();
132132
++i;

src/modm/platform/uart/cortex/itm.cpp.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Itm::discardTransmitBuffer()
126126
{
127127
%% if options["buffer.tx"]
128128
std::size_t count = 0;
129-
for(; not txBuffer.isEmpty(); txBuffer.pop())
129+
for(; txBuffer.isNotEmpty(); txBuffer.pop())
130130
++count;
131131
return count;
132132
%% else
@@ -180,7 +180,7 @@ Itm::update()
180180
static uint32_t buffer{0};
181181
static uint8_t size{0};
182182

183-
while (not txBuffer.isEmpty() and size < 4)
183+
while (txBuffer.isNotEmpty() and size < 4)
184184
{
185185
const uint8_t data = txBuffer.get();
186186
txBuffer.pop();

src/modm/platform/uart/lpc/uart.cpp.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ bool
252252
modm::platform::Uart1::read(uint8_t& data)
253253
{
254254
%% if options["buffer.rx"] > 16
255-
if (not rxBuffer.isEmpty())
255+
if (rxBuffer.isNotEmpty())
256256
{
257257
data = rxBuffer.get();
258258
rxBuffer.pop();
@@ -298,7 +298,7 @@ modm::platform::Uart1::discardReceiveBuffer()
298298
{
299299
std::size_t count(0);
300300
%% if options["buffer.rx"] > 16
301-
while(!rxBuffer.isEmpty())
301+
while(rxBuffer.isNotEmpty())
302302
{
303303
++count;
304304
rxBuffer.pop();
@@ -346,7 +346,7 @@ MODM_ISR(UART)
346346
return;
347347
}
348348

349-
while (!txBuffer.isEmpty() and (charsLeft-- > 0))
349+
while (txBuffer.isNotEmpty() and (charsLeft-- > 0))
350350
{
351351
// Write to the hardware buffer
352352
LPC_UART->THR = txBuffer.get();

src/modm/platform/uart/rp/uart.cpp.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ modm::platform::Uart{{ id }}::discardReceiveBuffer()
229229
{
230230
std::size_t count(0);
231231
%% if options["buffer.rx"] > fifo_size
232-
while(!rxBuffer.isEmpty())
232+
while(rxBuffer.isNotEmpty())
233233
{
234234
++count;
235235
rxBuffer.pop();
@@ -253,7 +253,7 @@ MODM_ISR(UART{{ id }}_IRQ)
253253
%% if options["buffer.tx"] > fifo_size
254254
if (IValue & UART_UARTMIS_TXMIS_BITS)
255255
{
256-
while (!txBuffer.isEmpty() and !tx_fifo_full())
256+
while (txBuffer.isNotEmpty() and !tx_fifo_full())
257257
{
258258
// Write to the hardware buffer
259259
uart{{ id }}_hw->dr = txBuffer.get();

src/modm/platform/uart/stm32/uart.cpp.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ std::size_t
131131
std::size_t count = 0;
132132
// disable interrupt since buffer will be cleared
133133
{{ hal }}::disableInterrupt({{ hal }}::Interrupt::TxEmpty);
134-
while(!txBuffer.isEmpty()) {
134+
while(txBuffer.isNotEmpty()) {
135135
++count;
136136
txBuffer.pop();
137137
}
@@ -202,7 +202,7 @@ std::size_t
202202
{
203203
%% if options["buffer.rx"]
204204
std::size_t count = 0;
205-
while(!rxBuffer.isEmpty()) {
205+
while(rxBuffer.isNotEmpty()) {
206206
++count;
207207
rxBuffer.pop();
208208
}

src/modm/platform/uart/xmega/uart_buffered_rx.cpp.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ std::size_t
8383
modm::platform::Uart{{ id }}::discardReceiveBuffer()
8484
{
8585
std::size_t i(0);
86-
while(!rxBuffer.isEmpty())
86+
while(rxBuffer.isNotEmpty())
8787
{
8888
rxBuffer.pop();
8989
++i;

src/modm/platform/uart/xmega/uart_buffered_tx.cpp.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ modm::platform::Uart{{ id }}::discardTransmitBuffer()
116116
}
117117

118118
std::size_t i = 0;
119-
while(!txBuffer.isEmpty())
119+
while(txBuffer.isNotEmpty())
120120
{
121121
txBuffer.pop();
122122
++i;

src/modm/platform/uart/xmega/uart_flow.cpp.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ modm::platform::BufferedUartFlow{{ id }}::read(uint8_t& c)
158158
// Small hack: When the AVR stopped transmission due to a high RTS signal try to resume
159159
// transmission now when RTS is low again and there is something to send.
160160
// TODO: can be removed if RTS interrupt is included.
161-
if (!RTS::read() && !txBuffer.isEmpty()) {
161+
if ((not RTS::read()) && txBuffer.isNotEmpty()) {
162162
// enable DRE interrupt to resume transmission
163163
USART{{ id }}_CTRLA = USART_RXCINTLVL_MED_gc | USART_DREINTLVL_MED_gc;
164164
}
@@ -219,7 +219,7 @@ uint8_t
219219
modm::platform::BufferedUartFlow{{ id }}::flushReceiveBuffer()
220220
{
221221
uint8_t i = 0;
222-
while(!rxBuffer.isEmpty()) {
222+
while(rxBuffer.isNotEmpty()) {
223223
rxBuffer.pop();
224224
++i;
225225
}
@@ -236,7 +236,7 @@ modm::platform::BufferedUartFlow{{ id }}::flushReceiveBuffer()
236236
//modm::platform::BufferedUartFlow{{ id }}::flushTransmitBuffer()
237237
//{
238238
// uint8_t i(0);
239-
// while(!txBuffer.isEmpty()) {
239+
// while(txBuffer.isNotEmpty()) {
240240
// txBuffer.pop();
241241
// ++i;
242242
// }

src/modm/ui/gui/view.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ modm::gui::View::update()
4040

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

43-
while(!input_queue->isEmpty()) {
43+
while(input_queue->isNotEmpty()) {
4444

4545
// pop input event
4646
ev = input_queue->get();

test/modm/architecture/driver/atomic/atomic_queue_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ AtomicQueueTest::testQueue()
2121
modm::atomic::Queue<int16_t, 3> queue;
2222

2323
TEST_ASSERT_TRUE(queue.isEmpty());
24+
TEST_ASSERT_FALSE(queue.isNotEmpty());
2425
TEST_ASSERT_EQUALS(queue.getMaxSize(), 3);
2526

2627
TEST_ASSERT_TRUE(queue.push(1));

test/modm/communication/xpcc/fake_backend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ FakeBackend::sendPacket(const xpcc::Header &header,
3030
bool
3131
FakeBackend::isPacketAvailable() const
3232
{
33-
return !this->messagesToReceive.isEmpty();
33+
return this->messagesToReceive.isNotEmpty();
3434
}
3535

3636
const xpcc::Header&

test/modm/container/bounded_deque_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ BoundedDequeTest::testForward()
2323
modm::BoundedDeque<int16_t, 3> deque;
2424

2525
TEST_ASSERT_TRUE(deque.isEmpty());
26+
TEST_ASSERT_FALSE(deque.isNotEmpty());
2627
TEST_ASSERT_EQUALS(deque.getMaxSize(), 3U);
2728

2829
TEST_ASSERT_EQUALS(deque.getSize(), 0U);

test/modm/container/bounded_queue_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ BoundedQueueTest::testQueue()
2121
modm::BoundedQueue<int16_t, 5> queue;
2222

2323
TEST_ASSERT_TRUE(queue.isEmpty());
24+
TEST_ASSERT_FALSE(queue.isNotEmpty());
2425

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

test/modm/container/bounded_stack_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ BoundedStackTest::testStack()
2121
modm::BoundedStack<int16_t, 3> stack;
2222

2323
TEST_ASSERT_TRUE(stack.isEmpty());
24+
TEST_ASSERT_FALSE(stack.isNotEmpty());
2425
TEST_ASSERT_EQUALS(stack.getMaxSize(), 3U);
2526

2627
TEST_ASSERT_TRUE(stack.push(1));

test/modm/container/doubly_linked_list_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ DoublyLinkedListTest::testConstructor()
3030
modm::DoublyLinkedList< unittest::CountType > list;
3131

3232
TEST_ASSERT_TRUE(list.isEmpty());
33+
TEST_ASSERT_FALSE(list.isNotEmpty());
3334
TEST_ASSERT_EQUALS(unittest::CountType::numberOfDefaultConstructorCalls, 0U);
3435
}
3536

test/modm/container/dynamic_array_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ DynamicArrayTest::testDefaultConstrutor()
3030
Container array;
3131

3232
TEST_ASSERT_TRUE(array.isEmpty());
33+
TEST_ASSERT_FALSE(array.isNotEmpty());
3334
TEST_ASSERT_EQUALS(array.getSize(), 0U);
3435
}
3536

test/modm/container/linked_list_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ LinkedListTest::testConstructor()
3131
modm::LinkedList< unittest::CountType > list;
3232

3333
TEST_ASSERT_TRUE(list.isEmpty());
34+
TEST_ASSERT_FALSE(list.isNotEmpty());
3435
TEST_ASSERT_EQUALS(unittest::CountType::numberOfDefaultConstructorCalls, 0U);
3536
}
3637

test/modm/mock/spi_master.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ modm_test::platform::SpiMaster::transfer(uint8_t data)
4949
{
5050
txBuffer.append(data);
5151

52-
if(!rxBuffer.isEmpty()) {
52+
if(rxBuffer.isNotEmpty()) {
5353
tmp = rxBuffer.getFront();
5454
rxBuffer.removeFront();
5555
}
@@ -77,14 +77,14 @@ modm_test::platform::SpiMaster::transfer(uint8_t * tx, uint8_t * rx, std::size_t
7777
}
7878

7979
if(rx != nullptr) {
80-
if(!rxBuffer.isEmpty()) {
80+
if(rxBuffer.isNotEmpty()) {
8181
rx[i] = rxBuffer.getFront();
8282
}
8383
else {
8484
rx[i] = 0;
8585
}
8686
}
87-
if(!rxBuffer.isEmpty()) {
87+
if(rxBuffer.isNotEmpty()) {
8888
rxBuffer.removeFront();
8989
}
9090
}

0 commit comments

Comments
 (0)