Advertisement
PVS-StudioWarnings

PVS-Studio warning V503 for Chromium

Nov 26th, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. typedef void *HANDLE;
  2.  
  3. #if defined(OS_WIN)
  4.   typedef HANDLE PlatformFile;
  5. #elif defined(OS_POSIX)
  6.   typedef int PlatformFile;
  7. #endif
  8.  
  9. int64 SeekPlatformFile(PlatformFile file,
  10.                        PlatformFileWhence whence,
  11.                        int64 offset) {
  12.   base::ThreadRestrictions::AssertIOAllowed();
  13.   if (file < 0 || offset < 0)
  14.     return -1;
  15.  
  16.   LARGE_INTEGER distance, res;
  17.   distance.QuadPart = offset;
  18.   DWORD move_method = static_cast<DWORD>(whence);
  19.   if (!SetFilePointerEx(file, distance, &res, move_method))
  20.     return -1;
  21.   return res.QuadPart;
  22. }
  23.  
  24. This suspicious code was found in Chromium project by PVS-Studio static code analyzer.
  25. Warning message is:
  26. V503 This is a nonsensical comparison: pointer < 0. platform_file_win.cc 124
  27.  
  28. 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