From 5012dffeaede4228d2109358b1d08adfafdd4d19 Mon Sep 17 00:00:00 2001 From: Phillip Khandeliants Date: Fri, 21 Apr 2017 18:13:06 +0300 Subject: [PATCH] Potentially infinite and deleted loops found by PVS-Studio (#7100) - Fixed V712 - The compiler can optimize this code by creating an infinite loop, or simply deleting it. - There is need to add a volatile qualifier to the '_ExitFlag' and 'sim_delay' variables. --- src/drivers/device/vdev_posix.cpp | 2 +- src/platforms/posix/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/drivers/device/vdev_posix.cpp b/src/drivers/device/vdev_posix.cpp index 354b5cdd20..509f247956 100644 --- a/src/drivers/device/vdev_posix.cpp +++ b/src/drivers/device/vdev_posix.cpp @@ -55,7 +55,7 @@ using namespace device; pthread_mutex_t filemutex = PTHREAD_MUTEX_INITIALIZER; px4_sem_t lockstep_sem; bool sim_lockstep = false; -bool sim_delay = false; +volatile bool sim_delay = false; extern "C" { diff --git a/src/platforms/posix/main.cpp b/src/platforms/posix/main.cpp index cce995afd9..3a66b60a76 100644 --- a/src/platforms/posix/main.cpp +++ b/src/platforms/posix/main.cpp @@ -71,7 +71,7 @@ const unsigned path_max_len = PATH_MAX; const unsigned path_max_len = 1024; #endif -static bool _ExitFlag = false; +static volatile bool _ExitFlag = false; static struct termios orig_term;