]> granicus.if.org Git - gc/commitdiff
Workaround 'condition appendToFile is always false' cppcheck false positive
authorIvan Maidanski <ivmai@mail.ru>
Thu, 26 Sep 2019 08:31:27 +0000 (11:31 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 26 Sep 2019 08:31:27 +0000 (11:31 +0300)
* misc.c [(MSWIN32 && !CONSOLE_LOG || MSWINCE) && !MSWINRT_FLAVOR
&& NO_GETENV_WIN32 && CPPCHECK] (GC_CreateLogFile): Define appendToFile
as macro (to FALSE) instead of a local variable; undefine appendToFile
at the function.

misc.c

diff --git a/misc.c b/misc.c
index faa64e6360b5303c057179741e5292080f0f7c14..3247dfc4864d52fa22476fb8f9c56e4c21abd606 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -1552,7 +1552,11 @@ GC_API void GC_CALL GC_enable_incremental(void)
 
 # else
     TCHAR *logPath;
-    BOOL appendToFile = FALSE;
+#   if defined(NO_GETENV_WIN32) && defined(CPPCHECK)
+#     define appendToFile FALSE
+#   else
+      BOOL appendToFile = FALSE;
+#   endif
 #   if !defined(NO_GETENV_WIN32) || !defined(OLD_WIN32_LOG_FILE)
       TCHAR pathBuf[_MAX_PATH + 0x10]; /* buffer for path + ext */
 
@@ -1597,6 +1601,7 @@ GC_API void GC_CALL GC_enable_incremental(void)
                                   /* Seek to file end (ignoring any error) */
       }
 #   endif
+#   undef appendToFile
 # endif
     return hFile;
   }