diff options
author | Zach Brown <zab@redhat.com> | 2013-01-17 11:54:47 -0800 |
---|---|---|
committer | Zach Brown <zab@redhat.com> | 2013-02-05 16:09:32 -0800 |
commit | 52162700bb59663add809a6465ce2769d80b3664 (patch) | |
tree | 5cd021a31a6e098ee5e9b9c6b47b02f70f3f147d /btrfs-show-super.c | |
parent | 2161e1b6f35d1c084fda49b479951219117c86e9 (diff) |
btrfs-progs: treat super.magic as an le64
The super block magic is a le64 whose value looks like an unterminated
string in memory. The lack of null termination leads to clumsy use of
string functions and causes static analysis tools to warn that the
string will be unterminated.
So let's just treat it as the le64 that it is. Endian wrappers are used
on the constant so that they're compiled into run-time constants.
Signed-off-by: Zach Brown <zab@redhat.com>
Diffstat (limited to 'btrfs-show-super.c')
-rw-r--r-- | btrfs-show-super.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/btrfs-show-super.c b/btrfs-show-super.c index 45eb1024..3614c527 100644 --- a/btrfs-show-super.c +++ b/btrfs-show-super.c @@ -187,7 +187,7 @@ static void dump_superblock(struct btrfs_super_block *sb) s = (char *) &sb->magic; for (i = 0; i < 8; i++) putchar(isprint(s[i]) ? s[i] : '.'); - if (!memcmp(BTRFS_MAGIC, &sb->magic, 8)) + if (sb->magic == cpu_to_le64(BTRFS_MAGIC)) printf(" [match]\n"); else printf(" [DON'T MATCH]\n"); |