Advertisement
PVS-StudioWarnings

PVS-Studio warning V205 for NetXMS

Nov 25th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. static int hash_void_ptr(void *ptr)
  2. {
  3.   int hash;
  4.   int i;
  5.  
  6.   /* I took this hash function just off the top of my head,
  7.      I have no idea whether it is bad or very bad. */
  8.   hash = 0;
  9.   for (i = 0; i < (int)sizeof(ptr)*8 / TABLE_BITS; i++)
  10.     {
  11.       hash ^= (unsigned long)ptr >> i*8;
  12.       hash += i * 17;
  13.       hash &= TABLE_MASK;
  14.     }
  15.   return hash;
  16. }
  17.  
  18. This suspicious code was found in NetXMS project by PVS-Studio static code analyzer.
  19. Warning message is:
  20. V205 Explicit conversion of pointer type to 32-bit integer type: (unsigned long) ptr xmalloc.c 85
  21.  
  22. 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