From 0c5d00727eeff8801b1c71478281930f3bcd5ae1 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Fri, 15 Mar 2024 09:28:30 +0200 Subject: [PATCH] generic: remove redundant Q_OS_UNIX definition checks Signed-off-by: Ivailo Monev --- kdecore/config/kconfigini.cpp | 10 ---------- kdecore/io/ksavefile.cpp | 4 ---- kdecore/tests/kconfigtest.cpp | 4 ---- kdecore/tests/kmountpointtest.cpp | 4 ---- kdecore/tests/kprocesstest.cpp | 8 -------- kdecore/tests/ksavefiletest.cpp | 4 ---- kdecore/tests/kstandarddirstest.cpp | 6 ------ kdeui/icons/kiconloader.cpp | 6 +----- kdeui/kernel/kapplication.cpp | 2 -- kio/tests/fileundomanagertest.cpp | 2 -- kio/tests/kiotesthelper.h | 2 -- 11 files changed, 1 insertion(+), 51 deletions(-) diff --git a/kdecore/config/kconfigini.cpp b/kdecore/config/kconfigini.cpp index 90a876e4..8d521b59 100644 --- a/kdecore/config/kconfigini.cpp +++ b/kdecore/config/kconfigini.cpp @@ -480,7 +480,6 @@ bool KConfigIniBackend::writeConfig(const QByteArray& locale, KEntryMap& entryMa } } else { // Open existing file. *DON'T* create it if it suddenly does not exist! -#ifdef Q_OS_UNIX int fd = KDE_open(QFile::encodeName(filePath()), O_WRONLY | O_TRUNC); if (fd < 0) { return false; @@ -498,15 +497,6 @@ bool KConfigIniBackend::writeConfig(const QByteArray& locale, KEntryMap& entryMa writeEntries(locale, f, writeMap); f.close(); fclose(fp); -#else - QFile f( filePath() ); - // XXX This is broken - it DOES create the file if it is suddenly gone. - if (!f.open( QIODevice::WriteOnly | QIODevice::Truncate )) { - return false; - } - f.setTextModeEnabled(true); - writeEntries(locale, f, writeMap); -#endif } return true; } diff --git a/kdecore/io/ksavefile.cpp b/kdecore/io/ksavefile.cpp index 73521c67..a899fa00 100644 --- a/kdecore/io/ksavefile.cpp +++ b/kdecore/io/ksavefile.cpp @@ -102,7 +102,6 @@ bool KSaveFile::open(OpenMode flags) tempFile.setAutoRemove(false); tempFile.setFileTemplate(d->realFileName + QLatin1String("XXXXXX.new")); if (!tempFile.open()) { -#ifdef Q_OS_UNIX if (d->directWriteFallback && errno == EACCES) { QFile::setFileName(d->realFileName); if (QFile::open(flags)) { @@ -112,7 +111,6 @@ bool KSaveFile::open(OpenMode flags) return true; } } -#endif // we only check here if the directory can be written to // the actual filename isn't written to, but replaced later @@ -214,7 +212,6 @@ bool KSaveFile::finalize() } bool success = false; -#ifdef Q_OS_UNIX static const bool extraSync = (::getenv("KDE_EXTRA_FSYNC") != 0 ? true : false); if (extraSync) { if (flush()) { @@ -233,7 +230,6 @@ bool KSaveFile::finalize() } } } -#endif close(); diff --git a/kdecore/tests/kconfigtest.cpp b/kdecore/tests/kconfigtest.cpp index 9295b556..6cb97465 100644 --- a/kdecore/tests/kconfigtest.cpp +++ b/kdecore/tests/kconfigtest.cpp @@ -1192,15 +1192,11 @@ void KConfigTest::testReparent() static void ageTimeStamp(const QString& path, int nsec) { -#ifdef Q_OS_UNIX QDateTime mtime = QFileInfo(path).lastModified().addSecs(-nsec); struct utimbuf utbuf; utbuf.actime = mtime.toTime_t(); utbuf.modtime = utbuf.actime; utime(QFile::encodeName(path), &utbuf); -#else - QTest::qSleep(nsec * 1000); -#endif } void KConfigTest::testWriteOnSync() diff --git a/kdecore/tests/kmountpointtest.cpp b/kdecore/tests/kmountpointtest.cpp index 0d87b54b..af406518 100644 --- a/kdecore/tests/kmountpointtest.cpp +++ b/kdecore/tests/kmountpointtest.cpp @@ -68,7 +68,6 @@ void KMountPointTest::testCurrentMountPoints() QVERIFY(!found); // Check findByPath -#ifdef Q_OS_UNIX const KMountPoint::Ptr rootMountPoint = mountPoints.findByPath("/"); QVERIFY(rootMountPoint); QCOMPARE(rootMountPoint->mountPoint(), QString("/")); @@ -89,7 +88,6 @@ void KMountPointTest::testCurrentMountPoints() } else { kDebug() << "/home doesn't seem to exist, skipping test"; } -#endif } void KMountPointTest::testPossibleMountPoints() @@ -119,13 +117,11 @@ void KMountPointTest::testPossibleMountPoints() QVERIFY(mountWithDevice); -#ifdef Q_OS_UNIX const KMountPoint::Ptr rootMountPoint = mountPoints.findByPath("/"); QVERIFY(rootMountPoint); QCOMPARE(rootMountPoint->mountPoint(), QString("/")); QVERIFY(rootMountPoint->realDeviceName().startsWith(QLatin1String("/dev"))); // portable? QVERIFY(!rootMountPoint->mountOptions().contains("noauto")); // how would this work? QVERIFY(!rootMountPoint->probablySlow()); -#endif } diff --git a/kdecore/tests/kprocesstest.cpp b/kdecore/tests/kprocesstest.cpp index 592b8595..63fb5cfd 100644 --- a/kdecore/tests/kprocesstest.cpp +++ b/kdecore/tests/kprocesstest.cpp @@ -63,21 +63,14 @@ static QString recurse(QProcess::ProcessChannelMode how) void KProcessTest::test_channels() { -#ifdef Q_OS_UNIX QString e, a; TESTCHAN(SeparateChannels, "separate", "", EO, EE); TESTCHAN(ForwardedChannels, "forwarded", EO EE, "", ""); TESTCHAN(MergedChannels, "merged", "", EO EE, ""); -#else - QSKIP("This test needs a UNIX system", SkipSingle); -#endif } void KProcessTest::test_setShellCommand() { -#if !defined(Q_OS_UNIX) - QSKIP("This test needs a free UNIX system", SkipSingle); -#else KProcess p; p.setShellCommand("cat"); @@ -86,7 +79,6 @@ void KProcessTest::test_setShellCommand() QVERIFY(p.program().at(0).endsWith("/bin/cat")); p.setShellCommand("true || false"); QCOMPARE(p.program(), QStringList() << "/bin/sh" << "-c" << "true || false"); -#endif } static void recursor(char **argv) diff --git a/kdecore/tests/ksavefiletest.cpp b/kdecore/tests/ksavefiletest.cpp index 81933ffd..e785ffcf 100644 --- a/kdecore/tests/ksavefiletest.cpp +++ b/kdecore/tests/ksavefiletest.cpp @@ -186,7 +186,6 @@ void KSaveFileTest::transactionalWriteNoPermissionsOnDir_data() void KSaveFileTest::transactionalWriteNoPermissionsOnDir() { -#ifdef Q_OS_UNIX QFETCH(bool, directWriteFallback); // Restore permissions so that the QTemporaryDir cleanup can happen class PermissionRestorer @@ -255,11 +254,8 @@ void KSaveFileTest::transactionalWriteNoPermissionsOnDir() QVERIFY(!file.open(QIODevice::WriteOnly)); QCOMPARE((int)file.error(), (int)QFile::PermissionsError); } -#endif } - - void KSaveFileTest::test_backupFile() { KTemporaryFile file; diff --git a/kdecore/tests/kstandarddirstest.cpp b/kdecore/tests/kstandarddirstest.cpp index 9d03af91..502f4ff7 100644 --- a/kdecore/tests/kstandarddirstest.cpp +++ b/kdecore/tests/kstandarddirstest.cpp @@ -213,7 +213,6 @@ void KStandarddirsTest::testFindExe() QString klauncherexe = KGlobal::dirs()->locate( "exe", "klauncher4" ); QVERIFY2(klauncherexe.endsWith("bin/klauncher4" EXT, PATH_SENSITIVITY), qPrintable(klauncherexe)); -#ifdef Q_OS_UNIX // findExe with a result in libexec const QString kioslave = KGlobal::dirs()->findExe( "kioslave" ); QVERIFY( !kioslave.isEmpty() ); @@ -234,21 +233,16 @@ void KStandarddirsTest::testFindExe() } QVERIFY(possibleResults.contains(sh)); QDir::setCurrent(pwd); -#endif -#ifdef Q_OS_UNIX QFile home( m_kdehome ); const QString target = m_kdehome + "/linktodir"; home.link( target ); QVERIFY( KGlobal::dirs()->findExe( target ).isEmpty() ); -#endif -#ifdef Q_OS_UNIX // findExe for a binary not part of KDE const QString ls = KGlobal::dirs()->findExe( "ls" ); QVERIFY( !ls.isEmpty() ); QVERIFY( ls.endsWith( QLatin1String( "bin/ls" ) ) ); -#endif // findExe with no result const QString idontexist = KGlobal::dirs()->findExe( "idontexist" ); diff --git a/kdeui/icons/kiconloader.cpp b/kdeui/icons/kiconloader.cpp index f7575c25..3ee5f6e6 100644 --- a/kdeui/icons/kiconloader.cpp +++ b/kdeui/icons/kiconloader.cpp @@ -55,15 +55,11 @@ #include "kiconeffect.h" /** - * Checks for relative paths quickly on UNIX-alikes, slowly on everything else. + * Checks for relative paths quickly on UNIX-alikes */ static bool pathIsRelative(const QString &path) { -#ifdef Q_OS_UNIX return (!path.isEmpty() && path[0] != QChar('/')); -#else - return QDir::isRelativePath(path); -#endif } /** diff --git a/kdeui/kernel/kapplication.cpp b/kdeui/kernel/kapplication.cpp index 7fa17807..5043f592 100644 --- a/kdeui/kernel/kapplication.cpp +++ b/kdeui/kernel/kapplication.cpp @@ -185,13 +185,11 @@ static QList< QWeakPointer< QWidget > > *x11Filter = 0; */ static void installSigpipeHandler() { -#ifdef Q_OS_UNIX struct sigaction act; act.sa_handler = SIG_IGN; sigemptyset(&act.sa_mask); act.sa_flags = 0; sigaction(SIGPIPE, &act, 0); -#endif } void KApplication::installX11EventFilter( QWidget* filter ) diff --git a/kio/tests/fileundomanagertest.cpp b/kio/tests/fileundomanagertest.cpp index fc2374aa..4bc1908b 100644 --- a/kio/tests/fileundomanagertest.cpp +++ b/kio/tests/fileundomanagertest.cpp @@ -443,7 +443,6 @@ void FileUndoManagerTest::testTrashFiles() static void setTimeStamp( const QString& path ) { -#ifdef Q_OS_UNIX // Put timestamp in the past so that we can check that the // copy actually preserves it. struct timeval tp; @@ -453,7 +452,6 @@ static void setTimeStamp( const QString& path ) utbuf.modtime = tp.tv_sec + 60; // 60 second in the future utime( QFile::encodeName( path ), &utbuf ); qDebug( "Time changed for %s", qPrintable( path ) ); -#endif } void FileUndoManagerTest::testModifyFileBeforeUndo() diff --git a/kio/tests/kiotesthelper.h b/kio/tests/kiotesthelper.h index 6de7889e..41c68dd3 100644 --- a/kio/tests/kiotesthelper.h +++ b/kio/tests/kiotesthelper.h @@ -43,14 +43,12 @@ QDateTime s_referenceTimeStamp; static void setTimeStamp( const QString& path, const QDateTime& mtime ) { -#ifdef Q_OS_UNIX // Put timestamp in the past so that we can check that the listing is correct struct utimbuf utbuf; utbuf.actime = mtime.toTime_t(); utbuf.modtime = utbuf.actime; utime( QFile::encodeName( path ), &utbuf ); //qDebug( "Time changed for %s", qPrintable( path ) ); -#endif } static void createTestFile( const QString& path, bool plainText = false )