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>bb10
parent
f68260e6c0
commit
75612a4b4f
|
|
@ -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)];
|
||||
|
|
|
|||
Loading…
Reference in New Issue