Skip to content

Commit beafcf3

Browse files
Paul Thompsonadbridge
authored andcommitted
Eliminate complier warning and remove superfluous call to empty()
Appears when complied with -O3 optimization level Compile: UARTSerial.cpp ../drivers/UARTSerial.cpp: In member function 'void mbed::UARTSerial::tx_irq()': ../drivers/UARTSerial.cpp:314:31: warning: 'data' may be used uninitialized in this function [-Wmaybe-uninitialized] SerialBase::_base_putc(data);
1 parent 1be48dc commit beafcf3

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/UARTSerial.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,11 @@ void UARTSerial::rx_irq(void)
305305
void UARTSerial::tx_irq(void)
306306
{
307307
bool was_full = _txbuf.full();
308+
char data;
308309

309310
/* Write to the peripheral if there is something to write
310311
* and if the peripheral is available to write. */
311-
while (!_txbuf.empty() && SerialBase::writeable()) {
312-
char data;
313-
_txbuf.pop(data);
312+
while (SerialBase::writeable() && _txbuf.pop(data)) {
314313
SerialBase::_base_putc(data);
315314
}
316315

0 commit comments

Comments
 (0)