From patchwork Thu Oct 29 09:31:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaolei X-Patchwork-Id: 7517741 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C4CF59F37F for ; Thu, 29 Oct 2015 09:34:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E5DE120773 for ; Thu, 29 Oct 2015 09:33:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 121B120772 for ; Thu, 29 Oct 2015 09:33:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752022AbbJ2Jdj (ORCPT ); Thu, 29 Oct 2015 05:33:39 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:5639 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751478AbbJ2Jdi (ORCPT ); Thu, 29 Oct 2015 05:33:38 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="102430433" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 29 Oct 2015 17:35:49 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t9T9X2n6015816 for ; Thu, 29 Oct 2015 17:33:02 +0800 Received: from localhost.localdomain (10.167.226.114) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Thu, 29 Oct 2015 17:33:35 +0800 From: Zhao Lei To: CC: Zhao Lei Subject: [PATCH 1/6] btrfs-progs: fix floating point exception for btrfs-calc-size Date: Thu, 29 Oct 2015 17:31:43 +0800 Message-ID: X-Mailer: git-send-email 1.8.5.1 MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 /