summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2023-05-05 00:15:10 +0300
committerIvan Maidanski <ivmai@mail.ru>2023-05-05 00:15:10 +0300
commit51783cbbfda018a8fe0ce8bba8f0eed305aee840 (patch)
tree03b55915eff10ad976ca4f7cc24e5acc8ff28624
parentd654f40deaa60b9bcaa5177963aec76974745897 (diff)
downloadbdwgc-51783cbbfda018a8fe0ce8bba8f0eed305aee840.tar.gz
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.
-rw-r--r--alloc.c6
1 files 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. */