]> granicus.if.org Git - gc/commitdiff
Fix 'redundant assignment to itself' Cppcheck warning in GC_scratch_alloc
authorIvan Maidanski <ivmai@mail.ru>
Sat, 14 Jun 2014 16:11:54 +0000 (20:11 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 14 Jun 2014 16:11:54 +0000 (20:11 +0400)
* headers.c (GC_scratch_alloc): Do not reassign "bytes_to_get" local
variable to avoid compiler warning in case of ROUNDUP_PAGESIZE_IF_MMAP
is a no-op (i.e., assign bytes_to_get only once directly to a rounded
value).

headers.c

index 361f19c12d18ec93f40e73940692b6947814e34d..057d989fd53b2af3df80cc367e9b93e89e818719 100644 (file)
--- a/headers.c
+++ b/headers.c
@@ -128,8 +128,7 @@ GC_INNER ptr_t GC_scratch_alloc(size_t bytes)
             return result;
         }
 
-        bytes_to_get = MINHINCR * HBLKSIZE;
-        if (bytes_to_get <= bytes) {
+        if (bytes >= MINHINCR * HBLKSIZE) {
             bytes_to_get = ROUNDUP_PAGESIZE_IF_MMAP(bytes);
             result = (ptr_t)GET_MEM(bytes_to_get);
             GC_add_to_our_memory(result, bytes_to_get);
@@ -143,7 +142,8 @@ GC_INNER ptr_t GC_scratch_alloc(size_t bytes)
             return result;
         }
 
-        bytes_to_get = ROUNDUP_PAGESIZE_IF_MMAP(bytes_to_get); /* for safety */
+        bytes_to_get = ROUNDUP_PAGESIZE_IF_MMAP(MINHINCR * HBLKSIZE);
+                                                /* round up for safety */
         result = (ptr_t)GET_MEM(bytes_to_get);
         GC_add_to_our_memory(result, bytes_to_get);
         if (NULL == result) {