Miranda IM

BUG OF THE MONTH | An error in the formatting string

V640 The code’s operational logic does not correspond with its formatting. The second statement will always be executed. It is possible that curly brackets are missing. infopanel.cpp 360

void CInfoPanel::renderContent(const HDC hdc)
{
  ....
  if(m_height >= DEGRADE_THRESHOLD)
      rc.top -= 2; rc.bottom -= 2;
  ....
}

It’s not easy to say which error is here, looking at this code fragment. Perhaps both commands should be executed only if the condition is true. In this case the code works incorrectly, and we should add curly brackets to the block of the operators. Additionally, we should separate the operators to improve the readability of the code.

if(m_height >= DEGRADE_THRESHOLD)
{
  rc.top -= 2; 
  rc.bottom -= 2;
}

Although, there is still a possibility that the code works in the way it was meant to, and the second operator should be always executed despite the condition. Then we have a formatting error that strongly hinders understanding of the code and we should move the rc.bottom -= 2; command to a different string.

Please click here to see more bugs from this project.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.