From: Florian Krohm Date: Tue, 14 Oct 2014 21:47:43 +0000 (+0000) Subject: Merge revisions 14220, 14221, and 15629 from BUF_REMOVAL branch to trunk. X-Git-Tag: svn/VALGRIND_3_11_0~918 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7959068226ab4b250c55789d8e0d0f3444bd5792;p=thirdparty%2Fvalgrind.git Merge revisions 14220, 14221, and 15629 from BUF_REMOVAL branch to trunk. Couple of format fixes and FIXMEs for VG_(percentify). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14630 --- diff --git a/coregrind/m_libcprint.c b/coregrind/m_libcprint.c index cdeabb2b92..a3749c01e6 100644 --- a/coregrind/m_libcprint.c +++ b/coregrind/m_libcprint.c @@ -304,12 +304,12 @@ void VG_(percentify)(ULong n, ULong m, UInt d, Int n_buf, HChar buf[]) { Int i, len, space; ULong p1; - HChar fmt[32]; + HChar fmt[32]; // large enough if (m == 0) { // Have to generate the format string in order to be flexible about // the width of the field. - VG_(sprintf)(fmt, "%%-%ds", n_buf); + VG_(sprintf)(fmt, "%%%ds", n_buf); // fmt is now "%s" where is 1,2,3... VG_(sprintf)(buf, fmt, "--%"); return; @@ -318,7 +318,7 @@ void VG_(percentify)(ULong n, ULong m, UInt d, Int n_buf, HChar buf[]) p1 = (100*n) / m; if (d == 0) { - VG_(sprintf)(buf, "%lld%%", p1); + VG_(sprintf)(buf, "%llu%%", p1); // FIXME: unsafe } else { ULong p2; UInt ex; @@ -331,9 +331,9 @@ void VG_(percentify)(ULong n, ULong m, UInt d, Int n_buf, HChar buf[]) p2 = ((100*n*ex) / m) % ex; // Have to generate the format string in order to be flexible about // the width of the post-decimal-point part. - VG_(sprintf)(fmt, "%%lld.%%0%dlld%%%%", d); - // fmt is now "%lld.%0lld%%" where is 1,2,3... - VG_(sprintf)(buf, fmt, p1, p2); + VG_(sprintf)(fmt, "%%llu.%%0%ullu%%%%", d); + // fmt is now "%llu.%0llu%%" where is 1,2,3... + VG_(sprintf)(buf, fmt, p1, p2); // FIXME: unsafe } len = VG_(strlen)(buf);