Advertisement
PVS-StudioWarnings

PVS-Studio warning V642 for Firebird

Nov 27th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. SSHORT TextType::compare(ULONG len1, const UCHAR* str1,
  2.                          ULONG len2, const UCHAR* str2)
  3. {
  4.   ....
  5.   SSHORT cmp = memcmp(str1, str2, MIN(len1, len2));
  6.  
  7.   if (cmp == 0)
  8.     cmp = (len1 < len2 ? -1 : (len1 > len2 ? 1 : 0));
  9.  
  10.   return cmp;
  11.  
  12. }
  13.  
  14. This suspicious code was found in Firebird project by PVS-Studio static code analyzer.
  15. Warning message is:
  16. V642 Saving the 'memcmp' function result inside the 'short' type variable is inappropriate. The significant bits could be lost breaking the program's logic. texttype.cpp 338
  17.  
  18. 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