[PATCH 1/4] xfs_db: fix alignment checks in getbitval

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Darrick J. Wong <djwong@xxxxxxxxxx>

For some reason, getbitval insists upon collecting a u64 from a pointer
bit by bit if it's not aligned to a 16-byte boundary.  Modern day
systems only seem to require N-byte alignment for an N-byte quantity, so
let's do that instead.

Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
---
 db/bit.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)


diff --git a/db/bit.c b/db/bit.c
index c9bfd2eb025f..42ea8daf814a 100644
--- a/db/bit.c
+++ b/db/bit.c
@@ -62,24 +62,24 @@ getbitval(
 	p = (char *)obj + byteize(bitoff);
 	bit = bitoffs(bitoff);
 	signext = (flags & BVSIGNED) != 0;
-	z4 = ((intptr_t)p & 0xf) == 0 && bit == 0;
+	z4 = ((intptr_t)p & (sizeof(uint64_t) - 1)) == 0 && bit == 0;
 	if (nbits == 64 && z4)
 		return be64_to_cpu(*(__be64 *)p);
-	z3 = ((intptr_t)p & 0x7) == 0 && bit == 0;
+	z3 = ((intptr_t)p & (sizeof(uint32_t) - 1)) == 0 && bit == 0;
 	if (nbits == 32 && z3) {
 		if (signext)
 			return (__s32)be32_to_cpu(*(__be32 *)p);
 		else
 			return (__u32)be32_to_cpu(*(__be32 *)p);
 	}
-	z2 = ((intptr_t)p & 0x3) == 0 && bit == 0;
+	z2 = ((intptr_t)p & (sizeof(uint16_t) - 1)) == 0 && bit == 0;
 	if (nbits == 16 && z2) {
 		if (signext)
 			return (__s16)be16_to_cpu(*(__be16 *)p);
 		else
 			return (__u16)be16_to_cpu(*(__be16 *)p);
 	}
-	z1 = ((intptr_t)p & 0x1) == 0 && bit == 0;
+	z1 = bit == 0;
 	if (nbits == 8 && z1) {
 		if (signext)
 			return *(__s8 *)p;
@@ -87,7 +87,6 @@ getbitval(
 			return *(__u8 *)p;
 	}
 
-
 	for (i = 0, rval = 0LL; i < nbits; i++) {
 		if (getbit_l(p, bit + i)) {
 			/* If the last bit is on and we care about sign





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux