previous_idle = cpu_active[IDLE_NUM];
percent = 0;
- if (0 != diff_total) {
+ if (0 != diff_total && 0 != diff_idle) {
percent = ((uintmax_t)TICKZ * (diff_total - diff_idle)) / diff_total;
}
previous_idle[x] = core_active[x][IDLE_NUM];
percent[x] = 0;
- if (0 != diff_total[x]) {
+ if (0 != diff_total[x] && 0 != diff_idle[x]) {
percent[x] = ((uintmax_t)TICKZ * (diff_total[x] - diff_idle[x]))
/ diff_total[x];
}
#pragma GCC diagnostic pop
percent = 0;
- if (0 != total) {
+ if (0 != total && 0 != used) {
percent = (used * 100) / total;
}
FILL_UINT_ARR(str1, percent);
snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
percent = 0L;
- if (0 != max) {
+ if (0 != max && 0 != vol) {
percent = (vol * 100) / max;
}