summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZach Brown <zab@redhat.com>2013-08-14 16:16:39 -0700
committerDavid Sterba <dsterba@suse.cz>2013-09-03 19:41:06 +0200
commit73043664dc8a48d329881632d33dd9eae6bd060a (patch)
tree24e6877169489f1e59e9afc62c39c83603862d73
parent47c072c2d85a786c5290e0bc5d2e3110bc806ca1 (diff)
btrfs-progs: fix in-place byte swapping
Storing fixed-endian values in native cpu types defeats the purpose of using sparse endian types to find endian conversion bugs. Signed-off-by: Zach Brown <zab@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r--print-tree.c6
-rw-r--r--uuid-tree.c5
2 files changed, 6 insertions, 5 deletions
diff --git a/print-tree.c b/print-tree.c
index 761448d1..913b1bb3 100644
--- a/print-tree.c
+++ b/print-tree.c
@@ -688,11 +688,11 @@ static void print_uuid_item(struct extent_buffer *l, unsigned long offset,
return;
}
while (item_size) {
- u64 subvol_id;
+ __le64 subvol_id;
read_extent_buffer(l, &subvol_id, offset, sizeof(u64));
- subvol_id = le64_to_cpu(subvol_id);
- printf("\t\tsubvol_id %llu\n", (unsigned long long)subvol_id);
+ printf("\t\tsubvol_id %llu\n",
+ (unsigned long long)le64_to_cpu(subvol_id));
item_size -= sizeof(u64);
offset += sizeof(u64);
}
diff --git a/uuid-tree.c b/uuid-tree.c
index 3a4c48e4..39c3f3fd 100644
--- a/uuid-tree.c
+++ b/uuid-tree.c
@@ -43,6 +43,7 @@ static int btrfs_uuid_tree_lookup_any(int fd, const u8 *uuid, u8 type,
struct btrfs_ioctl_search_args search_arg;
struct btrfs_ioctl_search_header *search_header;
u32 item_size;
+ __le64 lesubid;
btrfs_uuid_to_key(uuid, &key_objectid, &key_offset);
@@ -82,8 +83,8 @@ static int btrfs_uuid_tree_lookup_any(int fd, const u8 *uuid, u8 type,
}
/* return first stored id */
- memcpy(subid, search_header + 1, sizeof(*subid));
- *subid = le64_to_cpu(*subid);
+ memcpy(&lesubid, search_header + 1, sizeof(lesubid));
+ *subid = le64_to_cpu(lesubid);
out:
return ret;