Advertisement
PVS-StudioWarnings

PVS-Studio warning V516 for Micro-Manager

Nov 21st, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. class MP285
  2. {
  3.   ....
  4.   static int  GetMotionMode() { return m_nMotionMode; }
  5.   ....
  6. };
  7.  
  8. int ZStage::_SetPositionSteps(....)
  9. {
  10.   ....
  11.   if (MP285::GetMotionMode == 0)
  12.   {
  13.     long lOldZPosSteps = (long)MP285::Instance()->GetPositionZ();
  14.     dSec = (double)labs(lZPosSteps-lOldZPosSteps) / dVelocity;
  15.   }
  16.   else
  17.   {
  18.      dSec = (double)labs(lZPosSteps) / dVelocity;
  19.   }
  20.   ....
  21. }
  22.  
  23. This is what should have been written here: if (MP285::GetMotionMode() == 0)
  24.  
  25. This suspicious code was found in Micro-Manager project by PVS-Studio static code analyzer.
  26. Warning message is:
  27. V516 Consider inspecting an odd expression. Non-null function pointer is compared to null: 'MP285::GetMotionMode == 0'. MP285ZStage.cpp 558
  28.  
  29. 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