Examples of errors detected by the V516 diagnostic.


V516. Consider inspecting an odd expression. Non-null function pointer is compared to null.


Audacity

V516 Consider inspecting an odd expression. Non-null function pointer is compared to null: 'sf_error != 0'. libsndfile sndfile.c 491


int sf_error (SNDFILE *sndfile)
{
  ...
  if (! sndfile)
  {
    if (sf_error != 0)
      return sf_errno ;
    return 0 ;
  } ;
  ...
}

Strange code. Perhaps there should be (sf_errno != 0). But why not simply write "return sf_errno;" then?


Micro-Manager

V516 Consider inspecting an odd expression. Non-null function pointer is compared to null: 'MP285::GetMotionMode == 0'. MP285ZStage.cpp 558


class MP285
{
  ....
  static int  GetMotionMode() { return m_nMotionMode; }
  ....
};

int ZStage::_SetPositionSteps(....)
{
  ....
  if (MP285::GetMotionMode == 0)
  {
    long lOldZPosSteps = (long)MP285::Instance()->GetPositionZ();
    dSec = (double)labs(lZPosSteps-lOldZPosSteps) / dVelocity;
  }
  else
  {
     dSec = (double)labs(lZPosSteps) / dVelocity;
  }
  ....
}

This is what should have been written here: if (MP285::GetMotionMode() == 0)



Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++, and C#

goto PVS-Studio;