From bd2f5461abe8dee27e9fdbee228b7c4ccff29c59 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 10 Jan 2021 13:15:10 +0100 Subject: [PATCH] Check for actual ERROR_NONE instead of 0 --- source/PluginUtils.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/source/PluginUtils.cpp b/source/PluginUtils.cpp index ab9773b..dd0017f 100644 --- a/source/PluginUtils.cpp +++ b/source/PluginUtils.cpp @@ -20,6 +20,12 @@ #include "wups_backend/PluginUtils.h" #include "imports.h" +#define ERROR_NONE 0 +#define ERROR_INVALID_SIZE 0xFFFFFFFF +#define ERROR_INVALID_ARG 0xFFFFFFFE +#define ERROR_FAILED_ALLOC 0xFFFFFFFD +#define ERROR_FILE_NOT_FOUND 0xFFFFFFFC + std::optional PluginUtils::getMetaInformationForBuffer(char *buffer, size_t size) { plugin_information info; memset(&info, 0, sizeof(info)); @@ -42,7 +48,7 @@ std::optional PluginUtils::getMetaInformationForBuffer(ch std::optional PluginUtils::getMetaInformationForPath(const std::string &path) { plugin_information info; memset(&info, 0, sizeof(info)); - if (WUPSGetPluginMetaInformationByPath(&info, path.c_str()) != 0) { + if (WUPSGetPluginMetaInformationByPath(&info, path.c_str()) != ERROR_NONE) { // DEBUG_FUNCTION_LINE("Failed to load meta infos for %s\n", path.c_str()); return std::nullopt; } @@ -64,12 +70,12 @@ std::optional PluginUtils::getPluginForPath(const std::string & } plugin_data_handle dataHandle; - if (WUPSLoadPluginAsDataByPath(&dataHandle, path.c_str()) != 0) { + if (WUPSLoadPluginAsDataByPath(&dataHandle, path.c_str()) != ERROR_NONE) { // DEBUG_FUNCTION_LINE("Failed to load data"); return std::nullopt; } - return PluginContainer(PluginData(dataHandle), metaInfoOpt.value(), 0); + return PluginContainer(PluginData(dataHandle), metaInfoOpt.value(), ERROR_NONE); } std::optional PluginUtils::getPluginForBuffer(char *buffer, size_t size) { @@ -79,7 +85,7 @@ std::optional PluginUtils::getPluginForBuffer(char *buffer, siz } plugin_data_handle dataHandle; - if (WUPSLoadPluginAsDataByBuffer(&dataHandle, buffer, size) != 0) { + if (WUPSLoadPluginAsDataByBuffer(&dataHandle, buffer, size) != ERROR_NONE) { // DEBUG_FUNCTION_LINE("Failed to load data"); return std::nullopt; } @@ -95,7 +101,7 @@ std::vector PluginUtils::getLoadedPlugins(uint32_t maxSize) { } uint32_t realSize = 0; - if (WUPSGetLoadedPlugins(handles, maxSize, &realSize) != 0) { + if (WUPSGetLoadedPlugins(handles, maxSize, &realSize) != ERROR_NONE) { free(handles); // DEBUG_FUNCTION_LINE("Failed"); return result; @@ -125,7 +131,7 @@ std::vector PluginUtils::getLoadedPlugins(uint32_t maxSize) { free(dataHandles); return result; } - if (WUPSGetMetaInformation(handles, information, realSize) != 0) { + if (WUPSGetMetaInformation(handles, information, realSize) != ERROR_NONE) { free(handles); free(dataHandles); free(information);