From ea21c2bcf8933a18aa3c15a20c628a90495dc1af Mon Sep 17 00:00:00 2001 From: Scott Snyder <scott.snyder@cern.ch> Date: Fri, 20 May 2016 14:48:55 +0200 Subject: [PATCH] 'Avoid division by FP constant.' (RecAlgs-00-00-22) * Tagging RecAlgs-00-00-22. * Avoid division by FP constant. * Tagging RecAlgs-00-00-21. * Fix cppcheck warnings (scanf field widths) Former-commit-id: f0a8990d79621a1c7acb552e673f9f774c2b4b3b --- Reconstruction/RecAlgs/src/MemoryAlg.cxx | 2 +- Reconstruction/RecAlgs/src/TimingAlg.cxx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Reconstruction/RecAlgs/src/MemoryAlg.cxx b/Reconstruction/RecAlgs/src/MemoryAlg.cxx index c35ac3d0cb7..ffed8daf1f1 100755 --- a/Reconstruction/RecAlgs/src/MemoryAlg.cxx +++ b/Reconstruction/RecAlgs/src/MemoryAlg.cxx @@ -62,7 +62,7 @@ StatusCode MemoryAlg::execute() unsigned long a2(-1); FILE *proc = fopen("/proc/self/statm","r"); if (proc) { - (void)fscanf(proc, "%lu %lu %lu", &a0, &a1, &a2); + (void)fscanf(proc, "%80lu %80lu %80lu", &a0, &a1, &a2); fclose(proc); } float f=float(a0*m_pagesize) - f0; diff --git a/Reconstruction/RecAlgs/src/TimingAlg.cxx b/Reconstruction/RecAlgs/src/TimingAlg.cxx index 6698f33d92e..52ecfc9c991 100755 --- a/Reconstruction/RecAlgs/src/TimingAlg.cxx +++ b/Reconstruction/RecAlgs/src/TimingAlg.cxx @@ -87,7 +87,7 @@ StatusCode TimingAlg::initialize() int s(0); s=0xFF; if (stepping.compare("none") != 0) - sscanf(stepping.c_str(),"stepping\t: %d",&s); + sscanf(stepping.c_str(),"stepping\t: %80d",&s); ATH_MSG_VERBOSE( "stepping : " << s ); if ( s > 255 ) s = 255; @@ -95,7 +95,7 @@ StatusCode TimingAlg::initialize() s=0xFF; if (cpuFamily.compare("none") != 0) - sscanf(cpuFamily.c_str(),"cpu family\t: %d",&s); + sscanf(cpuFamily.c_str(),"cpu family\t: %80d",&s); ATH_MSG_VERBOSE( "cpuFamily : " << s ); if ( s > 255 ) s = 255; @@ -103,7 +103,7 @@ StatusCode TimingAlg::initialize() s=0xFF; if (model.compare("none") != 0) - sscanf(model.c_str(),"model\t: %d",&s); + sscanf(model.c_str(),"model\t: %80d",&s); ATH_MSG_VERBOSE( "model : " << s ); if ( s > 255 ) s = 255; @@ -143,7 +143,7 @@ StatusCode TimingAlg::execute() struct rusage r; getrusage(RUSAGE_SELF, &r); - float f=float(r.ru_utime.tv_sec+r.ru_stime.tv_sec) + float(r.ru_utime.tv_usec+r.ru_stime.tv_usec)/1000000-f0; + float f=float(r.ru_utime.tv_sec+r.ru_stime.tv_sec) + float(r.ru_utime.tv_usec+r.ru_stime.tv_usec)*1e-6-f0; t->push_back(f); ATH_MSG_DEBUG(" CPU time for this event until now is: " << f); if ( m_determineCPUID && m_CPUID ) -- GitLab