PVS-StudioWarnings

PVS-Studio warning V547 for FCEUX

Nov 20th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. void CenterWindow(HWND hwndDlg)
  2. {
  3.   ...
  4.   unsigned x = ((rectP.right-rectP.left) - width) / 2 +
  5.                rectP.left;
  6.   unsigned y = ((rectP.bottom-rectP.top) - height) / 2 +
  7.                rectP.top;
  8.   ...
  9.   // make sure that the dialog box never moves outside
  10.   // of the screen
  11.   if(x < 0) x = 0;
  12.   if(y < 0) y = 0;
  13.   if(x + width  > screenwidth)  x = screenwidth  - width;
  14.   if(y + height > screenheight) y = screenheight - height;
  15.   ...
  16. }
  17.  
  18. This suspicious code was found in FCEUX project by PVS-Studio static code analyzer.
  19. Warning message is:
  20. V547 Expression 'x < 0' is always false. Unsigned type value is never < 0. fceux gui.cpp 32
  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