PVS-StudioWarnings

PVS-Studio warning V556 for Source SDK

Nov 12th, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. enum PhysGunPickup_t
  2. {
  3.   PICKED_UP_BY_CANNON,
  4.   PUNTED_BY_CANNON,
  5.   PICKED_UP_BY_PLAYER, // Picked up by +USE, not physgun.
  6. };
  7.  
  8. enum PhysGunDrop_t
  9. {
  10.   DROPPED_BY_PLAYER,
  11.   THROWN_BY_PLAYER,
  12.   DROPPED_BY_CANNON,
  13.   LAUNCHED_BY_CANNON,
  14. };
  15.  
  16. void CBreakableProp::OnPhysGunDrop(...., PhysGunDrop_t Reason)
  17. {
  18.   ....
  19.   if( Reason == PUNTED_BY_CANNON )
  20.   {
  21.     PlayPuntSound();
  22.   }
  23.   ....
  24. }
  25.  
  26. This suspicious code was found in Source SDK project by PVS-Studio static code analyzer.
  27. Warning message is:
  28. V556 The values of different enum types are compared: Reason == PUNTED_BY_CANNON. Server (HL2) props.cpp 1520
  29.  
  30. 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