QNativeSocketEngine::option(): return a correct value on invalid call

Instead of 'true', it should be '-1'.

Change-Id: I5e8f99153da68d34b37477ef4cedbc447fba347f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Alex Trotsenko 2016-08-04 18:43:42 +03:00 committed by Edward Welbourne
parent 91a2c8630b
commit eb4bcdd8ce
2 changed files with 2 additions and 1 deletions

View File

@ -307,7 +307,7 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co
// handle non-getsockopt cases first
if (opt == QNativeSocketEngine::BindExclusively || opt == QNativeSocketEngine::NonBlockingSocketOption
|| opt == QNativeSocketEngine::BroadcastSocketOption)
return true;
return -1;
int n, level;
int v = -1;

View File

@ -139,6 +139,7 @@ void tst_PlatformSocketEngine::construction()
QCOMPARE(socketDevice.peerAddress(), QHostAddress());
QCOMPARE(socketDevice.peerPort(), quint16(0));
QCOMPARE(socketDevice.error(), QAbstractSocket::UnknownSocketError);
QCOMPARE(socketDevice.option(QNativeSocketEngine::NonBlockingSocketOption), -1);
QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::bytesAvailable() was called in QAbstractSocket::UnconnectedState");
QCOMPARE(socketDevice.bytesAvailable(), -1);