@@ -372,8 +372,8 @@ out_print:
printf("\tTotal seeks: %Lu\n", stat.total_seeks);
printf("\t\tForward seeks: %Lu\n", stat.forward_seeks);
printf("\t\tBackward seeks: %Lu\n", stat.backward_seeks);
- printf("\t\tAvg seek len: %Lu\n", stat.total_seek_len /
- stat.total_seeks);
+ printf("\t\tAvg seek len: %llu\n", stat.total_seeks ?
+ stat.total_seek_len / stat.total_seeks : 0);
print_seek_histogram(&stat);
printf("\tTotal clusters: %Lu\n", stat.total_clusters);
printf("\t\tAvg cluster size: %Lu\n", stat.total_cluster_size /
Current code exit with floating point exception on a blank fs: # btrfs-calc-size -b /dev/sda6 Calculating size of root tree Total size: 16384 Inline data: 0 Total seeks: 0 Forward seeks: 0 Backward seeks: 0 Floating point exception This patch add a condition check for above case. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> --- btrfs-calc-size.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)