diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-11-11 16:27:56 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-11-11 16:27:56 +0000 |
commit | e9e5234b9275ac13876a1070540faa95d7cf8903 (patch) | |
tree | 8236854f27ac755d64edb466fe617b871d2d1a73 | |
parent | e067753e6d44fc630c17fba507d543976a8f3187 (diff) |
2009-11-11 Jennifer Averett <jennifer.averett@OARcorp.com>
PR 1471/cpukit
* libmisc/cpuuse/cpuusagereport.c: Rework statement to ensure 64-bit
multiplication is used to avoid overflow with intermediate value.
-rw-r--r-- | cpukit/ChangeLog | 6 | ||||
-rw-r--r-- | cpukit/libmisc/cpuuse/cpuusagereport.c | 13 |
2 files changed, 17 insertions, 2 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index f517340b57..efdb855b81 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,9 @@ +2009-11-11 Jennifer Averett <jennifer.averett@OARcorp.com> + + PR 1471/cpukit + * libmisc/cpuuse/cpuusagereport.c: Rework statement to ensure 64-bit + multiplication is used to avoid overflow with intermediate value. + 2009-11-10 Jennifer Averett <jennifer.averett@OARcorp.com> PR 1468/cpukit diff --git a/cpukit/libmisc/cpuuse/cpuusagereport.c b/cpukit/libmisc/cpuuse/cpuusagereport.c index 144be50645..d216ff5cc8 100644 --- a/cpukit/libmisc/cpuuse/cpuusagereport.c +++ b/cpukit/libmisc/cpuuse/cpuusagereport.c @@ -141,8 +141,17 @@ void rtems_cpu_usage_report_with_plugin( ival, fval ); #else - ival = (total_units) ? - the_thread->cpu_time_used * 10000 / total_units : 0; + if (total_units) { + uint64_t ival_64; + + ival_64 = the_thread->cpu_time_used; + ival_64 *= 10000; + ival = ival_64 / total_units; + + } else { + ival = 0; + } + fval = ival % 100; ival /= 100; (*print)( context, |