From aa4a2bb1e1775a61514f6c1906a92970728e4c62 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 4 Mar 2022 11:26:10 +0100 Subject: [PATCH] MS QNativeFilePermissions: fix unused member and capture warnings Two members are only used in code that's conditioned on pseudo-feature fslibs, which was defined in qfilesystemengine_win.cpp; move that definition to qfiledevice_p.h so that the members's existence can be conditioned on the same #if-ery as their use. The bootstrap build was broken by the warning. In the code that uses them, a lambda captured this but didn't use it, causing the non-bootstrap build to get a warning (hence error) and fail. So remove the unnecessary capture. Also suppressed warnings on an unused function. This amends commit 174af05400f6344a11f4aa2228244c954cbbca97 Pick-to: 6.3 Task-number: QTBUG-79750 Change-Id: Ib29f3200b7736bc07df68aeec4fc6f568c8f4ddb Reviewed-by: Marc Mutz Reviewed-by: Ievgenii Meshcheriakov --- src/corelib/io/qfiledevice_p.h | 11 +++++++++-- src/corelib/io/qfilesystemengine_win.cpp | 13 ++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/corelib/io/qfiledevice_p.h b/src/corelib/io/qfiledevice_p.h index 2b97773c2ff..b02af544aa9 100644 --- a/src/corelib/io/qfiledevice_p.h +++ b/src/corelib/io/qfiledevice_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -62,6 +62,11 @@ # include # include // for SECURITY_DESCRIPTOR # include +# if defined(QT_BOOTSTRAPPED) +# define QT_FEATURE_fslibs -1 +# else +# define QT_FEATURE_fslibs 1 +# endif // QT_BOOTSTRAPPED #endif QT_BEGIN_NAMESPACE @@ -155,9 +160,11 @@ private: static constexpr auto MaxACLSize = sizeof(ACL) + (sizeof(ACCESS_ALLOWED_ACE) + SECURITY_MAX_SID_SIZE) * MaxNumACEs; - SECURITY_DESCRIPTOR sd; SECURITY_ATTRIBUTES sa; +#if QT_CONFIG(fslibs) + SECURITY_DESCRIPTOR sd; alignas(DWORD) char aclStorage[MaxACLSize]; +#endif }; #endif // Q_OS_UNIX diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 5dfb311fdee..c72405d8670 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -138,12 +138,6 @@ typedef struct _REPARSE_DATA_BUFFER { CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS) #endif -#if defined(QT_BOOTSTRAPPED) -# define QT_FEATURE_fslibs -1 -#else -# define QT_FEATURE_fslibs 1 -#endif // QT_BOOTSTRAPPED - #if QT_CONFIG(fslibs) #include #include @@ -411,6 +405,7 @@ constexpr NonSpecificPermissions toNonSpecificPermissions(PermissionTag tag, return NonSpecificPermissions::fromInt((permissions.toInt() >> int(tag)) & 0x7); } +[[maybe_unused]] // Not currently used; included to show how to do it (without bit-rotting). constexpr QFileDevice::Permissions toSpecificPermissions(PermissionTag tag, NonSpecificPermissions permissions) { @@ -477,8 +472,8 @@ QNativeFilePermissions::QNativeFilePermissions(std::optional