summaryrefslogtreecommitdiff
path: root/examples/c
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2014-11-22 10:53:55 -0500
committerKeith Bostic <keith@wiredtiger.com>2014-11-22 10:53:55 -0500
commit2a13545189ec77769ca0eb86e27e13779863c0e2 (patch)
tree00cfd976cccf042280903102af8cd0a644a94614 /examples/c
parent47a3bd9bdfa84690fe8256ffff5d8a94b0b6aa8b (diff)
downloadmongo-2a13545189ec77769ca0eb86e27e13779863c0e2.tar.gz
Don't divide by 0 if the file is 0 bytes.
Diffstat (limited to 'examples/c')
-rw-r--r--examples/c/ex_stat.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/c/ex_stat.c b/examples/c/ex_stat.c
index 0614a1de234..86114bb711f 100644
--- a/examples/c/ex_stat.c
+++ b/examples/c/ex_stat.c
@@ -149,12 +149,14 @@ print_derived_stats(WT_SESSION *session)
{
/*! [statistics calculate table fragmentation] */
- uint64_t ckpt_size, file_size;
+ uint64_t ckpt_size, file_size, percent;
ret = get_stat(cursor, WT_STAT_DSRC_BLOCK_CHECKPOINT_SIZE, &ckpt_size);
ret = get_stat(cursor, WT_STAT_DSRC_BLOCK_SIZE, &file_size);
- printf("File is %d%% fragmented\n",
- (int)(100 * (file_size - ckpt_size) / file_size));
+ percent = 0;
+ if (file_size != 0)
+ percent = 100 * ((file_size - ckpt_size) / file_size);
+ printf("Table is %" PRIu64 "%% fragmented\n", percent);
/*! [statistics calculate table fragmentation] */
}