diff options
author | Frank Meerkoetter <frank.meerkoetter@basyskom.com> | 2015-12-18 19:53:56 +0100 |
---|---|---|
committer | Frank Meerkoetter <frank.meerkoetter@basyskom.com> | 2015-12-22 14:29:44 +0000 |
commit | 75612a4b4f2b494aaa7bb34a4dbfdaba80447885 (patch) | |
tree | 83b821861efa98152e15d60e44cc9d8cea846d43 /src/platformsupport/devicediscovery | |
parent | f68260e6c078ec239a1b451c2a6d963340d3ce7e (diff) |
Fix resource leak/fix broken file open check
Also marking the error path as unlikely while I am
on it.
Fixes coverity CID154482.
Change-Id: I069fa7753e364ff1b8a4449b7008dfa8aee73de5
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'src/platformsupport/devicediscovery')
-rw-r--r-- | src/platformsupport/devicediscovery/qdevicediscovery_static.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp b/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp index de2f3415af..4bf7508b2f 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp +++ b/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp @@ -120,15 +120,17 @@ QStringList QDeviceDiscoveryStatic::scanConnectedDevices() bool QDeviceDiscoveryStatic::checkDeviceType(const QString &device) { int fd = QT_OPEN(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0); - if (!fd) { + if (Q_UNLIKELY(fd == -1)) { qWarning() << "Device discovery cannot open device" << device; return false; } qCDebug(lcDD) << "doing static device discovery for " << device; - if ((m_types & Device_DRM) && device.contains(QString::fromLatin1(QT_DRM_DEVICE_PREFIX))) + if ((m_types & Device_DRM) && device.contains(QString::fromLatin1(QT_DRM_DEVICE_PREFIX))) { + QT_CLOSE(fd); return true; + } long bitsAbs[LONG_FIELD_SIZE(ABS_CNT)]; long bitsKey[LONG_FIELD_SIZE(KEY_CNT)]; |