Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int hash_void_ptr(void *ptr)
- {
- int hash;
- int i;
- /* I took this hash function just off the top of my head,
- I have no idea whether it is bad or very bad. */
- hash = 0;
- for (i = 0; i < (int)sizeof(ptr)*8 / TABLE_BITS; i++)
- {
- hash ^= (unsigned long)ptr >> i*8;
- hash += i * 17;
- hash &= TABLE_MASK;
- }
- return hash;
- }
- This suspicious code was found in NetXMS project by PVS-Studio static code analyzer.
- Warning message is:
- V205 Explicit conversion of pointer type to 32-bit integer type: (unsigned long) ptr xmalloc.c 85
- PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement