From 00735eec3121f566641b484519e6d9809d13d14d Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 11 Nov 2009 16:28:06 +0000 Subject: [PATCH] 2009-11-11 Jennifer Averett PR 1471/cpukit * libmisc/cpuuse/cpuusagereport.c: Rework statement to ensure 64-bit multiplication is used to avoid overflow with intermediate value. --- cpukit/ChangeLog | 6 ++++++ cpukit/libmisc/cpuuse/cpuusagereport.c | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 6363631272..057729e20c 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,9 @@ +2009-11-11 Jennifer Averett + + 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 PR 1468/cpukit 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,