PVS-StudioWarnings

PVS-Studio warning V519 for VirtualBox

Nov 18th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. static void
  2. vbcppProcessSkipWhiteAndEscapedEol(PSCMSTREAM pStrmInput)
  3. {
  4.   ....
  5.   if (ch == '\r' || ch == '\n')
  6.   {
  7.     ....
  8.   }
  9.   else if (RT_C_IS_SPACE(ch))
  10.   {
  11.     ch = chPrev;                        //<==
  12.     ch = ScmStreamGetCh(pStrmInput);    //<==
  13.     Assert(ch == chPrev);
  14.   }
  15.   else
  16.     break;
  17.   ....
  18. }
  19.  
  20. It is logical to assume that the operands of the assignment operator are swapped by mistake and it is the previous character that should be saved in this code: chPrev = ch;
  21.  
  22. This suspicious code was found in VirtualBox project by PVS-Studio static code analyzer.
  23. Warning message is:
  24. V519 The 'ch' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 1135, 1136. vboxcpp.cpp 1136
  25.  
  26. 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