PVS-StudioWarnings

PVS-Studio warning V523 for KDE4

Nov 21st, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. QString newItem( const QString &type, ....)
  2. {
  3.   QString t = "new "+cfg.inherits+"::Item" + ....;
  4.   if ( type == "Enum" ) t += ", values" + name;
  5.   if ( !defaultValue.isEmpty() ) {
  6.     t += ", ";
  7.     if ( type == "String" ) t += defaultValue;        //<==
  8.     else t+= defaultValue;                            //<==
  9.   }
  10.   t += " );";
  11.  
  12.   return t;
  13. }
  14.  
  15. This suspicious code was found in KDE4 project by PVS-Studio static code analyzer.
  16. Warning message is:
  17. V523 The 'then' statement is equivalent to the 'else' statement. kconfig_compiler.cpp 1051
  18.  
  19. 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