From eea2d5dcb52fd96c5208e8446f2804792bfbe62c Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 26 Apr 2016 22:12:19 +1000 Subject: [PATCH] DataFlash_File: avoid integer wrap when checking minimum time --- libraries/DataFlash/DataFlash_File.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/DataFlash/DataFlash_File.cpp b/libraries/DataFlash/DataFlash_File.cpp index 940db1e8f9d..0aef56cea84 100644 --- a/libraries/DataFlash/DataFlash_File.cpp +++ b/libraries/DataFlash/DataFlash_File.cpp @@ -1025,7 +1025,9 @@ void DataFlash_File::flush(void) BUF_AVAILABLE(_writebuf)) { // convince the IO timer that it really is OK to write out // less than _writebuf_chunk bytes: - _last_write_time = tnow - 2000000; + if (tnow > 2000001) { // avoid resetting _last_write_time to 0 + _last_write_time = tnow - 2000001; + } _io_timer(); } hal.scheduler->resume_timer_procs();