PVS-StudioWarnings

PVS-Studio warning V501 for Skia

Nov 19th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. static bool fitsInBits(SkScalar x, int bits) {
  2. #ifdef SK_SCALAR_IS_FIXED
  3.   x = SkAbs32(x);
  4.   x += 1 << 7;
  5.   x >>= 8;
  6.   return x < (1 << (bits - 1));
  7. #else
  8.   return SkScalarAbs(x) < (1 << (bits - 1));
  9. #endif
  10. }
  11.  
  12. SkXfermode* SkArithmeticMode::Create(SkScalar k1, SkScalar k2,
  13.                                      SkScalar k3, SkScalar k4)
  14. {
  15.   if (fitsInBits(k1, 8) &&
  16.       fitsInBits(k2, 16) &&
  17.       fitsInBits(k2, 16) &&
  18.       fitsInBits(k2, 24)) {
  19.   ....
  20. }
  21.  
  22. This suspicious code was found in Skia project by PVS-Studio static code analyzer.
  23. Warning message is:
  24. V501 There are identical sub-expressions 'fitsInBits(k2, 16)' to the left and to the right of the '&&' operator. SkArithmeticMode.cpp 211
  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