From e9e5234b9275ac13876a1070540faa95d7cf8903 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 11 Nov 2009 16:27:56 +0000 Subject: 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 | 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 + + 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 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, -- cgit v1.2.3