summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-04-27 16:31:08 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-04-28 06:48:33 +0200
commitbbc385150f8ae0ab7b2fc179db82ef4bb3d5ac28 (patch)
tree035b946da27cc8d77b60e593056bc0096757accd /tests
parent069369d86707c89645d63ff36151065c47e6c0ea (diff)
Fix warnings from deprecated posix functions
Windows wants ISO C++ _fileno and _unlink instead of posix fileno and unlink. For fileno we have the QT_FILENO macro in qplatformdefs.h, so use it. For unlink we don't have a macro in Qt, so declare one in the test. Change-Id: I56c5c3fb4e500769c744132c46107816f89bb2c3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp6
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp4
2 files changed, 6 insertions, 4 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 188e3fdc25..67a8d66963 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -1766,7 +1766,7 @@ void tst_QFile::largeUncFileSupport()
// Retry in case of sharing violation
QTRY_VERIFY(fOpen(largeFileEncoded, "rb", &fhF));
StdioFileGuard fh(fhF);
- int fd = int(_fileno(fh));
+ int fd = int(QT_FILENO(fh));
QFile file;
QVERIFY(file.open(fd, QIODevice::ReadOnly));
QCOMPARE(file.size(), size);
@@ -2854,8 +2854,8 @@ void tst_QFile::handle()
StdioFileGuard fp(fopen(qPrintable(m_testSourceFile), "r"));
QVERIFY(fp);
file2.open(fp, QIODevice::ReadOnly);
- QCOMPARE(int(file2.handle()), int(fileno(fp)));
- QCOMPARE(int(file2.handle()), int(fileno(fp)));
+ QCOMPARE(int(file2.handle()), int(QT_FILENO(fp)));
+ QCOMPARE(int(file2.handle()), int(QT_FILENO(fp)));
fp.close();
//test round trip of adopted posix file handle
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index 732d81d84a..621214452b 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -57,8 +57,10 @@
#if defined(Q_OS_WIN)
#include <QtCore/qt_windows.h>
#include <private/qwinregistry_p.h>
+#define QT_UNLINK _unlink
#else
#include <unistd.h>
+#define QT_UNLINK unlink
#endif
#if defined(Q_OS_DARWIN)
@@ -1736,7 +1738,7 @@ void tst_QSettings::sync()
// Now "some other app" will change other.software.org.ini
QString userConfDir = settingsPath("__user__") + QDir::separator();
- unlink((userConfDir + "other.software.org.ini").toLatin1());
+ QT_UNLINK((userConfDir + "other.software.org.ini").toLatin1());
rename((userConfDir + "software.org.ini").toLatin1(),
(userConfDir + "other.software.org.ini").toLatin1());