From cb9d76169aefc95f4e8962dcbff98bedd63a3e50 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Mon, 31 Oct 2022 22:57:24 +0200 Subject: [PATCH] QFileSystemEngine/Unix: remove futimes related code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - futimes isn't a standard system call[1]: « This system call is nonstandard. It was implemented from a specification that was proposed for POSIX.1, but that specification was replaced by the one for utimensat(2). A similar system call exists on Solaris. » [1] https://man7.org/linux/man-pages/man2/futimesat.2.html [2] https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html - futimens is a standard system call[2], it's available on: - Linux: https://man7.org/linux/man-pages/man2/futimesat.2.html - FreeBSD: https://www.freebsd.org/cgi/man.cgi?query=futimens&sektion=2&n=1 - OpenBSD: https://man.openbsd.org/futimens.2 - QNX: https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/f/futimens.html So, remove futimes related code. Change-Id: I58ac466f08161a88219e3a32eab98d168f065140 Reviewed-by: Thiago Macieira --- src/corelib/configure.cmake | 20 -------- src/corelib/global/qconfig-bootstrapped.h | 1 - src/corelib/io/qfilesystemengine_unix.cpp | 62 ----------------------- 3 files changed, 83 deletions(-) diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake index d2e8fa42059..089892cbccc 100644 --- a/src/corelib/configure.cmake +++ b/src/corelib/configure.cmake @@ -229,22 +229,6 @@ futimens(-1, 0); /* END TEST: */ return 0; } -"# FIXME: qmake: ["# Block futimens() on Apple platforms unless it's available on ALL", '# deployment targets. This simplifies the logic at the call site', "# dramatically, as it isn't strictly needed compared to futimes().", 'darwin: QMAKE_CXXFLAGS += -Werror=unguarded-availability -Werror=unguarded-availability-new', 'CONFIG += warn_on'] -) - -# futimes -qt_config_compile_test(futimes - LABEL "futimes()" - CODE -"#include - -int main(void) -{ - /* BEGIN TEST: */ -futimes(-1, 0); - /* END TEST: */ - return 0; -} ") # getauxval @@ -578,10 +562,6 @@ qt_feature("futimens" PRIVATE LABEL "futimens()" CONDITION NOT WIN32 AND TEST_futimens ) -qt_feature("futimes" PRIVATE - LABEL "futimes()" - CONDITION NOT WIN32 AND NOT QT_FEATURE_futimens AND TEST_futimes -) qt_feature("getauxval" PRIVATE LABEL "getauxval()" CONDITION LINUX AND TEST_getauxval diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index ff5709f7af1..78d622f5e9a 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -63,7 +63,6 @@ #define QT_FEATURE_jalalicalendar -1 #define QT_FEATURE_journald -1 #define QT_FEATURE_futimens -1 -#define QT_FEATURE_futimes -1 #define QT_FEATURE_future -1 #define QT_FEATURE_itemmodel -1 #define QT_FEATURE_library -1 diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 0645952091f..b727463a3c0 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -159,41 +159,6 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e namespace { namespace GetFileTimes { -#if !QT_CONFIG(futimens) && (QT_CONFIG(futimes)) -template -static inline typename std::enable_if_t<(&T::st_atim, &T::st_mtim, true)> get(const T *p, struct timeval *access, struct timeval *modification) -{ - access->tv_sec = p->st_atim.tv_sec; - access->tv_usec = p->st_atim.tv_nsec / 1000; - - modification->tv_sec = p->st_mtim.tv_sec; - modification->tv_usec = p->st_mtim.tv_nsec / 1000; -} - -template -static inline typename std::enable_if_t<(&T::st_atimespec, &T::st_mtimespec, true)> get(const T *p, struct timeval *access, struct timeval *modification) -{ - access->tv_sec = p->st_atimespec.tv_sec; - access->tv_usec = p->st_atimespec.tv_nsec / 1000; - - modification->tv_sec = p->st_mtimespec.tv_sec; - modification->tv_usec = p->st_mtimespec.tv_nsec / 1000; -} - -# ifndef st_atimensec -// if "st_atimensec" is defined, this would expand to invalid C++ -template -static inline typename std::enable_if_t<(&T::st_atimensec, &T::st_mtimensec, true)> get(const T *p, struct timeval *access, struct timeval *modification) -{ - access->tv_sec = p->st_atime; - access->tv_usec = p->st_atimensec / 1000; - - modification->tv_sec = p->st_mtime; - modification->tv_usec = p->st_mtimensec / 1000; -} -# endif -#endif - qint64 timespecToMSecs(const timespec &spec) { return (qint64(spec.tv_sec) * 1000) + (spec.tv_nsec / 1000000); @@ -1567,33 +1532,6 @@ bool QFileSystemEngine::setFileTime(int fd, const QDateTime &newDate, QAbstractF return false; } - return true; -#elif QT_CONFIG(futimes) - struct timeval tv[2]; - QT_STATBUF st; - - if (QT_FSTAT(fd, &st) == -1) { - error = QSystemError(errno, QSystemError::StandardLibraryError); - return false; - } - - GetFileTimes::get(&st, &tv[0], &tv[1]); - - const qint64 msecs = newDate.toMSecsSinceEpoch(); - - if (time == QAbstractFileEngine::AccessTime) { - tv[0].tv_sec = msecs / 1000; - tv[0].tv_usec = (msecs % 1000) * 1000; - } else if (time == QAbstractFileEngine::ModificationTime) { - tv[1].tv_sec = msecs / 1000; - tv[1].tv_usec = (msecs % 1000) * 1000; - } - - if (futimes(fd, tv) == -1) { - error = QSystemError(errno, QSystemError::StandardLibraryError); - return false; - } - return true; #else Q_UNUSED(fd);