]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Avoiding division by zero errors that were truncating results for OpenOffice
authorNicholas Nethercote <njn@valgrind.org>
Tue, 3 Sep 2002 15:09:06 +0000 (15:09 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Tue, 3 Sep 2002 15:09:06 +0000 (15:09 +0000)
with --trace-children=yes.

git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_1_0_BRANCH@864

vg_cachesim.c

index ea9cbce05f183a228ef26b2732ccf128af28ab5e..8cfab99656e9d83a5dc8f796d6d10586c8a34591 100644 (file)
@@ -78,7 +78,7 @@ static void file_err()
       "error: can't open cache simulation output file `%s'",
       OUT_FILE );
    VG_(message)(Vg_UserMsg,
-      "       ... so detailed simulation results will be missing.");
+      "       ... so simulation results will be missing.");
 }
 
 /*------------------------------------------------------------*/
@@ -1634,6 +1634,7 @@ void percentify(Int n, Int pow, Int field_width, char buf[])
    VG_(sprintf)(buf, "%d.%d%%", n / pow, n % pow);
    len = VG_(strlen)(buf);
    space = field_width - len;
+   if (space < 0) space = 0;     /* Allow for v. small field_width */
    i = len;
 
    /* Right justify in field */
@@ -1670,6 +1671,7 @@ void VG_(do_cachesim_results)(Int client_argc, Char** client_argv)
 
    p = 100;
 
+   if (0 == Ir_total.a) Ir_total.a = 1;
    percentify(Ir_total.m1 * 100 * p / Ir_total.a, p, l1+1, buf1);
    VG_(message)(Vg_UserMsg, "I1  miss rate: %s", buf1);
                 
@@ -1703,6 +1705,9 @@ void VG_(do_cachesim_results)(Int client_argc, Char** client_argv)
 
    p = 10;
    
+   if (0 == D_total.a)  D_total.a  = 1;
+   if (0 == Dr_total.a) Dr_total.a = 1;
+   if (0 == Dw_total.a) Dw_total.a = 1;
    percentify( D_total.m1 * 100 * p / D_total.a,  p, l1+1, buf1);
    percentify(Dr_total.m1 * 100 * p / Dr_total.a, p, l2+1, buf2);
    percentify(Dw_total.m1 * 100 * p / Dw_total.a, p, l3+1, buf3);