From b2cba5c4a88763d9110174100d4e1611b17ddd0f Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 15 Jan 2026 16:50:01 +0100 Subject: [PATCH] Fix warnings --- source/config/WUPSConfigAPI.cpp | 22 +++++++++---------- source/config/WUPSConfigAPIDeprecated.cpp | 12 +++++----- source/main.cpp | 8 +++---- source/plugin/ButtonComboManager.cpp | 2 +- source/plugin/FunctionData.cpp | 2 +- .../plugin/PluginLinkInformationFactory.cpp | 12 +++++----- source/utils/HeapMemoryFixedSize.cpp | 2 +- source/utils/config/ConfigUtils.cpp | 4 ++-- source/utils/logger.h | 1 + source/utils/storage/StorageUtils.cpp | 2 +- source/utils/utils.cpp | 2 +- 11 files changed, 35 insertions(+), 34 deletions(-) diff --git a/source/config/WUPSConfigAPI.cpp b/source/config/WUPSConfigAPI.cpp index 46c1845..b16073b 100644 --- a/source/config/WUPSConfigAPI.cpp +++ b/source/config/WUPSConfigAPI.cpp @@ -22,13 +22,13 @@ namespace WUPSConfigAPIBackend { std::vector> sConfigs; - std::mutex sConfigsMutex; + std::recursive_mutex sConfigsMutex; std::vector> sConfigCategories; - std::mutex sConfigCategoryMutex; + std::recursive_mutex sConfigCategoryMutex; std::vector> sConfigItems; - std::mutex sConfigItemsMutex; + std::recursive_mutex sConfigItemsMutex; namespace Intern { WUPSConfig *GetConfigByHandle(WUPSConfigHandle handle) { @@ -201,7 +201,7 @@ namespace WUPSConfigAPIBackend { return WUPSCONFIG_API_RESULT_SUCCESS; } } - DEBUG_FUNCTION_LINE_WARN("Failed to destroy WUPSConfigCategory (for handle: \"%08X\")", handle.handle); + DEBUG_FUNCTION_LINE_WARN("Failed to destroy WUPSConfigCategory (for handle: \"%p\")", handle.handle); return WUPSCONFIG_API_RESULT_NOT_FOUND; } return WUPSCONFIG_API_RESULT_SUCCESS; @@ -218,20 +218,20 @@ namespace WUPSConfigAPIBackend { if (!parentCat) { parentCat = Intern::GetCategoryByHandle(parentHandle); if (!parentCat) { - DEBUG_FUNCTION_LINE_WARN("Failed to find parent for handle %08X", parentHandle.handle); + DEBUG_FUNCTION_LINE_WARN("Failed to find parent for handle %p", parentHandle.handle); return WUPSCONFIG_API_RESULT_NOT_FOUND; } } auto category = Intern::PopCategoryByHandle(categoryHandle); if (!category) { - DEBUG_FUNCTION_LINE_WARN("Failed to find category. parentHandle: %08X categoryHandle: %08X", parentHandle.handle, categoryHandle.handle); + DEBUG_FUNCTION_LINE_WARN("Failed to find category. parentHandle: %p categoryHandle: %p", parentHandle.handle, categoryHandle.handle); return WUPSCONFIG_API_RESULT_NOT_FOUND; } if (!parentCat->addCategory(category)) { sConfigCategories.push_back(std::move(category)); - DEBUG_FUNCTION_LINE_WARN("Failed to add category to parent. parentHandle: %08X categoryHandle: %08X", parentHandle.handle, categoryHandle.handle); + DEBUG_FUNCTION_LINE_WARN("Failed to add category to parent. parentHandle: %p categoryHandle: %p", parentHandle.handle, categoryHandle.handle); return WUPSCONFIG_API_RESULT_UNKNOWN_ERROR; // TODO!!! } return WUPSCONFIG_API_RESULT_SUCCESS; @@ -249,21 +249,21 @@ namespace WUPSConfigAPIBackend { if (!parentCat) { parentCat = Intern::GetCategoryByHandle(parentHandle, true); if (!parentCat) { - DEBUG_FUNCTION_LINE_WARN("Failed to find parent for handle %08X", parentHandle.handle); + DEBUG_FUNCTION_LINE_WARN("Failed to find parent for handle %p", parentHandle.handle); return WUPSCONFIG_API_RESULT_NOT_FOUND; } } auto item = Intern::PopItemByHandle(itemHandle); if (!item) { - DEBUG_FUNCTION_LINE_ERR("Failed to get item for handle %08X", itemHandle.handle); + DEBUG_FUNCTION_LINE_ERR("Failed to get item for handle %p", itemHandle.handle); return WUPSCONFIG_API_RESULT_NOT_FOUND; } if (!parentCat->addItem(item)) { std::lock_guard lockItems(sConfigItemsMutex); sConfigItems.push_back(std::move(item)); - DEBUG_FUNCTION_LINE_ERR("Failed to add item %08X to category %08X", itemHandle.handle, parentHandle.handle); + DEBUG_FUNCTION_LINE_ERR("Failed to add item %p to category %p", itemHandle.handle, parentHandle.handle); return WUPSCONFIG_API_RESULT_UNKNOWN_ERROR; // TODO } @@ -305,7 +305,7 @@ namespace WUPSConfigAPIBackend { } if (!remove_locked_first_if(sConfigItemsMutex, sConfigItems, [&handle](auto &cur) { return cur.get() == handle; })) { - DEBUG_FUNCTION_LINE_WARN("Failed to destroy WUPSConfigItem (handle: \"%08X\")", handle); + DEBUG_FUNCTION_LINE_WARN("Failed to destroy WUPSConfigItem (handle: \"%p\")", handle.handle); return WUPSCONFIG_API_RESULT_NOT_FOUND; } return WUPSCONFIG_API_RESULT_SUCCESS; diff --git a/source/config/WUPSConfigAPIDeprecated.cpp b/source/config/WUPSConfigAPIDeprecated.cpp index 980c60d..3f3ff4c 100644 --- a/source/config/WUPSConfigAPIDeprecated.cpp +++ b/source/config/WUPSConfigAPIDeprecated.cpp @@ -31,7 +31,7 @@ int32_t WUPSConfig_GetName(void *handle, char *out_buf, int32_t out_len) { } auto config = WUPSConfigAPIBackend::Intern::GetConfigByHandle(WUPSConfigHandle(handle)); if (!config) { - DEBUG_FUNCTION_LINE_WARN("Failed to find WUPSConfig by handle %08X", handle); + DEBUG_FUNCTION_LINE_WARN("Failed to find WUPSConfig by handle %p", handle); return -1; } snprintf(out_buf, out_len, "%s", config->getName().c_str()); @@ -117,7 +117,7 @@ int32_t WUPSConfigCategory_GetName(void *handle, char *out_buf, int32_t out_len) auto *category = WUPSConfigAPIBackend::Intern::GetCategoryByHandle(WUPSConfigCategoryHandle(handle), true); if (!category) { - DEBUG_FUNCTION_LINE_WARN("Failed to find existing category for handle %08X", handle); + DEBUG_FUNCTION_LINE_WARN("Failed to find existing category for handle %p", handle); return -2; } snprintf(out_buf, out_len, "%s", category->getName().c_str()); @@ -176,7 +176,7 @@ int32_t WUPSConfigItem_SetDisplayName(void *handle, const char *displayName) { auto *config = WUPSConfigAPIBackend::Intern::GetItemByHandle(WUPSConfigItemHandle(handle)); if (!config) { - DEBUG_FUNCTION_LINE_ERR("Failed to find item for handle %08X", handle); + DEBUG_FUNCTION_LINE_ERR("Failed to find item for handle %p", handle); return -2; } config->setDisplayName(displayName); @@ -190,7 +190,7 @@ int32_t WUPSConfigItem_GetDisplayName(void *handle, char *out_buf, int32_t out_l } auto *config = WUPSConfigAPIBackend::Intern::GetItemByHandle(WUPSConfigItemHandle(handle)); if (!config) { - DEBUG_FUNCTION_LINE_ERR("Failed to find item for handle %08X", handle); + DEBUG_FUNCTION_LINE_ERR("Failed to find item for handle %p", handle); return -2; } snprintf(out_buf, out_len, "%s", config->getDisplayName().c_str()); @@ -205,7 +205,7 @@ int32_t WUPSConfigItem_SetConfigID(void *handle, const char *configId) { auto *config = WUPSConfigAPIBackend::Intern::GetItemByHandle(WUPSConfigItemHandle(handle)); if (!config) { - DEBUG_FUNCTION_LINE_ERR("Failed to find item for handle %08X", handle); + DEBUG_FUNCTION_LINE_ERR("Failed to find item for handle %p", handle); return -2; } config->setConfigId(configId); @@ -219,7 +219,7 @@ int32_t WUPSConfigItem_GetConfigID(void *handle, char *out_buf, int32_t out_len) } auto *config = WUPSConfigAPIBackend::Intern::GetItemByHandle(WUPSConfigItemHandle(handle)); if (!config) { - DEBUG_FUNCTION_LINE_ERR("Failed to find item for handle %08X", handle); + DEBUG_FUNCTION_LINE_ERR("Failed to find item for handle %p", handle); return -2; } snprintf(out_buf, out_len, "%s", config->getConfigId().c_str()); diff --git a/source/main.cpp b/source/main.cpp index 6e9b057..d6406a5 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -112,11 +112,11 @@ WUMS_INITIALIZE() { DrawUtils::endDraw(); }); DEBUG_FUNCTION_LINE_INFO("Safe Mode activated!"); - auto tobeIgnoredFilePath = getNonBaseAromaPluginFilenames(getPluginPath()); + auto toBeIgnoredFilePath = getNonBaseAromaPluginFilenames(getPluginPath()); WUPSBackendSettings::LoadSettings(); std::set inactivePlugins = WUPSBackendSettings::GetInactivePluginFilenames(); - inactivePlugins.insert(tobeIgnoredFilePath.begin(), tobeIgnoredFilePath.end()); + inactivePlugins.insert(toBeIgnoredFilePath.begin(), toBeIgnoredFilePath.end()); for (const auto &plugin : inactivePlugins) { DEBUG_FUNCTION_LINE_INFO("safemode: %s will be deactivated", plugin.c_str()); } @@ -172,7 +172,7 @@ WUMS_APPLICATION_STARTS() { // If an allocated rpl was not released properly (e.g. if something else calls OSDynload_Acquire without releasing it) memory get leaked. // Let's clean this up! for (const auto &addr : gAllocatedAddresses) { - DEBUG_FUNCTION_LINE_WARN("Memory allocated by OSDynload was not freed properly, let's clean it up! (%08X)", addr); + DEBUG_FUNCTION_LINE_WARN("Memory allocated by OSDynload was not freed properly, let's clean it up! (%p)", addr); free(addr); } gAllocatedAddresses.clear(); @@ -391,7 +391,7 @@ void CheckCleanupCallbackUsage(const std::vector &plugins) { while (t) { const auto address = reinterpret_cast(t->cleanupCallback); if (address != 0 && address >= startAddress && address <= endAddress) { - OSReport("[WARN] PluginBackend: Thread 0x%08X is using a function from plugin %s for the threadCleanupCallback\n", t, pluginName); + OSReport("[WARN] PluginBackend: Thread 0x%p is using a function from plugin %s for the threadCleanupCallback\n", t, pluginName); } t = t->activeLink.next; } diff --git a/source/plugin/ButtonComboManager.cpp b/source/plugin/ButtonComboManager.cpp index eb02483..e2134e6 100644 --- a/source/plugin/ButtonComboManager.cpp +++ b/source/plugin/ButtonComboManager.cpp @@ -497,7 +497,7 @@ WUPSButtonCombo_Error ButtonComboManager::RemoveButtonCombo(const WUPSButtonComb // Destructor removes it from the button combo module return WUPS_BUTTON_COMBO_ERROR_SUCCESS; } - DEBUG_FUNCTION_LINE_WARN("Could not remove button combo: not found! %08X", handle); + DEBUG_FUNCTION_LINE_WARN("Could not remove button combo: not found! %p", handle.handle); return WUPS_BUTTON_COMBO_ERROR_NOT_FOUND; } diff --git a/source/plugin/FunctionData.cpp b/source/plugin/FunctionData.cpp index 6aacd0b..b1bb932 100644 --- a/source/plugin/FunctionData.cpp +++ b/source/plugin/FunctionData.cpp @@ -70,7 +70,7 @@ bool FunctionData::AddPatch() { }}; if (FunctionPatcher_AddFunctionPatch(&functionData, &mHandle, nullptr) != FUNCTION_PATCHER_RESULT_SUCCESS) { - DEBUG_FUNCTION_LINE_ERR("Failed to add patch for function (\"%s\" PA:%08X VA:%08X)", this->mName.c_str(), this->mPAddress, this->mVAddress); + DEBUG_FUNCTION_LINE_ERR("Failed to add patch for function (\"%s\" PA:%p VA:%p)", this->mName.c_str(), this->mPAddress, this->mVAddress); return false; } } else { diff --git a/source/plugin/PluginLinkInformationFactory.cpp b/source/plugin/PluginLinkInformationFactory.cpp index 8245c48..2fae905 100644 --- a/source/plugin/PluginLinkInformationFactory.cpp +++ b/source/plugin/PluginLinkInformationFactory.cpp @@ -162,7 +162,7 @@ PluginLinkInformationFactory::load(const PluginData &pluginData) { // Lets create a shared memory pool for both of them HeapMemoryFixedSizePool textAndTrampDataPool({text_size, trampDataSize}); if (!textAndTrampDataPool) { - DEBUG_FUNCTION_LINE_ERR("Failed to alloc memory for the .text section (%d bytes) and tramp data", text_size, trampDataSize); + DEBUG_FUNCTION_LINE_ERR("Failed to alloc memory for the .text section (%d bytes) and tramp data (%d bytes)", text_size, trampDataSize); return std::nullopt; } // Segment 0 is the .text data @@ -235,7 +235,7 @@ PluginLinkInformationFactory::load(const PluginData &pluginData) { DEBUG_FUNCTION_LINE_VERBOSE("memset section %s %08X to 0 (%d bytes)", psec->get_name().c_str(), destination, sectionSize); memset((void *) destination, 0, sectionSize); } else if (psec->get_type() == SHT_PROGBITS) { - DEBUG_FUNCTION_LINE_VERBOSE("Copy section %s %08X -> %08X (%d bytes)", psec->get_name().c_str(), p, destination, sectionSize); + DEBUG_FUNCTION_LINE_VERBOSE("Copy section %s %p -> %08X (%d bytes)", psec->get_name().c_str(), p, destination, sectionSize); memcpy((void *) destination, p, sectionSize); } pluginInfo.addSectionInfo(SectionInfo(psec->get_name(), destination, sectionSize)); @@ -252,7 +252,7 @@ PluginLinkInformationFactory::load(const PluginData &pluginData) { for (uint32_t i = 0; i < sec_num; ++i) { section *psec = reader.sections[i]; if (psec && (psec->get_type() == SHT_PROGBITS || psec->get_type() == SHT_NOBITS) && (psec->get_flags() & SHF_ALLOC)) { - DEBUG_FUNCTION_LINE_VERBOSE("Linking (%d)... %s at %08X", i, psec->get_name().c_str(), destinations[psec->get_index()]); + DEBUG_FUNCTION_LINE_VERBOSE("Linking (%d)... %s at %p", i, psec->get_name().c_str(), destinations[psec->get_index()]); if (!linkSection(reader, psec->get_index(), (uint32_t) destinations[psec->get_index()], (uint32_t) text_data.data(), (uint32_t) data_data.data(), trampolineList)) { DEBUG_FUNCTION_LINE_ERR("linkSection failed"); @@ -278,7 +278,7 @@ PluginLinkInformationFactory::load(const PluginData &pluginData) { if (entries != nullptr) { for (size_t j = 0; j < entries_count; j++) { wups_loader_hook_t *hook = &entries[j]; - DEBUG_FUNCTION_LINE_VERBOSE("Saving hook of plugin Type: %08X, target: %08X", hook->type, (void *) hook->target); + DEBUG_FUNCTION_LINE_VERBOSE("Saving hook of plugin Type: %08X, target: %p", hook->type, (void *) hook->target); pluginInfo.addHookData(HookData((void *) hook->target, hook->type)); } } @@ -291,7 +291,7 @@ PluginLinkInformationFactory::load(const PluginData &pluginData) { if (entries != nullptr) { for (size_t j = 0; j < entries_count; j++) { wups_loader_entry_t *cur_function = &entries[j]; - DEBUG_FUNCTION_LINE_VERBOSE("Saving function \"%s\" of plugin . PA:%08X VA:%08X Library: %08X, target: %08X, call_addr: %08X", + DEBUG_FUNCTION_LINE_VERBOSE("Saving function \"%s\" of plugin . PA:%p VA:%p Library: %08X, target: %p, call_addr: %p", cur_function->_function.name /*,mPluginData->getPluginInformation()->getName().c_str()*/, cur_function->_function.physical_address, cur_function->_function.virtual_address, cur_function->_function.library, cur_function->_function.target, (void *) cur_function->_function.call_addr); @@ -407,7 +407,7 @@ bool PluginLinkInformationFactory::addImportRelocationData(PluginLinkInformation uint32_t section_index = psec->get_info(); if (!infoMap.contains(sym_section_index)) { - DEBUG_FUNCTION_LINE_ERR("Relocation is referencing a unknown section. %d destination: %08X sym_name %s", section_index, destinations[section_index], sym_name.c_str()); + DEBUG_FUNCTION_LINE_ERR("Relocation is referencing a unknown section. %d destination: %p sym_name %s", section_index, destinations[section_index], sym_name.c_str()); return false; } diff --git a/source/utils/HeapMemoryFixedSize.cpp b/source/utils/HeapMemoryFixedSize.cpp index ef900a4..478f3d9 100644 --- a/source/utils/HeapMemoryFixedSize.cpp +++ b/source/utils/HeapMemoryFixedSize.cpp @@ -63,7 +63,7 @@ HeapMemoryFixedSizePool::operator bool() const { HeapMemoryFixedSizePool::MemorySegmentInfo HeapMemoryFixedSizePool::operator[](const int idx) const { if (idx < 0 || idx >= static_cast(mSegmentInfos.size())) { - DEBUG_FUNCTION_LINE_ERR("Out of bounce access (tried to access index %d; size is", idx, mSegmentInfos.size()); + DEBUG_FUNCTION_LINE_ERR("Out of bounce access (tried to access index %d; size is %d", idx, mSegmentInfos.size()); } return mSegmentInfos[idx]; } \ No newline at end of file diff --git a/source/utils/config/ConfigUtils.cpp b/source/utils/config/ConfigUtils.cpp index 7e764fc..19eb871 100644 --- a/source/utils/config/ConfigUtils.cpp +++ b/source/utils/config/ConfigUtils.cpp @@ -100,7 +100,7 @@ void ConfigUtils::displayMenu() { WUPSConfigAPIStatus callbackResult = configData->CallMenuOpenedCallback(configHandleOpt.value()); config = WUPSConfigAPIBackend::Intern::PopConfigByHandle(configHandleOpt.value()); if (!config) { - DEBUG_FUNCTION_LINE_ERR("Failed to get config for handle: %08X", configHandleOpt.value().handle); + DEBUG_FUNCTION_LINE_ERR("Failed to get config for handle: %p", configHandleOpt.value().handle); } else if (callbackResult != WUPSCONFIG_API_RESULT_SUCCESS) { DEBUG_FUNCTION_LINE_ERR("Callback failed for %s: %s", info.name.c_str(), WUPSConfigAPI_GetStatusStr(callbackResult)); config.reset(); @@ -122,7 +122,7 @@ void ConfigUtils::displayMenu() { } config = WUPSConfigAPIBackend::Intern::PopConfigByHandle(WUPSConfigHandle(cur_config_handle)); if (!config) { - DEBUG_FUNCTION_LINE_ERR("Failed to find config for handle: %08X", cur_config_handle); + DEBUG_FUNCTION_LINE_ERR("Failed to find config for handle: %p", cur_config_handle); } break; } diff --git a/source/utils/logger.h b/source/utils/logger.h index 4bf7101..b9da9fa 100644 --- a/source/utils/logger.h +++ b/source/utils/logger.h @@ -1,5 +1,6 @@ #pragma once + #include #include #include diff --git a/source/utils/storage/StorageUtils.cpp b/source/utils/storage/StorageUtils.cpp index ba84abb..8cca49c 100644 --- a/source/utils/storage/StorageUtils.cpp +++ b/source/utils/storage/StorageUtils.cpp @@ -404,7 +404,7 @@ namespace StorageUtils { // TODO: handle write error? if (!remove_first_if(gStorage, [&root](auto &cur) { return cur.getHandle() == reinterpret_cast(root); })) { - DEBUG_FUNCTION_LINE_WARN("Failed to close storage: Not opened (\"%08X\")", root); + DEBUG_FUNCTION_LINE_WARN("Failed to close storage: Not opened (\"%pX\")", root); return WUPS_STORAGE_ERROR_NOT_FOUND; } return res; diff --git a/source/utils/utils.cpp b/source/utils/utils.cpp index 4b6b0f5..8b37a1d 100644 --- a/source/utils/utils.cpp +++ b/source/utils/utils.cpp @@ -61,7 +61,7 @@ void dumpHex(const void *data, const size_t size) { char ascii[17]; size_t i, j; ascii[16] = '\0'; - DEBUG_FUNCTION_LINE("0x%08X (0x0000): ", data); + DEBUG_FUNCTION_LINE("0x%p (0x0000): ", data); for (i = 0; i < size; ++i) { WHBLogWritef("%02X ", ((unsigned char *) data)[i]); if (((unsigned char *) data)[i] >= ' ' && ((unsigned char *) data)[i] <= '~') {