From 916b91f13e6309a4a655a01c7278165603cde8f5 Mon Sep 17 00:00:00 2001 From: Janne Kiiskila Date: Thu, 7 Nov 2019 17:19:57 +0200 Subject: [PATCH] SerialBase.h|cpp [-Wreorder] compiler warning fix This fixes: ``` [Warning] SerialBase.h@351,22: 'mbed::SerialBase::_flow2' will be initialized after [-Wreorder] [Warning] SerialBase.h@343,22: 'bool mbed::SerialBase::_rx_enabled' [-Wreorder] [Warning] SerialBase.cpp@26,1: when initialized here [-Wreorder] ``` by using C++11 style initializer for SerialBase Kudos to Kevin Bracey, as her his suggestion - we can drop the initializer list if we just set the values directly in the SerialBase.h. No need to worry about the "right order" after that. --- drivers/SerialBase.h | 20 ++++++++++---------- drivers/source/SerialBase.cpp | 13 +------------ 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/SerialBase.h b/drivers/SerialBase.h index d2a41a46a2..9dc31512f1 100644 --- a/drivers/SerialBase.h +++ b/drivers/SerialBase.h @@ -329,26 +329,26 @@ protected: #if DEVICE_SERIAL_ASYNCH CThunk _thunk_irq; - DMAUsage _tx_usage; - DMAUsage _rx_usage; + DMAUsage _tx_usage = DMA_USAGE_NEVER; + DMAUsage _rx_usage = DMA_USAGE_NEVER; event_callback_t _tx_callback; event_callback_t _rx_callback; - bool _tx_asynch_set; - bool _rx_asynch_set; + bool _tx_asynch_set = false; + bool _rx_asynch_set = false; #endif - serial_t _serial; + serial_t _serial {}; Callback _irq[IrqCnt]; int _baud; - bool _rx_enabled; - bool _tx_enabled; + bool _rx_enabled = true; + bool _tx_enabled = true; const PinName _tx_pin; const PinName _rx_pin; #if DEVICE_SERIAL_FC - Flow _flow_type; - PinName _flow1; - PinName _flow2; + Flow _flow_type = Disabled; + PinName _flow1 = NC; + PinName _flow2 = NC; #endif #endif diff --git a/drivers/source/SerialBase.cpp b/drivers/source/SerialBase.cpp index 8172c93104..cdc8636bbf 100644 --- a/drivers/source/SerialBase.cpp +++ b/drivers/source/SerialBase.cpp @@ -25,20 +25,9 @@ namespace mbed { SerialBase::SerialBase(PinName tx, PinName rx, int baud) : #if DEVICE_SERIAL_ASYNCH - _thunk_irq(this), _tx_usage(DMA_USAGE_NEVER), - _rx_usage(DMA_USAGE_NEVER), _tx_callback(NULL), - _rx_callback(NULL), _tx_asynch_set(false), - _rx_asynch_set(false), + _thunk_irq(this), #endif - _serial(), _baud(baud), -#if DEVICE_SERIAL_FC - _flow_type(Disabled), - _flow1(NC), - _flow2(NC), -#endif - _rx_enabled(true), - _tx_enabled(true), _tx_pin(tx), _rx_pin(rx) {