mirror of https://github.com/ARMmbed/mbed-os.git
Durations don't always zero init
In a couple of places I assumed that durations and time_points always zero-initialised. This is incorrect - they act as if they were their representation, so integer durations only zero-init when static. You can zero init (like integers) by having `{}` initialisation.pull/12425/head
parent
58388b7e5e
commit
b614bd3113
|
@ -149,7 +149,7 @@ protected:
|
|||
void attach_absolute(Callback<void()> func, TickerDataClock::time_point abs_time);
|
||||
|
||||
void handler() override;
|
||||
std::chrono::microseconds _delay; /**< Time delay (in microseconds) for resetting the multishot callback. */
|
||||
std::chrono::microseconds _delay{0}; /**< Time delay (in microseconds) for resetting the multishot callback. */
|
||||
Callback<void()> _function; /**< Callback. */
|
||||
bool _lock_deepsleep; /**< Flag which indicates if deep sleep should be disabled. */
|
||||
#endif
|
||||
|
|
|
@ -111,8 +111,8 @@ protected:
|
|||
TimerBase(const ticker_data_t *data, bool lock_deepsleep);
|
||||
~TimerBase();
|
||||
std::chrono::microseconds slicetime() const;
|
||||
TickerDataClock::time_point _start; // the start time of the latest slice
|
||||
std::chrono::microseconds _time; // any accumulated time from previous slices
|
||||
TickerDataClock::time_point _start{}; // the start time of the latest slice
|
||||
std::chrono::microseconds _time{}; // any accumulated time from previous slices
|
||||
TickerDataClock _ticker_data;
|
||||
bool _lock_deepsleep; // flag that indicates if deep sleep should be disabled
|
||||
bool _running = false; // whether the timer is running
|
||||
|
|
|
@ -100,7 +100,7 @@ microseconds TimerBase::elapsed_time() const
|
|||
microseconds TimerBase::slicetime() const
|
||||
{
|
||||
CriticalSectionLock lock;
|
||||
microseconds ret;
|
||||
microseconds ret = 0us;
|
||||
if (_running) {
|
||||
ret = _ticker_data.now() - _start;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue