From: Josef Bacik <jbacik@fusionio.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH] Btrfs-progs: make pretty_sizes take u64 instead of a double
Date: Tue, 22 Oct 2013 10:10:21 -0400 [thread overview]
Message-ID: <1382451021-16745-1-git-send-email-jbacik@fusionio.com> (raw)
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 <jbacik@fusionio.com>
---
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]; \
--
1.8.3.1
reply other threads:[~2013-10-22 14:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1382451021-16745-1-git-send-email-jbacik@fusionio.com \
--to=jbacik@fusionio.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).