Browse Source

TT#108003 Do not allow division by 0 load_thread()

We should make sure total_secs is never 0.

Change-Id: I532c7d67a640b7f88ed6f7c0ff31189fe0d98fb0
Warned-by: coverity
pull/1194/head
Guillem Jover 5 years ago
parent
commit
2c565874c7
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      daemon/load.c

+ 1
- 1
daemon/load.c View File

@ -36,7 +36,7 @@ void load_thread(void *dummy) {
long used_secs = used_now - used_last;
long idle_secs = idle_now - idle_last;
long total_secs = used_secs + idle_secs;
if (used_last && idle_last)
if (total_secs > 0 && used_last && idle_last)
g_atomic_int_set(&cpu_usage, (int) (used_secs
* 10000 / total_secs));
used_last = used_now;


Loading…
Cancel
Save