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@xxxxxxxxxxxxxx>
---
btrfs-calc-size.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/btrfs-calc-size.c b/btrfs-calc-size.c
index b756693..17d44ae 100644
--- a/btrfs-calc-size.c
+++ b/btrfs-calc-size.c
@@ -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 /
--
1.8.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html