From patchwork Tue Oct 22 14:10:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 3082991 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BC2DF9F2B7 for ; Tue, 22 Oct 2013 14:10:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 275E92039B for ; Tue, 22 Oct 2013 14:10:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03A9920381 for ; Tue, 22 Oct 2013 14:10:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753547Ab3JVOK1 (ORCPT ); Tue, 22 Oct 2013 10:10:27 -0400 Received: from dkim1.fusionio.com ([66.114.96.53]:44032 "EHLO dkim1.fusionio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753513Ab3JVOKY (ORCPT ); Tue, 22 Oct 2013 10:10:24 -0400 Received: from mx2.fusionio.com (unknown [10.101.1.160]) by dkim1.fusionio.com (Postfix) with ESMTP id 50FF57C06A5 for ; Tue, 22 Oct 2013 08:10:24 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fusionio.com; s=default; t=1382451024; bh=oeU3OHjwHJhWgB+72jvZCXxQTvloTZOoMSWcx2Ui0KA=; h=From:To:Subject:Date; b=OBPFNWIPsfcEhEqqkRS3v0EJu2GmeuXtq5QDdKYYp33fRph5FdSETSnViTk5pmJ3Y 6xyi4of74ceyLgYIdCHPTUWRieXBdRx/BinSv1QNI5JBmgEMFG30oSb62iqAJfL12T HBcmt5zfwlE/F9A/YURtBrghp0Z0qnmghbOBCM6U= X-ASG-Debug-ID: 1382451023-0421b56d445dd10001-6jHSXT Received: from CAS1.int.fusionio.com (cas1.int.fusionio.com [10.101.1.40]) by mx2.fusionio.com with ESMTP id P6ABAyf7an8BWl8x (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO) for ; Tue, 22 Oct 2013 08:10:23 -0600 (MDT) X-Barracuda-Envelope-From: JBacik@fusionio.com Received: from localhost (10.101.1.160) by mail.fusionio.com (10.101.1.40) with Microsoft SMTP Server (TLS) id 14.3.158.1; Tue, 22 Oct 2013 08:10:22 -0600 From: Josef Bacik To: Subject: [PATCH] Btrfs-progs: make pretty_sizes take u64 instead of a double Date: Tue, 22 Oct 2013 10:10:21 -0400 X-ASG-Orig-Subj: [PATCH] Btrfs-progs: make pretty_sizes take u64 instead of a double Message-ID: <1382451021-16745-1-git-send-email-jbacik@fusionio.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.101.1.160] X-Barracuda-Connect: cas1.int.fusionio.com[10.101.1.40] X-Barracuda-Start-Time: 1382451023 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: http://10.101.1.181:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at fusionio.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.141699 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 This got changed to a double but all the callers still use a u64, which causes us to segfault sometimes because of some weird C voodoo that I had to have explained to me. Apparently because we're using a double the compiler will use the floating point registers to hold our argument which ends up not being aligned properly if you don't actually give it a double so it will cause problems for other things, in our case it was screwing up str_bytes so it was larger than the actual size of the str. This patch fixes the segfault. Thanks, Signed-off-by: Josef Bacik --- utils.c | 2 +- utils.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/utils.c b/utils.c index 69ae21f..f8bc94f 100644 --- a/utils.c +++ b/utils.c @@ -1190,7 +1190,7 @@ out: } static char *size_strs[] = { "", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"}; -int pretty_size_snprintf(double size, char *str, size_t str_bytes) +int pretty_size_snprintf(u64 size, char *str, size_t str_bytes) { int num_divs = 0; float fraction; diff --git a/utils.h b/utils.h index 7a74826..32e0542 100644 --- a/utils.h +++ b/utils.h @@ -49,7 +49,7 @@ int check_mounted_where(int fd, const char *file, char *where, int size, int btrfs_device_already_in_root(struct btrfs_root *root, int fd, int super_offset); -int pretty_size_snprintf(double size, char *str, size_t str_bytes); +int pretty_size_snprintf(u64 size, char *str, size_t str_bytes); #define pretty_size(size) \ ({ \ static __thread char _str[24]; \