gnome-system-monitor r2554 - trunk/src
- From: bdejean svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-system-monitor r2554 - trunk/src
- Date: Tue, 20 Jan 2009 00:19:20 +0000 (UTC)
Author: bdejean
Date: Tue Jan 20 00:19:20 2009
New Revision: 2554
URL: http://svn.gnome.org/viewvc/gnome-system-monitor?rev=2554&view=rev
Log:
Avoid 0 division.
Closes #557099.
Modified:
trunk/src/smooth_refresh.cpp
Modified: trunk/src/smooth_refresh.cpp
==============================================================================
--- trunk/src/smooth_refresh.cpp (original)
+++ trunk/src/smooth_refresh.cpp Tue Jan 20 00:19:20 2009
@@ -26,13 +26,16 @@
glibtop_cpu cpu;
glibtop_proc_time proctime;
guint64 elapsed;
- unsigned usage;
+ unsigned usage = PCPU_LO;
glibtop_get_cpu (&cpu);
elapsed = cpu.total - this->last_total_time;
- glibtop_get_proc_time(&proctime, getpid());
- usage = (proctime.rtime - this->last_cpu_time) * 100 / elapsed;
+ if (elapsed) { // avoid division by 0
+ glibtop_get_proc_time(&proctime, getpid());
+ usage = (proctime.rtime - this->last_cpu_time) * 100 / elapsed;
+ }
+
usage = CLAMP(usage, 0, 100);
this->last_total_time = cpu.total;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]