Fix compiler warnings

This commit is contained in:
Maschell 2022-01-26 23:19:27 +01:00
parent 032459d809
commit cceda5e231
4 changed files with 25 additions and 27 deletions

View File

@ -17,7 +17,7 @@ fileMagic_t file_handles[FILE_HANDLES_LENGTH];
std::mutex dir_handle_mutex; std::mutex dir_handle_mutex;
std::mutex file_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) { inline void getFullPath(char *pathForCheck, int pathSize, char *path) {
if (path[0] != '/' && path[0] != '\\') { if (path[0] != '/' && path[0] != '\\') {
@ -28,7 +28,7 @@ inline void getFullPath(char *pathForCheck, int pathSize, char *path) {
strncat(pathForCheck, path, pathSize - 1); 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] == '\\') { if (pathForCheck[i] == '\\') {
pathForCheck[i] = '/'; pathForCheck[i] = '/';
} }
@ -129,7 +129,7 @@ void freeDirHandle(uint32_t handle) {
free(dir_handles[handle].mutex); free(dir_handles[handle].mutex);
dir_handles[handle].mutex = nullptr; dir_handles[handle].mutex = nullptr;
} }
memset(&dir_handles[handle], 0, sizeof(dirMagic_t)); dir_handles[handle] = {};
DCFlushRange(&dir_handles[handle], sizeof(dirMagic_t)); DCFlushRange(&dir_handles[handle], sizeof(dirMagic_t));
dir_handle_mutex.unlock(); dir_handle_mutex.unlock();
} }
@ -224,7 +224,7 @@ extern "C" FSStatus (*real_FSReadDir)(FSClient *client, FSCmdBlock *block, FSDir
FSStatus FSReadDirWrapper(FSDirectoryHandle handle, FSStatus FSReadDirWrapper(FSDirectoryHandle handle,
FSDirectoryEntry *entry, FSDirectoryEntry *entry,
FSErrorFlag errorMask, [[maybe_unused]] FSErrorFlag errorMask,
const std::function<FSStatus(FSStatus)> &result_handler) { const std::function<FSStatus(FSStatus)> &result_handler) {
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || 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); extern "C" FSStatus (*real_FSCloseDir)(FSClient *client, FSCmdBlock *block, FSDirectoryHandle handle, FSErrorFlag errorMask);
FSStatus FSCloseDirWrapper(FSDirectoryHandle handle, FSStatus FSCloseDirWrapper(FSDirectoryHandle handle,
FSErrorFlag errorMask, [[maybe_unused]] FSErrorFlag errorMask,
const std::function<FSStatus(FSStatus)> &result_handler) { const std::function<FSStatus(FSStatus)> &result_handler) {
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) || (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); extern "C" FSStatus (*real_FSRewindDir)(FSClient *client, FSCmdBlock *block, FSDirectoryHandle handle, FSErrorFlag errorMask);
FSStatus FSRewindDirWrapper(FSDirectoryHandle handle, FSStatus FSRewindDirWrapper(FSDirectoryHandle handle,
FSErrorFlag errorMask, [[maybe_unused]] FSErrorFlag errorMask,
const std::function<FSStatus(FSStatus)> &result_handler) { const std::function<FSStatus(FSStatus)> &result_handler) {
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) || (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
@ -570,7 +570,7 @@ FSStatus FSOpenFileWrapper(char *path,
} }
FSStatus FSCloseFileWrapper(FSFileHandle handle, FSStatus FSCloseFileWrapper(FSFileHandle handle,
FSErrorFlag errorMask, [[maybe_unused]] FSErrorFlag errorMask,
const std::function<FSStatus(FSStatus)> &result_handler) { const std::function<FSStatus(FSStatus)> &result_handler) {
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) || (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; return FS_STATUS_USE_REAL_OS;
} }
static inline void replaceContentPath(char *pathForCheck, int pathForCheckSize, int skipLen, char *replaceWith) { static inline void replaceContentPath(char *pathForCheck, size_t pathForCheckSize, int skipLen, char *replaceWith) {
int subStrLen = strlen(pathForCheck) - skipLen; size_t subStrLen = strlen(pathForCheck) - skipLen;
if (subStrLen <= 0) { if (subStrLen <= 0) {
pathForCheck[0] = '\0'; pathForCheck[0] = '\0';
if (strlen(replaceWith) + 1 <= pathForCheckSize) { if (strlen(replaceWith) + 1 <= pathForCheckSize) {
@ -679,7 +679,7 @@ static inline void replaceContentPath(char *pathForCheck, int pathForCheckSize,
FSStatus FSGetStatFileWrapper(FSFileHandle handle, FSStatus FSGetStatFileWrapper(FSFileHandle handle,
FSStat *stats, FSStat *stats,
FSErrorFlag errorMask, [[maybe_unused]] FSErrorFlag errorMask,
const std::function<FSStatus(FSStatus)> &result_handler) { const std::function<FSStatus(FSStatus)> &result_handler) {
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) || (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
@ -721,8 +721,8 @@ FSStatus FSReadFileWrapper(void *buffer,
uint32_t size, uint32_t size,
uint32_t count, uint32_t count,
FSFileHandle handle, FSFileHandle handle,
uint32_t unk1, [[maybe_unused]] uint32_t unk1,
FSErrorFlag errorMask, [[maybe_unused]] FSErrorFlag errorMask,
const std::function<FSStatus(FSStatus)> &result_handler) { const std::function<FSStatus(FSStatus)> &result_handler) {
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) || (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
@ -796,7 +796,7 @@ FSStatus FSReadFileWithPosWrapper(void *buffer,
FSStatus FSSetPosFileWrapper(FSFileHandle handle, FSStatus FSSetPosFileWrapper(FSFileHandle handle,
uint32_t pos, uint32_t pos,
FSErrorFlag errorMask, [[maybe_unused]] FSErrorFlag errorMask,
const std::function<FSStatus(FSStatus)> &result_handler) { const std::function<FSStatus(FSStatus)> &result_handler) {
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) || (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
@ -828,7 +828,7 @@ FSStatus FSSetPosFileWrapper(FSFileHandle handle,
FSStatus FSGetPosFileWrapper(FSFileHandle handle, FSStatus FSGetPosFileWrapper(FSFileHandle handle,
uint32_t *pos, uint32_t *pos,
FSErrorFlag errorMask, [[maybe_unused]] FSErrorFlag errorMask,
const std::function<FSStatus(FSStatus)> &result_handler) { const std::function<FSStatus(FSStatus)> &result_handler) {
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) || (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
@ -861,7 +861,7 @@ FSStatus FSGetPosFileWrapper(FSFileHandle handle,
} }
FSStatus FSIsEofWrapper(FSFileHandle handle, FSStatus FSIsEofWrapper(FSFileHandle handle,
FSErrorFlag errorMask, [[maybe_unused]] FSErrorFlag errorMask,
const std::function<FSStatus(FSStatus)> &result_handler) { const std::function<FSStatus(FSStatus)> &result_handler) {
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) || (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) ||
@ -918,11 +918,11 @@ FSStatus FSTruncateFileWrapper(FSFileHandle handle,
return result_handler(result); return result_handler(result);
} }
FSStatus FSWriteFileWrapper(uint8_t *buffer, FSStatus FSWriteFileWrapper([[maybe_unused]] uint8_t *buffer,
uint32_t size, [[maybe_unused]] uint32_t size,
uint32_t count, [[maybe_unused]] uint32_t count,
FSFileHandle handle, FSFileHandle handle,
uint32_t unk1, [[maybe_unused]] uint32_t unk1,
FSErrorFlag errorMask, FSErrorFlag errorMask,
const std::function<FSStatus(FSStatus)> &result_handler) { const std::function<FSStatus(FSStatus)> &result_handler) {
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
@ -1001,7 +1001,7 @@ FSStatus FSRenameWrapper(char *oldPath,
return result_handler(result); return result_handler(result);
} }
FSStatus FSFlushFileWrapper(FSFileHandle handle, FSErrorFlag errorMask, const std::function<FSStatus(FSStatus)> &result_handler) { FSStatus FSFlushFileWrapper([[maybe_unused]] FSFileHandle handle, FSErrorFlag errorMask, const std::function<FSStatus(FSStatus)> &result_handler) {
if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) || if ((gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_NONE) ||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_PATH) || (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_PATH) ||
(gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted)) { (gReplacementInfo.contentReplacementInfo.mode == CONTENTREDIRECT_FROM_WUHB_BUNDLE && !gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted)) {

View File

@ -39,6 +39,7 @@ FSStatus send_result_async(FSClient *client, FSCmdBlock *block, FSAsyncData *asy
} }
if (asyncData->ioMsgQueue != nullptr) { if (asyncData->ioMsgQueue != nullptr) {
#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
FSAsyncResult *result = &(fsCmdBlockGetBody(block)->asyncResult); FSAsyncResult *result = &(fsCmdBlockGetBody(block)->asyncResult);
//DEBUG_FUNCTION_LINE("Send result %d to ioMsgQueue (%08X)", status, asyncData->ioMsgQueue); //DEBUG_FUNCTION_LINE("Send result %d to ioMsgQueue (%08X)", status, asyncData->ioMsgQueue);
result->asyncData.callback = asyncData->callback; 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; void *newBuffer = buffer;
int32_t curResult = -1; int32_t curResult = -1;
int32_t totalSize = 0; int32_t totalSize = 0;
int32_t toRead = 0; // int32_t toRead = 0;
while (sizeToRead > 0) { while (sizeToRead > 0) {
curResult = read(handle, newBuffer, sizeToRead); curResult = read(handle, newBuffer, sizeToRead);
if (curResult < 0) { if (curResult < 0) {
int errsv = errno; DEBUG_FUNCTION_LINE("Error: Reading %08X bytes from handle %08X. result %08X errno: %d ", size * count, handle, curResult, errno);
DEBUG_FUNCTION_LINE("Error: Reading %08X bytes from handle %08X. result %08X errno: %d ", size * count, handle, curResult, errsv);
return -1; return -1;
} }
if (curResult == 0) { if (curResult == 0) {

View File

@ -15,10 +15,8 @@
#include "utils/ini.h" #include "utils/ini.h"
#include <cstring> #include <cstring>
#include <rpxloader.h> #include <rpxloader.h>
#include <sys/types.h>
#include <dirent.h> #include <dirent.h>
/* /*
* Patch the meta xml for the home menu * 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'; gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath[0] = '\0';
strncat(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath, strncat(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath,
gReplacementInfo.contentReplacementInfo.bundleMountInformation.mountedPath, gReplacementInfo.contentReplacementInfo.bundleMountInformation.mountedPath,
sizeof(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath) - 1); sizeof(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath) - 2);
} else { } else {
gReplacementInfo.contentReplacementInfo.replaceSave = false; gReplacementInfo.contentReplacementInfo.replaceSave = false;
} }

View File

@ -259,7 +259,7 @@ char *StringTools::str_replace(char *orig, char *rep, char *with) {
if (len_rep == 0) if (len_rep == 0)
return nullptr; // empty rep causes infinite loop during count return nullptr; // empty rep causes infinite loop during count
if (!with) if (!with)
with = ""; with = (char *) "";
len_with = strlen(with); len_with = strlen(with);
// count the number of replacements needed // count the number of replacements needed