From 2e44af129e89898ccfdcd6bf084d8be92938b6a7 Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 21 Jan 2022 19:02:31 +0100 Subject: [PATCH] Properly deinit logging, call missing __fini(), return instead of calling _Exit(0); --- Makefile | 2 +- source/main.cpp | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 2af9690..b0f5313 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ INCLUDES := source #------------------------------------------------------------------------------- # options for code generation #------------------------------------------------------------------------------- -CFLAGS := -g -Wall -O3 -ffunction-sections -fno-exceptions -fno-rtti\ +CFLAGS := -g -Wall -O2 -ffunction-sections -fno-exceptions -fno-rtti\ $(MACHDEP) CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ diff --git a/source/main.cpp b/source/main.cpp index 27715a3..28d51d1 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -86,11 +86,19 @@ bool writeFileContent(const std::string &path, const std::string &content) { return false; } +extern "C" void __fini(); + +#ifdef DEBUG +bool module_log = false; +bool udp_log = false; +bool cafe_log = false; +#endif // DEBUG + int main(int argc, char **argv) { #ifdef DEBUG - if (!WHBLogModuleInit()) { - WHBLogCafeInit(); - WHBLogUdpInit(); + if (!(module_log = WHBLogModuleInit())) { + cafe_log = WHBLogCafeInit(); + udp_log = WHBLogUdpInit(); } #endif // DEBUG @@ -230,7 +238,12 @@ int main(int argc, char **argv) { } ProcUIShutdown(); - _Exit(0); +#ifdef DEBUG + if (module_log) { WHBLogModuleDeinit(); } + if (udp_log) { WHBLogUdpDeinit(); } + if (cafe_log) { WHBLogCafeDeinit(); } +#endif // DEBUG + __fini(); return 0; }