summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorDavid Miller <davem@davemloft.net>2008-02-15 11:19:58 -0500
committerDavid Woodhouse <dwmw2@hera.kernel.org>2008-02-15 11:19:58 -0500
commit8871a0eaa98d951727e97c615d831af9a60432ae (patch)
tree7701fa42a830e2fba095199bfe25c62b42b9d36e /hash.c
parent0c6513b1d120ba99a3d5f3641cb059723245ec00 (diff)
Unaligned access fixes
The first problem is that these SETGET macros lose typing information, and therefore can't see the 'packed' attribute and therefore take unaligned access SIGBUS signals on sparc64 when trying to derefernce the member. The next problem is a similar issue in btrfs_name_hash(). This gets passed things like &key.offset which is a member of a packed structure, losing this packed'ness information btrfs_name_hash() performs a potentially unaligned memory access, again resulting in a SIGBUS.
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/hash.c b/hash.c
index 75cac881..58f0be69 100644
--- a/hash.c
+++ b/hash.c
@@ -75,12 +75,13 @@ static void str2hashbuf(const char *msg, int len, __u32 *buf, int num)
*buf++ = pad;
}
-int btrfs_name_hash(const char *name, int len, u64 *hash_result)
+u64 btrfs_name_hash(const char *name, int len)
{
__u32 hash;
__u32 minor_hash = 0;
const char *p;
__u32 in[8], buf[2];
+ u64 hash_result;
/* Initialize the default seed for the hash checksum functions */
buf[0] = 0x67452301;
@@ -97,8 +98,8 @@ int btrfs_name_hash(const char *name, int len, u64 *hash_result)
}
hash = buf[0];
minor_hash = buf[1];
- *hash_result = buf[0];
- *hash_result <<= 32;
- *hash_result |= buf[1];
- return 0;
+ hash_result = buf[0];
+ hash_result <<= 32;
+ hash_result |= buf[1];
+ return hash_result;
}