PVS-StudioWarnings

PVS-Studio warning V525 for MySQL

Nov 13th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. static int rr_cmp(uchar *a,uchar *b)
  2. {
  3.   if (a[0] != b[0])
  4.     return (int) a[0] - (int) b[0];
  5.   if (a[1] != b[1])
  6.     return (int) a[1] - (int) b[1];
  7.   if (a[2] != b[2])
  8.     return (int) a[2] - (int) b[2];
  9.   if (a[3] != b[3])
  10.     return (int) a[3] - (int) b[3];
  11.   if (a[4] != b[4])
  12.     return (int) a[4] - (int) b[4];
  13.   if (a[5] != b[5])
  14.     return (int) a[1] - (int) b[5]; <<<---
  15.   if (a[6] != b[6])
  16.     return (int) a[6] - (int) b[6];
  17.   return (int) a[7] - (int) b[7];
  18. }
  19.  
  20. This is what should have been written here: return (int) a[5] - (int) b[5];
  21.  
  22. This suspicious code was found in MySQL project by PVS-Studio static code analyzer.
  23. Warning message is:
  24. V525 The code containing the collection of similar blocks. Check items '0', '1', '2', '3', '4', '1', '6' in lines 680, 682, 684, 689, 691, 693, 695. sql records.cc 680
  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