From: Nicholas Nethercote Date: Sun, 25 Sep 2005 19:11:45 +0000 (+0000) Subject: Fix incorrect computation of miss rates due to Int/Long mixups . X-Git-Tag: svn/VALGRIND_3_1_0~446 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eb51a9ff0d70aa3672b712cc0e0225cdf565223d;p=thirdparty%2Fvalgrind.git Fix incorrect computation of miss rates due to Int/Long mixups . git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4769 --- diff --git a/coregrind/m_libcprint.c b/coregrind/m_libcprint.c index 9adb6618e1..5d435e328a 100644 --- a/coregrind/m_libcprint.c +++ b/coregrind/m_libcprint.c @@ -156,13 +156,19 @@ UInt VG_(sprintf) ( Char* buf, const HChar *format, ... ) ------------------------------------------------------------------ */ // Percentify n/m with d decimal places. Includes the '%' symbol at the end. -void VG_(percentify)(UInt n, UInt m, UInt d, Int n_buf, char buf[]) +// Right justifies in 'buf'. +void VG_(percentify)(ULong n, ULong m, UInt d, Int n_buf, char buf[]) { Int i, len, space; ULong p1; + Char fmt[32]; if (m == 0) { - VG_(sprintf)(buf, "--%%"); + // Have to generate the format string in order to be flexible about + // the width of the field. + VG_(sprintf)(fmt, "%%-%lds", n_buf); + // fmt is now "%s" where is 1,2,3... + VG_(sprintf)(buf, fmt, "--%"); return; } @@ -173,7 +179,6 @@ void VG_(percentify)(UInt n, UInt m, UInt d, Int n_buf, char buf[]) } else { ULong p2; UInt ex; - Char fmt[32]; switch (d) { case 1: ex = 10; break; case 2: ex = 100; break; diff --git a/include/pub_tool_libcprint.h b/include/pub_tool_libcprint.h index 8922a6a05e..9a6ce995cd 100644 --- a/include/pub_tool_libcprint.h +++ b/include/pub_tool_libcprint.h @@ -46,7 +46,8 @@ extern UInt VG_(sprintf) ( Char* buf, const HChar* format, ... ); extern UInt VG_(vsprintf)( Char* buf, const HChar* format, va_list vargs ); // Percentify n/m with d decimal places. Includes the '%' symbol at the end. -extern void VG_(percentify)(UInt n, UInt m, UInt d, Int n_buf, char buf[]); +// Right justifies in 'buf'. +extern void VG_(percentify)(ULong n, ULong m, UInt d, Int n_buf, char buf[]); /* --------------------------------------------------------------------- Messages for the user