summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/timespecdivide.c
diff options
context:
space:
mode:
authorGlenn Humphrey <glenn.humphrey@oarcorp.com>2007-10-26 21:30:59 +0000
committerGlenn Humphrey <glenn.humphrey@oarcorp.com>2007-10-26 21:30:59 +0000
commitb0ac06f8e9dc11c7aa3bfebc910fafd4018dbd9c (patch)
tree60ad5746b5e5ccad0a2971a64adb2f1a7af3266f /cpukit/score/src/timespecdivide.c
parent2007-10-26 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-b0ac06f8e9dc11c7aa3bfebc910fafd4018dbd9c.tar.bz2
2007-10-26 Glenn Humphrey <glenn.humphrey@OARcorp.com>
* libmisc/cpuuse/cpuusagereport.c, rtems/src/ratemonreportstatistics.c: Cleaned up reports and fixed a bug related the printf format which resulted in lack of leading zeroes and misleading magnitude. * score/src/timespecdivide.c: Fixed bugs related to zero divide case.
Diffstat (limited to 'cpukit/score/src/timespecdivide.c')
-rw-r--r--cpukit/score/src/timespecdivide.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/cpukit/score/src/timespecdivide.c b/cpukit/score/src/timespecdivide.c
index c40d02757f..91e6319848 100644
--- a/cpukit/score/src/timespecdivide.c
+++ b/cpukit/score/src/timespecdivide.c
@@ -42,18 +42,20 @@ void _Timespec_Divide(
right = rhs->tv_sec * (uint64_t)TOD_NANOSECONDS_PER_SECOND;
right += rhs->tv_nsec;
- if ( rhs == 0 ) {
- *ival_percentage = 0;
+ if ( right == 0 ) {
*ival_percentage = 0;
+ *fval_percentage = 0;
return;
}
/*
- * Put it back in the timespec result
+ * Put it back in the timespec result.
+ *
+ * TODO: Rounding on the last digit of the fval.
*/
answer = (left * 100000) / right;
- *fval_percentage = answer % 1000;
*ival_percentage = answer / 1000;
+ *fval_percentage = answer % 1000;
}