chiark / gitweb /
journald: be more careful when we try to flush the runtime journal to disk and the...
[elogind.git] / src / libudev / libudev-util.c
index 62b7e56c05c7e463663f0302c4105055746fa3ba..714dc50ae9609911bbbb3d21c08c942bed8963cf 100644 (file)
@@ -241,8 +241,7 @@ int util_resolve_sys_link(struct udev *udev, char *syspath, size_t size)
                         return -EINVAL;
                 base[0] = '\0';
         }
-        if (base == NULL)
-                return -EINVAL;
+
         strscpyl(base, size - (base - syspath), "/", &link_target[back * 3], NULL);
         return 0;
 }
@@ -568,7 +567,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 +582,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 */