From 5e2b4c401d19f2067a9ce799883113f59cb66607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Mon, 29 May 2023 09:02:16 +0300 Subject: [PATCH] CTF: Use access to check if location is writable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pick-to: 6.5 Change-Id: Ic6afcf74432f176374d47e828b480e4d2499c670 Reviewed-by: Antti Määttä Reviewed-by: Janne Koskinen Reviewed-by: Hatem ElKharashy --- src/plugins/tracing/qctflib.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/plugins/tracing/qctflib.cpp b/src/plugins/tracing/qctflib.cpp index 28016982dd..9311bb1fdd 100644 --- a/src/plugins/tracing/qctflib.cpp +++ b/src/plugins/tracing/qctflib.cpp @@ -62,16 +62,13 @@ QCtfLibImpl::QCtfLibImpl() } // Check if the location is writable - FILE *file = nullptr; - file = fopen(qPrintable(location + "/metadata"_L1), "w+b"); - if (!file) { + if (QT_ACCESS(qPrintable(location), W_OK) != 0) { qCWarning (lcDebugTrace) << "Unable to write to location"; return; } - fclose(file); const QString filename = location + QStringLiteral("/session.json"); - file = fopen(qPrintable(filename), "rb"); + FILE *file = fopen(qPrintable(filename), "rb"); if (!file) { qCWarning (lcDebugTrace) << "unable to open session file: " << filename; m_location = location;