PVS-StudioWarnings

PVS-Studio warning V547 for MongoDB

Nov 20th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. void* MemoryMappedFile::map(....) {
  2.   ....
  3.   size_t len = strlen( filename );
  4.   for ( size_t i=len-1; i>=0; i-- ) {
  5.     if ( filename[i] == '/' ||
  6.          filename[i] == '\\' )
  7.       break;
  8.  
  9.     if ( filename[i] == ':' )
  10.          filename[i] = '_';
  11.   }
  12.   ....
  13. }
  14.  
  15. This suspicious code was found in MongoDB project by PVS-Studio static code analyzer.
  16. Warning message is:
  17. V547 Expression 'i >= 0' is always true. Unsigned type value is always >= 0. mmap_win.cpp 90
  18.  
  19. 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