From d908300077c908ea32fb9509bedaa7045fb771f1 Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 8 Jun 2017 22:51:32 -0400 Subject: [PATCH] refactoring --- firmware/util/efilib2.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/firmware/util/efilib2.cpp b/firmware/util/efilib2.cpp index 6e7a44da05..46fecad763 100644 --- a/firmware/util/efilib2.cpp +++ b/firmware/util/efilib2.cpp @@ -69,19 +69,18 @@ efitime_t Overflow64Counter::get() { * http://stackoverflow.com/questions/5162673/how-to-read-two-32bit-counters-as-a-64bit-integer-without-race-condition */ efitime_t localH; + efitime_t localH2; uint32_t localLow; int counter = 0; - while (true) { + do { localH = state.highBits; localLow = state.lowBits; - efitime_t localH2 = state.highBits; - if (localH == localH2) - break; + localH2 = state.highBits; #if EFI_PROD_CODE || defined(__DOXYGEN__) if (counter++ == 10000) chDbgPanic("lock-free frozen"); #endif /* EFI_PROD_CODE */ - } + } while (localH != localH2); /** * We need to take current counter after making a local 64 bit snapshot */