Hi Ambroz, On Fri, Feb 3, 2012 at 5:14 PM, Ambroz Bizjak <ambrop7@xxxxxxxxx> wrote: > Hi, > > Here's an updated patch as you requested. > > Note that it implicitly fixes a small bug in the hash function that > was introduced when modifying the eina code: the line "hash ^= key[2] > << 18;" is supposed to be accessing the 3rd byte of the remainder of > the input, but when 'it' was introduced, 'key' ('data' in eina code) > was no longer incremented, so this ended up accessing the 3rd byte of > the input from the beginning. This is fixed by iterating over 'key', > like the eina code does. yeah, indeed. Thanks a lot for doing this. > > As far as implementation of get16bits() is concerned, the "attribute > packed" approach is the best; it avoids having to hardcode specific > platforms, letting the compiler deal with the details of memory > access. (and it works in every compiler this code is ever going to be > compiled with; e.g. gcc and clang both support this) Sure, we have something similar in BlueZ which IMO is even cleaner (since the structure is not visible from outside): /* Bluetooth unaligned access */ #define bt_get_unaligned(ptr) \ ({ \ struct __attribute__((packed)) { \ typeof(*(ptr)) __v; \ } *__p = (void *) (ptr); \ __p->__v; \ }) But I'm happy with the patch the way it is. Thanks. Patch has been applied. Lucas De Marchi -- To unsubscribe from this list: send the line "unsubscribe linux-modules" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html