PVS-StudioWarnings

PVS-Studio warning V523 for QT

Nov 18th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. void
  2. QBluetoothServiceDiscoveryAgentPrivate::_q_deviceDiscovered(
  3.   const QBluetoothDeviceInfo &info)
  4. {
  5.   if(mode == QBluetoothServiceDiscoveryAgent::FullDiscovery) {
  6.     for(int i = 0; i < discoveredDevices.count(); i++){
  7.       if(discoveredDevices.at(i).address() == info.address()){
  8.         discoveredDevices.removeAt(i);
  9.       }
  10.     }
  11.     discoveredDevices.prepend(info);
  12.   }
  13.   else {
  14.     for(int i = 0; i < discoveredDevices.count(); i++){
  15.       if(discoveredDevices.at(i).address() == info.address()){
  16.         discoveredDevices.removeAt(i);
  17.       }
  18.     }
  19.     discoveredDevices.prepend(info);
  20.   }
  21. }
  22.  
  23. This suspicious code was found in QT project by PVS-Studio static code analyzer.
  24. Warning message is:
  25. V523 The 'then' statement is equivalent to the 'else' statement. qbluetoothservicediscoveryagent.cpp 402
  26.  
  27. 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