diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2023-05-05 00:15:10 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2023-05-05 00:15:10 +0300 |
commit | 51783cbbfda018a8fe0ce8bba8f0eed305aee840 (patch) | |
tree | 03b55915eff10ad976ca4f7cc24e5acc8ff28624 | |
parent | d654f40deaa60b9bcaa5177963aec76974745897 (diff) | |
download | bdwgc-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.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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. */ |