summaryrefslogtreecommitdiffstats
path: root/utils/nfsstat/nfsstat.c
diff options
context:
space:
mode:
authorneilbrown <neilbrown>2003-05-30 05:41:10 +0000
committerneilbrown <neilbrown>2003-05-30 05:41:10 +0000
commit5fb01106f45ddbd6836d75496fb11070044a454a (patch)
tree795f0d84004015f2a7553acb2563a723e7c4bceb /utils/nfsstat/nfsstat.c
parentd38ea02d0e4bcdc4e0114567028596f7bcba45b9 (diff)
downloadnfs-utils-5fb01106f45ddbd6836d75496fb11070044a454a.tar.gz
nfs-utils-5fb01106f45ddbd6836d75496fb11070044a454a.tar.xz
nfs-utils-5fb01106f45ddbd6836d75496fb11070044a454a.zip
Avoid overflow in nfsstats printing
Diffstat (limited to 'utils/nfsstat/nfsstat.c')
-rw-r--r--utils/nfsstat/nfsstat.c10
1 files changed, 6 insertions, 4 deletions
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");