From 40532a70267878fde588f7306cd5a13e34ef0446 Mon Sep 17 00:00:00 2001 From: hilfingr 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 442af68dea..53824f1d94 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 cadadb5cce..0bc533ebfe 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.11.0