From 51783cbbfda018a8fe0ce8bba8f0eed305aee840 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 5 May 2023 00:15:10 +0300 Subject: Fix 'scope of total_time can be reduced' cppcheck warning in stopped_mark (fix of commit 53f132650) * alloc.c [!NO_CLOCK] (GC_stopped_mark): Move total_time and divisor local variables to inner block of their usage. --- alloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/alloc.c b/alloc.c index b34f3101..611701e4 100644 --- a/alloc.c +++ b/alloc.c @@ -906,7 +906,6 @@ STATIC GC_bool GC_stopped_mark(GC_stop_func stop_func) if (start_time_valid) { CLOCK_TYPE current_time; unsigned long time_diff, ns_frac_diff; - unsigned total_time, divisor; /* TODO: Avoid code duplication from GC_try_to_collect_inner */ GET_TIME(current_time); @@ -922,9 +921,10 @@ STATIC GC_bool GC_stopped_mark(GC_stop_func stop_func) } if (GC_PRINT_STATS_FLAG) { + unsigned total_time = world_stopped_total_time; + unsigned divisor = world_stopped_total_divisor; + /* Compute new world-stop delay total time. */ - total_time = world_stopped_total_time; - divisor = world_stopped_total_divisor; if (total_time > (((unsigned)-1) >> 1) || divisor >= MAX_TOTAL_TIME_DIVISOR) { /* Halve values if overflow occurs. */ -- cgit v1.2.1