PVS-StudioWarnings

PVS-Studio warning V564 for Doom3

Nov 20th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #define BIT( num ) ( 1 << ( num ) )
  2. const int BUTTON_ATTACK = BIT(0);
  3.  
  4. void idTarget_WaitForButton::Think( void ) {
  5.   ...
  6.   if ( player &&
  7.       ( !player->oldButtons & BUTTON_ATTACK ) &&
  8.       ( player->usercmd.buttons & BUTTON_ATTACK ) ) {
  9.   ...
  10. }
  11.  
  12. A trouble with parentheses: ( !(player->oldButtons & BUTTON_ATTACK) ) &&
  13.  
  14. This suspicious code was found in Doom3 project by PVS-Studio static code analyzer.
  15. Warning message is:
  16. V564 The '&' operator is applied to bool type value. You've probably forgotten to include parentheses or intended to use the '&&' operator. Game target.cpp 257
  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