From b3713b3ba84f1cccd998c49248e9b8f030b9587a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 11 Apr 2022 11:18:52 +0200 Subject: Port indexed for-loops from int to qsizetype ... and port (already or soon-expected-to-be) count() to size(). These changes are considered trivial, in that nothing but the loop variable needs adjustment. The alternative, a port to ranged for-loops, I dismissed for these loops, either because the loop index was used for something else (first/last check, zip iteration) or I was just too lazy to prove that the container under iteration isn't changed. In some cases, I may have forgotten to port to ranged loops, even though it would be trivially safe. This was already much more complex than anticipated :) Also fix post-increment to pre-increment. It doesn't matter for integral types, but developers that regularly read and write post-increment for integral types will likely fail to switch to pre-increment for iterators types, where the difference does matter, so increase the exposure of code readers to the idiomatic form. Pick-to: 6.3 Task-number: QTBUG-102463 Change-Id: Ia6f2960dc52d46ffbd48f12446e9b0f7c70df162 Reviewed-by: Ivan Solovev --- src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp') diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp index c4787779..3945e918 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp @@ -318,7 +318,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::deviceFound(const QString &devicePat // Cache the properties so we do not have to access dbus every time to get a value devicesProperties[devicePath] = properties; - for (int i = 0; i < discoveredDevices.size(); i++) { + for (qsizetype i = 0; i < discoveredDevices.size(); ++i) { if (discoveredDevices[i].address() == deviceInfo.address()) { if (lowEnergySearchTimeout > 0 && discoveredDevices[i] == deviceInfo) { qCDebug(QT_BT_BLUEZ) << "Duplicate: " << deviceInfo.address(); @@ -436,7 +436,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::_q_PropertiesChanged(const QString & if (changed_properties.contains(QStringLiteral("RSSI")) || changed_properties.contains(QStringLiteral("ManufacturerData"))) { - for (int i = 0; i < discoveredDevices.size(); i++) { + for (qsizetype i = 0; i < discoveredDevices.size(); ++i) { if (discoveredDevices[i].address() == info.address()) { QBluetoothDeviceInfo::Fields updatedFields = QBluetoothDeviceInfo::Field::None; if (changed_properties.contains(QStringLiteral("RSSI"))) { -- cgit v1.2.3