summaryrefslogtreecommitdiff
path: root/print-tree.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-11-02 10:22:10 +0100
committerDavid Sterba <dsterba@suse.com>2016-11-09 13:47:30 +0100
commita15294f0c4fa56c0402e7b23ce6dff3508da0be5 (patch)
tree8b4394df2efa04d75b913e5483ca8d291bc07ae1 /print-tree.c
parent5082ec84a86cbb8a6f8e5140c11f1200c26cc05a (diff)
btrfs-progs: dump-tree: simplify and fix check for empty uuid
Counting non-zero bytes is wasteful, besides that it would not recognize uuids containing a 00 value. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'print-tree.c')
-rw-r--r--print-tree.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/print-tree.c b/print-tree.c
index 0f55607e..4ecf1004 100644
--- a/print-tree.c
+++ b/print-tree.c
@@ -516,15 +516,14 @@ static void print_root_ref(struct extent_buffer *leaf, int slot, char *tag)
namelen, namebuf);
}
-static int count_bytes(void *buf, int len, char b)
+static int empty_uuid(const u8 *uuid)
{
- int cnt = 0;
int i;
- for (i = 0; i < len; i++) {
- if (((char*)buf)[i] == b)
- cnt++;
- }
- return cnt;
+
+ for (i = 0; i < BTRFS_UUID_SIZE; i++)
+ if (uuid[i])
+ return 0;
+ return 1;
}
/*
@@ -570,11 +569,11 @@ static void print_root(struct extent_buffer *leaf, int slot)
if (root_item.generation == root_item.generation_v2) {
uuid_unparse(root_item.uuid, uuid_str);
printf("\t\tuuid %s\n", uuid_str);
- if (count_bytes(root_item.parent_uuid, BTRFS_UUID_SIZE, 0) != BTRFS_UUID_SIZE) {
+ if (!empty_uuid(root_item.parent_uuid)) {
uuid_unparse(root_item.parent_uuid, uuid_str);
printf("\t\tparent_uuid %s\n", uuid_str);
}
- if (count_bytes(root_item.received_uuid, BTRFS_UUID_SIZE, 0) != BTRFS_UUID_SIZE) {
+ if (!empty_uuid(root_item.received_uuid)) {
uuid_unparse(root_item.received_uuid, uuid_str);
printf("\t\treceived_uuid %s\n", uuid_str);
}