From 5fb01106f45ddbd6836d75496fb11070044a454a Mon Sep 17 00:00:00 2001 From: neilbrown Date: Fri, 30 May 2003 05:41:10 +0000 Subject: [PATCH 1/1] Avoid overflow in nfsstats printing --- ChangeLog | 6 ++++++ utils/nfsstat/nfsstat.c | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 414a526..5a53aa6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-05-30 Michael Griffith + NeilBrown + + utils/nfsstat/nfsstat.c(print_callstats): use unsigned + long long to avoid overflow when printing stats. + 2003-05-30 NeilBrown * support/export/export.c, support/include/nfslib.h, diff --git a/utils/nfsstat/nfsstat.c b/utils/nfsstat/nfsstat.c index 739daba..b26b3b8 100644 --- a/utils/nfsstat/nfsstat.c +++ b/utils/nfsstat/nfsstat.c @@ -307,7 +307,8 @@ static void print_callstats(const char *hdr, const char **names, unsigned int *info, unsigned int nr) { - unsigned int total; + unsigned long long total; + unsigned long long pct; int i, j; fputs(hdr, stdout); @@ -319,9 +320,10 @@ print_callstats(const char *hdr, const char **names, for (j = 0; j < 6 && i + j < nr; j++) printf("%-11s", names[i+j]); printf("\n"); - for (j = 0; j < 6 && i + j < nr; j++) - printf("%-6d %2d%% ", - info[i+j], 100 * info[i+j] / total); + for (j = 0; j < 6 && i + j < nr; j++) { + pct = ((unsigned long long) info[i+j]*100)/total; + printf("%-6d %2llu%% ", info[i+j], pct); + } printf("\n"); } printf("\n"); -- 2.39.2