From 813a99e4f646a14c640eb08de7bf40f44235fc94 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sat, 14 Jun 2014 20:11:54 +0400 Subject: [PATCH] Fix 'redundant assignment to itself' Cppcheck warning in GC_scratch_alloc * 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/headers.c b/headers.c index 361f19c..057d989 100644 --- 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) { -- 2.7.4