diff --git a/src/FSWrapper.cpp b/src/FSWrapper.cpp index 99b1216..6b5497f 100644 --- a/src/FSWrapper.cpp +++ b/src/FSWrapper.cpp @@ -17,7 +17,7 @@ fileMagic_t file_handles[FILE_HANDLES_LENGTH]; std::mutex dir_handle_mutex; std::mutex file_handle_mutex; -static inline void replaceContentPath(char *pathForCheck, int pathForCheckSize, int replaceLen, char *replaceWith); +static inline void replaceContentPath(char *pathForCheck, size_t pathForCheckSize, int replaceLen, char *replaceWith); inline void getFullPath(char *pathForCheck, int pathSize, char *path) { if (path[0] != '/' && path[0] != '\\') { @@ -28,7 +28,7 @@ inline void getFullPath(char *pathForCheck, int pathSize, char *path) { strncat(pathForCheck, path, pathSize - 1); } - for (int i = 0; i < strlen(pathForCheck); i++) { + for (size_t i = 0; i < strlen(pathForCheck); i++) { if (pathForCheck[i] == '\\') { pathForCheck[i] = '/'; } @@ -129,7 +129,7 @@ void freeDirHandle(uint32_t handle) { free(dir_handles[handle].mutex); dir_handles[handle].mutex = nullptr; } - memset(&dir_handles[handle], 0, sizeof(dirMagic_t)); + dir_handles[handle] = {}; DCFlushRange(&dir_handles[handle], sizeof(dirMagic_t)); dir_handle_mutex.unlock(); } @@ -224,7 +224,7 @@ extern "C" FSStatus (*real_FSReadDir)(FSClient *client, FSCmdBlock *block, FSDir FSStatus FSReadDirWrapper(FSDirectoryHandle handle, FSDirectoryEntry *entry, - FSErrorFlag errorMask, + [[maybe_unused]] FSErrorFlag errorMask, const std::function &result_handler) { if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || @@ -349,7 +349,7 @@ FSStatus FSReadDirWrapper(FSDirectoryHandle handle, extern "C" FSStatus (*real_FSCloseDir)(FSClient *client, FSCmdBlock *block, FSDirectoryHandle handle, FSErrorFlag errorMask); FSStatus FSCloseDirWrapper(FSDirectoryHandle handle, - FSErrorFlag errorMask, + [[maybe_unused]] FSErrorFlag errorMask, const std::function &result_handler) { if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) || @@ -404,7 +404,7 @@ FSStatus FSCloseDirWrapper(FSDirectoryHandle handle, extern "C" FSStatus (*real_FSRewindDir)(FSClient *client, FSCmdBlock *block, FSDirectoryHandle handle, FSErrorFlag errorMask); FSStatus FSRewindDirWrapper(FSDirectoryHandle handle, - FSErrorFlag errorMask, + [[maybe_unused]] FSErrorFlag errorMask, const std::function &result_handler) { if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) || @@ -570,7 +570,7 @@ FSStatus FSOpenFileWrapper(char *path, } FSStatus FSCloseFileWrapper(FSFileHandle handle, - FSErrorFlag errorMask, + [[maybe_unused]] FSErrorFlag errorMask, const std::function &result_handler) { if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) || @@ -662,8 +662,8 @@ FSStatus FSGetStatWrapper(char *path, FSStat *stats, FSErrorFlag errorMask, return FS_STATUS_USE_REAL_OS; } -static inline void replaceContentPath(char *pathForCheck, int pathForCheckSize, int skipLen, char *replaceWith) { - int subStrLen = strlen(pathForCheck) - skipLen; +static inline void replaceContentPath(char *pathForCheck, size_t pathForCheckSize, int skipLen, char *replaceWith) { + size_t subStrLen = strlen(pathForCheck) - skipLen; if (subStrLen <= 0) { pathForCheck[0] = '\0'; if (strlen(replaceWith) + 1 <= pathForCheckSize) { @@ -679,7 +679,7 @@ static inline void replaceContentPath(char *pathForCheck, int pathForCheckSize, FSStatus FSGetStatFileWrapper(FSFileHandle handle, FSStat *stats, - FSErrorFlag errorMask, + [[maybe_unused]] FSErrorFlag errorMask, const std::function &result_handler) { if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) || @@ -721,8 +721,8 @@ FSStatus FSReadFileWrapper(void *buffer, uint32_t size, uint32_t count, FSFileHandle handle, - uint32_t unk1, - FSErrorFlag errorMask, + [[maybe_unused]] uint32_t unk1, + [[maybe_unused]] FSErrorFlag errorMask, const std::function &result_handler) { if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) || @@ -796,7 +796,7 @@ FSStatus FSReadFileWithPosWrapper(void *buffer, FSStatus FSSetPosFileWrapper(FSFileHandle handle, uint32_t pos, - FSErrorFlag errorMask, + [[maybe_unused]] FSErrorFlag errorMask, const std::function &result_handler) { if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) || @@ -828,7 +828,7 @@ FSStatus FSSetPosFileWrapper(FSFileHandle handle, FSStatus FSGetPosFileWrapper(FSFileHandle handle, uint32_t *pos, - FSErrorFlag errorMask, + [[maybe_unused]] FSErrorFlag errorMask, const std::function &result_handler) { if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) || @@ -861,7 +861,7 @@ FSStatus FSGetPosFileWrapper(FSFileHandle handle, } FSStatus FSIsEofWrapper(FSFileHandle handle, - FSErrorFlag errorMask, + [[maybe_unused]] FSErrorFlag errorMask, const std::function &result_handler) { if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) || @@ -918,11 +918,11 @@ FSStatus FSTruncateFileWrapper(FSFileHandle handle, return result_handler(result); } -FSStatus FSWriteFileWrapper(uint8_t *buffer, - uint32_t size, - uint32_t count, +FSStatus FSWriteFileWrapper([[maybe_unused]] uint8_t *buffer, + [[maybe_unused]] uint32_t size, + [[maybe_unused]] uint32_t count, FSFileHandle handle, - uint32_t unk1, + [[maybe_unused]] uint32_t unk1, FSErrorFlag errorMask, const std::function &result_handler) { if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || @@ -1001,7 +1001,7 @@ FSStatus FSRenameWrapper(char *oldPath, return result_handler(result); } -FSStatus FSFlushFileWrapper(FSFileHandle handle, FSErrorFlag errorMask, const std::function &result_handler) { +FSStatus FSFlushFileWrapper([[maybe_unused]] FSFileHandle handle, FSErrorFlag errorMask, const std::function &result_handler) { if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_PATH) || (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted)) { diff --git a/src/FileUtils.cpp b/src/FileUtils.cpp index 3a73358..9490ead 100644 --- a/src/FileUtils.cpp +++ b/src/FileUtils.cpp @@ -39,6 +39,7 @@ FSStatus send_result_async(FSClient *client, FSCmdBlock *block, FSAsyncData *asy } if (asyncData->ioMsgQueue != nullptr) { +#pragma GCC diagnostic ignored "-Waddress-of-packed-member" FSAsyncResult *result = &(fsCmdBlockGetBody(block)->asyncResult); //DEBUG_FUNCTION_LINE("Send result %d to ioMsgQueue (%08X)", status, asyncData->ioMsgQueue); result->asyncData.callback = asyncData->callback; @@ -68,12 +69,11 @@ int32_t readIntoBuffer(int32_t handle, void *buffer, size_t size, size_t count) void *newBuffer = buffer; int32_t curResult = -1; int32_t totalSize = 0; - int32_t toRead = 0; + // int32_t toRead = 0; while (sizeToRead > 0) { curResult = read(handle, newBuffer, sizeToRead); if (curResult < 0) { - int errsv = errno; - DEBUG_FUNCTION_LINE("Error: Reading %08X bytes from handle %08X. result %08X errno: %d ", size * count, handle, curResult, errsv); + DEBUG_FUNCTION_LINE("Error: Reading %08X bytes from handle %08X. result %08X errno: %d ", size * count, handle, curResult, errno); return -1; } if (curResult == 0) { diff --git a/src/RPXLoading.cpp b/src/RPXLoading.cpp index b669e7d..e5130c9 100644 --- a/src/RPXLoading.cpp +++ b/src/RPXLoading.cpp @@ -15,10 +15,8 @@ #include "utils/ini.h" #include #include -#include #include - /* * Patch the meta xml for the home menu */ @@ -226,7 +224,7 @@ bool RL_LoadFromSDOnNextLaunch(const char *bundle_path) { gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath[0] = '\0'; strncat(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath, gReplacementInfo.contentReplacementInfo.bundleMountInformation.mountedPath, - sizeof(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath) - 1); + sizeof(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath) - 2); } else { gReplacementInfo.contentReplacementInfo.replaceSave = false; } diff --git a/src/utils/StringTools.cpp b/src/utils/StringTools.cpp index 18b8d0e..eca34b8 100644 --- a/src/utils/StringTools.cpp +++ b/src/utils/StringTools.cpp @@ -259,7 +259,7 @@ char *StringTools::str_replace(char *orig, char *rep, char *with) { if (len_rep == 0) return nullptr; // empty rep causes infinite loop during count if (!with) - with = ""; + with = (char *) ""; len_with = strlen(with); // count the number of replacements needed