Advertisement
PVS-StudioWarnings

PVS-Studio warning V517 for Micro-Manager

Nov 27th, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. class Wheel : public CStateDeviceBase<Wheel>
  2. {
  3.   ....
  4.   unsigned wheelNumber_;
  5.   ....
  6. };
  7.  
  8. int Wheel::SetWheelPosition(int position)
  9. {
  10.   unsigned char cmd[4];
  11.   cmd[0] = moduleId_; cmd[2] = 0; cmd[3] = 58;
  12.   if (wheelNumber_ == 1) {
  13.     switch (position) {
  14.       case 0: cmd[1] = 49; break;
  15.       case 1: cmd[1] = 50; break;
  16.       case 2: cmd[1] = 51; break;
  17.       case 3: cmd[1] = 52; break;
  18.       case 4: cmd[1] = 53; break;
  19.       case 5: cmd[1] = 54; break;
  20.     }
  21.   } else if (wheelNumber_ == 1) {
  22.     switch (position) {
  23.       case 0: cmd[1] = 33; break;
  24.       case 1: cmd[1] = 64; break;
  25.       case 2: cmd[1] = 35; break;
  26.       case 3: cmd[1] = 36; break;
  27.       case 4: cmd[1] = 37; break;
  28.       case 5: cmd[1] = 94; break;
  29.     }
  30.   ....
  31. }
  32.  
  33. This suspicious code was found in Micro-Manager project by PVS-Studio static code analyzer.
  34. Warning message is:
  35. V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 645, 654. Ludl.cpp 645
  36.  
  37. 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
Advertisement