PVS-StudioWarnings

PVS-Studio warning V563 for TPP

Nov 20th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. void MascotConverter::init(....) {
  2.   ...
  3.   if(line_len > 8 && line[0] == 'r' && line[1] == 'e' &&
  4.      line[2] == 'l' && line[3] == 'e' && line[4] == 'a' &&
  5.      line[5] == 's' && line[6] == 'e' && line[7] == '=')
  6.     if(database_ == NULL)
  7.       database_ = strCopy(line+8);
  8.   else if(line_len > 5 && line[0] == 'F' && line[1] == 'I' &&
  9.           line[2] == 'L' && line[3] == 'E' && line[4] == '=') {
  10.     header_ = strCopy(line+5);
  11.   ...
  12. }
  13.  
  14. Because there are no parentheses, else refers to another if.
  15.  
  16. This suspicious code was found in TPP project by PVS-Studio static code analyzer.
  17. Warning message is:
  18. V563 It is possible that this 'else' branch must apply to the previous 'if' statement. Mascot2XML mascotconverter.cxx 895
  19.  
  20. 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