PVS-StudioWarnings

PVS-Studio warning V547 for CrashRpt

Nov 17th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. typedef std::basic_string<TCHAR> tstring;
  2.  
  3. int process_report(....)
  4. {
  5.   ....
  6.   tstring sInDirName;
  7.   ....
  8.   size_t pos = sInDirName.rfind('\\');
  9.   if(pos<0) // There is no back slash in path
  10.   {
  11.     sInDirName = _T("");
  12.     sInFileName = szInput;
  13.   }
  14.   else
  15.   {
  16.     sInFileName = sInDirName.substr(pos+1);
  17.     sInDirName = sInDirName.substr(0, pos);
  18.   }
  19.   ....
  20. }
  21.  
  22. This suspicious code was found in CrashRpt project by PVS-Studio static code analyzer.
  23. Warning message is:
  24. V547 Expression 'pos < 0' is always false. Unsigned type value is never < 0. main.cpp 314
  25.  
  26. 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