PVS-StudioWarnings

PVS-Studio warning V525 for TPP

Nov 26th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. void setPepMaxProb( bool use_nsp, bool use_fpkm,
  2.   bool use_joint_probs, bool compute_spectrum_cnts )
  3. {
  4.   double prob = 0.0;
  5.   double max2 = 0.0;
  6.   double max3 = 0.0;
  7.   double max4 = 0.0;
  8.   double max5 = 0.0;
  9.   double max6 = 0.0;
  10.   double max7 = 0.0;
  11.   ....
  12.   if ( pep3 ) { ... if ( use_joint_probs && prob > max3 ) ... }
  13.   ....
  14.   if ( pep4 ) { ... if ( use_joint_probs && prob > max4 ) ... }
  15.   ....
  16.   if ( pep5 ) { ... if ( use_joint_probs && prob > max5 ) ... }
  17.   ....
  18.   if ( pep6 ) { ... if ( use_joint_probs && prob > max6 ) ... }
  19.   ....
  20.   if ( pep7 ) { ... if ( use_joint_probs && prob > max6 ) ... }
  21.  
  22.   ....
  23. }
  24.  
  25. This is what should have been written here: if ( pep7 ) { ... if ( use_joint_probs && prob > max7 ) ... }
  26.  
  27. This suspicious code was found in TPP project by PVS-Studio static code analyzer.
  28. Warning message is:
  29. V525 The code containing the collection of similar blocks. Check items 'max3', 'max4', 'max5', 'max6', 'max6' in lines 4664, 4690, 4716, 4743, 4770. proteinprophet.cpp 4664
  30.  
  31. 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