|
From: <sv...@va...> - 2005-07-17 16:16:46
|
Author: njn
Date: 2005-07-17 17:16:41 +0100 (Sun, 17 Jul 2005)
New Revision: 4149
Log:
Make VG_(percentify)() cope if the denominator is zero.
Modified:
trunk/coregrind/m_libcprint.c
Modified: trunk/coregrind/m_libcprint.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_libcprint.c 2005-07-17 16:12:59 UTC (rev 4148)
+++ trunk/coregrind/m_libcprint.c 2005-07-17 16:16:41 UTC (rev 4149)
@@ -158,8 +158,14 @@
void VG_(percentify)(UInt n, UInt m, UInt d, Int n_buf, char buf[])=20
{
Int i, len, space;
+ ULong p1;
=20
- ULong p1 =3D (100*n) / m;
+ if (m =3D=3D 0) {
+ VG_(sprintf)(buf, "--%%");
+ return;
+ }
+ =20
+ p1 =3D (100*n) / m;
=20
if (d =3D=3D 0) {
VG_(sprintf)(buf, "%lld%%", p1);
|