Eliminate 'scope of variable can be reduced' cppcheck warnings (Win32)
authorIvan Maidanski <ivmai@mail.ru>
Tue, 7 Mar 2017 15:41:13 +0000 (18:41 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 7 Mar 2017 15:50:58 +0000 (18:50 +0300)
* os_dep.c [MSWIN32] (GC_register_root_section): Move "protect" local
variable declaration to the inner scope where the variable is actually
used.
* win32_threads.c [!MSWINCE && !CYGWIN32] (GC_CreateThread): Move
"thread_h" local variable declaration to the inner scope.

os_dep.c
win32_threads.c

index ddb577d..08872a0 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -1817,7 +1817,6 @@ void GC_register_data_segments(void)
   STATIC void GC_register_root_section(ptr_t static_root)
   {
       MEMORY_BASIC_INFORMATION buf;
-      DWORD protect;
       LPVOID p;
       char * base;
       char * limit;
@@ -1827,6 +1826,7 @@ void GC_register_data_segments(void)
       while ((word)p < (word)GC_sysinfo.lpMaximumApplicationAddress) {
         size_t result = VirtualQuery(p, &buf, sizeof(buf));
         char * new_limit;
+        DWORD protect;
 
         if (result != sizeof(buf) || buf.AllocationBase == 0
             || GC_is_heap_base(buf.AllocationBase)) break;
index 0b51452..5565841 100644 (file)
@@ -2208,8 +2208,6 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
                         LPVOID lpParameter, DWORD dwCreationFlags,
                         LPDWORD lpThreadId)
   {
-    HANDLE thread_h;
-
     if (!EXPECT(parallel_initialized, TRUE))
       GC_init_parallel();
                 /* make sure GC is initialized (i.e. main thread is     */
@@ -2225,6 +2223,7 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
     } else {
       thread_args *args = GC_malloc_uncollectable(sizeof(thread_args));
                 /* Handed off to and deallocated by child thread.       */
+      HANDLE thread_h;
 
       if (0 == args) {
         SetLastError(ERROR_NOT_ENOUGH_MEMORY);