summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@inai.de>2013-03-20 15:23:32 +0100
committerKay Sievers <kay@vrfy.org>2013-03-20 16:18:04 +0100
commitacd42fae59096d84e78f1c17bfcc0d8f96486341 (patch)
treecd434d58da6ad3e7751a54497cd071609f34a097 /src
parent53726349e1d7a85bdf572ce81f122e66e438c6ec (diff)
libudev: avoid potential misaligned accesses
clang reports: src/libudev/libudev-util.c:665:35: warning: cast from "const unsigned char *" to "unsigned int *" increases required alignment from 1 to 4 [-Wcast-align]
Diffstat (limited to 'src')
-rw-r--r--src/libudev/libudev-util.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/libudev/libudev-util.c b/src/libudev/libudev-util.c
index 62b7e56c05..44f6e4a863 100644
--- a/src/libudev/libudev-util.c
+++ b/src/libudev/libudev-util.c
@@ -568,7 +568,7 @@ err:
* Murmurhash is under the MIT license.
*
*/
-static unsigned int murmur_hash2(const char *key, int len, unsigned int seed)
+static unsigned int murmur_hash2(const char *key, size_t len, unsigned int seed)
{
/*
* 'm' and 'r' are mixing constants generated offline.
@@ -583,17 +583,18 @@ static unsigned int murmur_hash2(const char *key, int len, unsigned int seed)
/* mix 4 bytes at a time into the hash */
const unsigned char * data = (const unsigned char *)key;
- while(len >= 4) {
- unsigned int k = *(unsigned int *)data;
+ while(len >= sizeof(unsigned int)) {
+ unsigned int k;
+ memcpy(&k, data, sizeof(k));
k *= m;
k ^= k >> r;
k *= m;
h *= m;
h ^= k;
- data += 4;
- len -= 4;
+ data += sizeof(k);
+ len -= sizeof(k);
}
/* handle the last few bytes of the input array */