linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zach Brown <zab@redhat.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 09/15] btrfs-progs: fix in-place byte swapping
Date: Wed, 14 Aug 2013 16:16:39 -0700	[thread overview]
Message-ID: <1376522205-16992-10-git-send-email-zab@redhat.com> (raw)
In-Reply-To: <1376522205-16992-1-git-send-email-zab@redhat.com>

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>
---
 print-tree.c | 6 +++---
 uuid-tree.c  | 5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/print-tree.c b/print-tree.c
index 761448d..913b1bb 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 3a4c48e..39c3f3f 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;
-- 
1.7.11.7


  parent reply	other threads:[~2013-08-14 23:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-14 23:16 [RFC] btrfs-progs: fix sparse checking and warnings Zach Brown
2013-08-14 23:16 ` [PATCH 01/15] btrfs-progs: get C=1 sparse checking working again Zach Brown
2013-08-30 16:08   ` David Sterba
2013-08-30 21:03     ` Zach Brown
2013-08-30 21:27       ` David Sterba
2013-08-14 23:16 ` [PATCH 02/15] btrfs-progs: remove __CHECKER__ from main code Zach Brown
2013-08-14 23:16 ` [PATCH 03/15] btrfs-progs: add ULL to u64 constant Zach Brown
2013-08-14 23:16 ` [PATCH 04/15] btrfs-progs: fix shadow symbols Zach Brown
2013-08-14 23:16 ` [PATCH 05/15] btrfs-progs: remove variable length stack arrays Zach Brown
2013-08-14 23:16 ` [PATCH 06/15] btrfs-print: define void function args Zach Brown
2013-08-14 23:16 ` [PATCH 07/15] btrfs-progs: fix endian bugs in chunk rebuilding Zach Brown
2013-08-30 16:16   ` David Sterba
2013-08-14 23:16 ` [PATCH 08/15] btrfs-progs: fix extent key endian bug in repair Zach Brown
2013-08-14 23:16 ` Zach Brown [this message]
2013-08-14 23:16 ` [PATCH 10/15] btrfs-progs: fix qgroup realloc inheritance Zach Brown
2013-08-18  8:05   ` Arne Jansen
2013-08-14 23:16 ` [PATCH 11/15] btrfs-progs: make many private symbols static Zach Brown
2013-08-14 23:16 ` [PATCH 12/15] btrfs-progs: fix unaligned compat endian warnings Zach Brown
2013-08-14 23:16 ` [PATCH 13/15] btrfs-progs: don't use <linux/fs.h> Zach Brown
2013-08-14 23:16 ` [PATCH 14/15] btrfs-progs: give raid6.c its exported prototypes Zach Brown
2013-08-14 23:16 ` [PATCH 15/15] btrfs-progs: use NULL instead of 0 Zach Brown
2013-08-30 16:25   ` David Sterba
2013-08-30 21:04     ` Zach Brown
2013-08-30 16:31 ` [RFC] btrfs-progs: fix sparse checking and warnings David Sterba

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=1376522205-16992-10-git-send-email-zab@redhat.com \
    --to=zab@redhat.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).