linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] btrfs-progs: fix floating point exception for btrfs-calc-size
@ 2015-10-29  9:31 Zhao Lei
  2015-10-29  9:31 ` [PATCH 2/6] btrfs-progs: Fix negative eb's ref_cnt in btrfs-calc-size Zhao Lei
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Zhao Lei @ 2015-10-29  9:31 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Zhao Lei

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(-)

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


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-11-02  1:17 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-29  9:31 [PATCH 1/6] btrfs-progs: fix floating point exception for btrfs-calc-size Zhao Lei
2015-10-29  9:31 ` [PATCH 2/6] btrfs-progs: Fix negative eb's ref_cnt in btrfs-calc-size Zhao Lei
2015-10-29  9:31 ` [PATCH 3/6] btrfs-progs: free fslabel for btrfs-convert Zhao Lei
2015-10-29 13:08   ` David Sterba
2015-10-29  9:31 ` [PATCH 4/6] btrfs-progs: Fix uninitialized key.type for btrfs_find_free_objectid Zhao Lei
2015-10-29  9:31 ` [PATCH 5/6] btrfs-progs: free comparer_set in cmd_qgroup_show Zhao Lei
2015-10-30 13:35   ` David Sterba
2015-11-02  1:16     ` Zhao Lei
2015-10-29  9:31 ` [PATCH 6/6] btrfs-progs: Avoid use pointer in handle_options Zhao Lei
2015-10-29 13:15   ` David Sterba
2015-10-29 13:26 ` [PATCH 1/6] btrfs-progs: fix floating point exception for btrfs-calc-size David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).