From 11491fcc5fb9283ae9f735c4834e00926b19c8ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Tue, 9 May 2023 08:59:23 +0300 Subject: [PATCH] CTF: Fix reading a session file Use qsizetype. Invert fread arguments to get the read size. Pick-to: 6.5 Change-Id: I20684dc7a30177394b387e8893198007dbf36eed Reviewed-by: Janne Koskinen Reviewed-by: Hatem ElKharashy --- src/plugins/tracing/qctflib.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugins/tracing/qctflib.cpp b/src/plugins/tracing/qctflib.cpp index f0bc001456..a237dfa02f 100644 --- a/src/plugins/tracing/qctflib.cpp +++ b/src/plugins/tracing/qctflib.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "qctflib_p.h" #include @@ -79,12 +80,12 @@ QCtfLibImpl::QCtfLibImpl() m_session.name = QStringLiteral("default"); } else { fseek(file, 0, SEEK_END); - long pos = ftell(file); + qsizetype pos = ftell(file); fseek(file, 0, SEEK_SET); QByteArray data(pos, Qt::Uninitialized); - long size = (long)fread(data.data(), pos, 1, file); + qsizetype size = (qsizetype)fread(data.data(), 1, pos, file); fclose(file); - if (size != 1) + if (size != pos) return; QJsonDocument json(QJsonDocument::fromJson(data)); @@ -93,7 +94,7 @@ QCtfLibImpl::QCtfLibImpl() if (value.isNull() || !value.isArray()) return; m_session.name = obj.begin().key(); - QJsonArray arr = value.toArray(); + const QJsonArray arr = value.toArray(); for (auto var : arr) m_session.tracepoints.append(var.toString());