Fix warnings in tests (MinGW/MSCV)

tst_qtcpsocket.cpp:606:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
tst_qtcpsocket.cpp:670:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
tst_qfile.cpp(2661): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
tst_qarraydata.cpp(760): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
main.cpp:40:33: warning: ignoring return value of 'char* fgets(char*, int, FILE*)', declared with attribute warn_unused_result [-Wunused-result]

Change-Id: I80ccef29b71af6a2c3d45a79aedaeb37f49bba72
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
This commit is contained in:
Friedemann Kleint 2016-11-29 12:38:51 +01:00
parent 6aa2d49d5f
commit 1e303601a7
4 changed files with 10 additions and 7 deletions

View File

@ -2618,9 +2618,10 @@ void tst_QFile::appendAndRead()
// Write blocks and read them back
for (int j = 0; j < 18; ++j) {
writeFile.write(QByteArray(1 << j, '@'));
const int size = 1 << j;
writeFile.write(QByteArray(size, '@'));
writeFile.flush();
QCOMPARE(readFile.read(1 << j).size(), 1 << j);
QCOMPARE(readFile.read(size).size(), size);
}
readFile.close();

View File

@ -751,8 +751,8 @@ void tst_QArrayData::alignment_data()
{
QTest::addColumn<size_t>("alignment");
for (int i = 1; i < 10; ++i) {
size_t alignment = 1u << i;
for (size_t i = 1; i < 10; ++i) {
size_t alignment = size_t(1u) << i;
QTest::newRow(qPrintable(QString::number(alignment))) << alignment;
}
}

View File

@ -603,7 +603,7 @@ void tst_QTcpSocket::bind()
if (port)
QCOMPARE(int(boundPort), port);
fd = socket->socketDescriptor();
QVERIFY(fd != INVALID_SOCKET);
QVERIFY(fd != qintptr(INVALID_SOCKET));
} else {
QVERIFY(!socket->bind(addr, port));
QCOMPARE(socket->localPort(), quint16(0));
@ -667,7 +667,7 @@ void tst_QTcpSocket::bindThenResolveHost()
QCOMPARE(socket->state(), QAbstractSocket::BoundState);
quint16 boundPort = socket->localPort();
qintptr fd = socket->socketDescriptor();
QVERIFY(fd != INVALID_SOCKET);
QVERIFY(fd != quint16(INVALID_SOCKET));
dummySocket.close();

View File

@ -37,7 +37,9 @@ int main(int, char **argv)
fflush(stdout);
// wait for a newline
fgets(buf, sizeof buf, stdin);
const char *result = fgets(buf, sizeof buf, stdin);
if (result != buf)
return -1;
puts(msg);
fflush(stdout);