From b2ba182e8f635d2d97ed07317920422cca90b4e8 Mon Sep 17 00:00:00 2001 From: "Paul N. Hilfinger" Date: Sat, 20 Mar 2004 09:53:03 +0000 Subject: [PATCH] print_percentage: Use floating point to avoid incorrect results when portion*100 overflows. --- gdb/ChangeLog | 5 +++++ gdb/bcache.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 442af68deab..53824f1d941 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2004-03-20 Paul Hilfinger + + * bcache.c (print_percentage): Use floating point to avoid + incorrect results when portion*100 overflows. + 2004-03-19 Kevin Buettner * ppc_tdep.h (ppc_linux_frame_saved_pc) diff --git a/gdb/bcache.c b/gdb/bcache.c index cadadb5cce6..0bc533ebfef 100644 --- a/gdb/bcache.c +++ b/gdb/bcache.c @@ -303,7 +303,7 @@ print_percentage (int portion, int total) if (total == 0) printf_filtered ("(not applicable)\n"); else - printf_filtered ("%3d%%\n", portion * 100 / total); + printf_filtered ("%3d%%\n", (int) (portion * 100.0 / total)); } -- 2.30.2