From 63ac6874eeea037b4b8b1a450a938999fb4f31b8 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Thu, 9 Jun 2016 21:32:02 +0300 Subject: Replace local 'static const' integers with 'enum' Not sure whether this improves anything, but it can't make it worse. Enumerators are always rvalues and never end up in the .rodata part of binaries; static variables (const or not) are lvalues and therefore can get their address taken. Change-Id: I24155e5a3224fd6a33885a7ca3194ac53879d2c5 Reviewed-by: Thiago Macieira --- src/serialport/qserialportinfo_win.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/serialport/qserialportinfo_win.cpp b/src/serialport/qserialportinfo_win.cpp index 995f1d7..4a80325 100644 --- a/src/serialport/qserialportinfo_win.cpp +++ b/src/serialport/qserialportinfo_win.cpp @@ -158,10 +158,10 @@ static QString devicePortName(HDEVINFO deviceInfoSet, PSP_DEVINFO_DATA deviceInf L"PortNumber\0" }; - static const int keyTokensCount = sizeof(keyTokens) / sizeof(keyTokens[0]); + enum { KeyTokensCount = sizeof(keyTokens) / sizeof(keyTokens[0]) }; QString portName; - for (int i = 0; i < keyTokensCount; ++i) { + for (int i = 0; i < KeyTokensCount; ++i) { DWORD dataType = 0; std::vector outputBuffer(MAX_PATH + 1, 0); DWORD bytesRequired = MAX_PATH; @@ -299,11 +299,11 @@ QList QSerialPortInfo::availablePorts() { GUID_DEVINTERFACE_MODEM, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE } }; - static const int setupTokensCount = sizeof(setupTokens) / sizeof(setupTokens[0]); + enum { SetupTokensCount = sizeof(setupTokens) / sizeof(setupTokens[0]) }; QList serialPortInfoList; - for (int i = 0; i < setupTokensCount; ++i) { + for (int i = 0; i < SetupTokensCount; ++i) { const HDEVINFO deviceInfoSet = ::SetupDiGetClassDevs(&setupTokens[i].guid, Q_NULLPTR, Q_NULLPTR, setupTokens[i].flags); if (deviceInfoSet == INVALID_HANDLE_VALUE) return serialPortInfoList; -- cgit v1.2.1