~ubuntu-branches/ubuntu/trusty/systemd/trusty

« back to all changes in this revision

Viewing changes to src/libudev/libudev-util.c

Tags: upstream-202
ImportĀ upstreamĀ versionĀ 202

Show diffs side-by-side

added added

removed removed

Lines of Context:
241
241
                        return -EINVAL;
242
242
                base[0] = '\0';
243
243
        }
244
 
        if (base == NULL)
245
 
                return -EINVAL;
 
244
 
246
245
        strscpyl(base, size - (base - syspath), "/", &link_target[back * 3], NULL);
247
246
        return 0;
248
247
}
568
567
 * Murmurhash is under the MIT license.
569
568
 *
570
569
 */
571
 
static unsigned int murmur_hash2(const char *key, int len, unsigned int seed)
 
570
static unsigned int murmur_hash2(const char *key, size_t len, unsigned int seed)
572
571
{
573
572
        /*
574
573
         *  'm' and 'r' are mixing constants generated offline.
583
582
        /* mix 4 bytes at a time into the hash */
584
583
        const unsigned char * data = (const unsigned char *)key;
585
584
 
586
 
        while(len >= 4) {
587
 
                unsigned int k = *(unsigned int *)data;
 
585
        while(len >= sizeof(unsigned int)) {
 
586
                unsigned int k;
588
587
 
 
588
                memcpy(&k, data, sizeof(k));
589
589
                k *= m;
590
590
                k ^= k >> r;
591
591
                k *= m;
592
592
                h *= m;
593
593
                h ^= k;
594
594
 
595
 
                data += 4;
596
 
                len -= 4;
 
595
                data += sizeof(k);
 
596
                len -= sizeof(k);
597
597
        }
598
598
 
599
599
        /* handle the last few bytes of the input array */