public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Harvey Harrison <harvey.harrison@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 09/21] xfs: use aligned-endian get/put helpers
Date: Tue, 20 May 2008 11:06:14 -0700	[thread overview]
Message-ID: <1211306774.5915.176.camel@brick> (raw)

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
 fs/xfs/xfs_log.c         |    4 ++--
 fs/xfs/xfs_log_priv.h    |    6 +++---
 fs/xfs/xfs_log_recover.c |    9 ++++-----
 fs/xfs/xfs_mount.c       |   12 ++++++------
 4 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index afaee30..b90325d 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1529,7 +1529,7 @@ xlog_sync(xlog_t		*log,
 		 */
 		for (i = 0; i < split; i += BBSIZE) {
 			be32_add_cpu((__be32 *)dptr, 1);
-			if (be32_to_cpu(*(__be32 *)dptr) == XLOG_HEADER_MAGIC_NUM)
+			if (get_be32(dptr) == XLOG_HEADER_MAGIC_NUM)
 				be32_add_cpu((__be32 *)dptr, 1);
 			dptr += BBSIZE;
 		}
@@ -3387,7 +3387,7 @@ xlog_verify_iclog(xlog_t	 *log,
 	ptr = (xfs_caddr_t) &iclog->ic_header;
 	for (ptr += BBSIZE; ptr < ((xfs_caddr_t)&iclog->ic_header) + count;
 	     ptr += BBSIZE) {
-		if (be32_to_cpu(*(__be32 *)ptr) == XLOG_HEADER_MAGIC_NUM)
+		if (get_be32(ptr) == XLOG_HEADER_MAGIC_NUM)
 			xlog_panic("xlog_verify_iclog: unexpected magic num");
 	}
 
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h
index 8952a39..858f8d4 100644
--- a/fs/xfs/xfs_log_priv.h
+++ b/fs/xfs/xfs_log_priv.h
@@ -63,10 +63,10 @@ static inline xfs_lsn_t xlog_assign_lsn(uint cycle, uint block)
 
 static inline uint xlog_get_cycle(char *ptr)
 {
-	if (be32_to_cpu(*(__be32 *)ptr) == XLOG_HEADER_MAGIC_NUM)
-		return be32_to_cpu(*((__be32 *)ptr + 1));
+	if (get_be32(ptr) == XLOG_HEADER_MAGIC_NUM)
+		return get_be32((__be32 *)ptr + 1);
 	else
-		return be32_to_cpu(*(__be32 *)ptr);
+		return get_be32(ptr);
 }
 
 #define BLK_AVG(blk1, blk2)	((blk1+blk2) >> 1)
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index e65ab4a..1b710c1 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -824,7 +824,7 @@ xlog_find_tail(
 		if ((error = xlog_bread(log, i, 1, bp)))
 			goto bread_err;
 		offset = xlog_align(log, i, 1, bp);
-		if (XLOG_HEADER_MAGIC_NUM == be32_to_cpu(*(__be32 *)offset)) {
+		if (XLOG_HEADER_MAGIC_NUM == get_be32(offset)) {
 			found = 1;
 			break;
 		}
@@ -840,8 +840,7 @@ xlog_find_tail(
 			if ((error = xlog_bread(log, i, 1, bp)))
 				goto bread_err;
 			offset = xlog_align(log, i, 1, bp);
-			if (XLOG_HEADER_MAGIC_NUM ==
-			    be32_to_cpu(*(__be32 *)offset)) {
+			if (XLOG_HEADER_MAGIC_NUM == get_be32(offset)) {
 				found = 2;
 				break;
 			}
@@ -3342,7 +3341,7 @@ xlog_pack_data_checksum(
 	up = (__be32 *)iclog->ic_datap;
 	/* divide length by 4 to get # words */
 	for (i = 0; i < (size >> 2); i++) {
-		chksum ^= be32_to_cpu(*up);
+		chksum ^= get_be32(up);
 		up++;
 	}
 	iclog->ic_header.h_chksum = cpu_to_be32(chksum);
@@ -3407,7 +3406,7 @@ xlog_unpack_data_checksum(
 
 	/* divide length by 4 to get # words */
 	for (i=0; i < be32_to_cpu(rhead->h_len) >> 2; i++) {
-		chksum ^= be32_to_cpu(*up);
+		chksum ^= get_be32(up);
 		up++;
 	}
 	if (chksum != be32_to_cpu(rhead->h_chksum)) {
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index da39884..e946b95 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -488,16 +488,16 @@ xfs_sb_to_disk(
 		} else {
 			switch (size) {
 			case 2:
-				*(__be16 *)(to_ptr + first) =
-					cpu_to_be16(*(__u16 *)(from_ptr + first));
+				put_be16(*(__u16 *)(from_ptr + first),
+					 to_ptr + first);
 				break;
 			case 4:
-				*(__be32 *)(to_ptr + first) =
-					cpu_to_be32(*(__u32 *)(from_ptr + first));
+				put_be32(*(__u32 *)(from_ptr + first),
+					 to_ptr + first);
 				break;
 			case 8:
-				*(__be64 *)(to_ptr + first) =
-					cpu_to_be64(*(__u64 *)(from_ptr + first));
+				put_be64(*(__u64 *)(from_ptr + first),
+					 to_ptr + first);
 				break;
 			default:
 				ASSERT(0);
-- 
1.5.5.1.570.g26b5e



                 reply	other threads:[~2008-05-20 18:09 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=1211306774.5915.176.camel@brick \
    --to=harvey.harrison@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@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