diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-11-11 16:28:06 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-11-11 16:28:06 +0000 |
commit | 00735eec3121f566641b484519e6d9809d13d14d (patch) | |
tree | 258a5f577fa37f56637bc05629e6feacf6172de5 /cpukit/libmisc/cpuuse/cpuusagereport.c | |
parent | 2009-11-11 Till Straumann <strauman@slac.stanford.edu> (diff) | |
download | rtems-00735eec3121f566641b484519e6d9809d13d14d.tar.bz2 |
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.
Diffstat (limited to 'cpukit/libmisc/cpuuse/cpuusagereport.c')
-rw-r--r-- | cpukit/libmisc/cpuuse/cpuusagereport.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cpukit/libmisc/cpuuse/cpuusagereport.c b/cpukit/libmisc/cpuuse/cpuusagereport.c index d8f08a9a65..a0f0995756 100644 --- a/cpukit/libmisc/cpuuse/cpuusagereport.c +++ b/cpukit/libmisc/cpuuse/cpuusagereport.c @@ -148,8 +148,16 @@ 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 % 1000; ival /= 1000; (*print)( context, |