From 8fa9705079d330dbbfec5d9a877b5ff9cd790f3e Mon Sep 17 00:00:00 2001 From: Rayyan Ansari Date: Mon, 6 Nov 2023 21:27:09 +0000 Subject: [PATCH] ArchiveUtil: use signed return type instead of unsigned The ExtractFileFromArchive function can sometimes return -1 on error, however the function's return type was specified as u32, which would mean that it would instead be represented as the maximum value. Change the function's return type to the signed s32 instead, and correct uses. --- src/frontend/qt_sdl/ArchiveUtil.cpp | 2 +- src/frontend/qt_sdl/ArchiveUtil.h | 2 +- src/frontend/qt_sdl/ROMManager.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/frontend/qt_sdl/ArchiveUtil.cpp b/src/frontend/qt_sdl/ArchiveUtil.cpp index 91b993cd..6f4b1348 100644 --- a/src/frontend/qt_sdl/ArchiveUtil.cpp +++ b/src/frontend/qt_sdl/ArchiveUtil.cpp @@ -119,7 +119,7 @@ QVector ExtractFileFromArchive(QString path, QString wantedFile, QByteA } -u32 ExtractFileFromArchive(QString path, QString wantedFile, u8** filedata, u32* filesize) +s32 ExtractFileFromArchive(QString path, QString wantedFile, u8** filedata, u32* filesize) { struct archive *a = archive_read_new(); struct archive_entry *entry; diff --git a/src/frontend/qt_sdl/ArchiveUtil.h b/src/frontend/qt_sdl/ArchiveUtil.h index d9327c80..14ff9968 100644 --- a/src/frontend/qt_sdl/ArchiveUtil.h +++ b/src/frontend/qt_sdl/ArchiveUtil.h @@ -36,7 +36,7 @@ namespace Archive { QVector ListArchive(QString path); -u32 ExtractFileFromArchive(QString path, QString wantedFile, u8** filedata, u32* filesize); +s32 ExtractFileFromArchive(QString path, QString wantedFile, u8** filedata, u32* filesize); //QVector ExtractFileFromArchive(QString path, QString wantedFile, QByteArray *romBuffer); //u32 ExtractFileFromArchive(const char* path, const char* wantedFile, u8 **romdata); diff --git a/src/frontend/qt_sdl/ROMManager.cpp b/src/frontend/qt_sdl/ROMManager.cpp index 6b2b0b06..0bb6b7fe 100644 --- a/src/frontend/qt_sdl/ROMManager.cpp +++ b/src/frontend/qt_sdl/ROMManager.cpp @@ -1362,7 +1362,7 @@ bool LoadGBAROM(QStringList filepath) { // file inside archive - u32 lenread = Archive::ExtractFileFromArchive(filepath.at(0), filepath.at(1), &filedata, &filelen); + s32 lenread = Archive::ExtractFileFromArchive(filepath.at(0), filepath.at(1), &filedata, &filelen); if (lenread < 0) return false; if (!filedata) return false; if (lenread != filelen)