From c82f178943f8cd39b7727eb3e381725461355e18 Mon Sep 17 00:00:00 2001 From: Maschell Date: Wed, 2 Feb 2022 19:12:52 +0100 Subject: [PATCH] Format the code via clang-format (#1) * Format the code via clang-format --- .clang-format | 66 ++++++++++ .github/workflows/ci.yml | 8 ++ .github/workflows/pr.yml | 8 ++ README.md | 3 + source/ElfUtils.cpp | 36 ++--- source/ElfUtils.h | 6 +- source/common/dynamic_linking_defines.h | 4 +- source/common/module_defines.h | 4 +- source/common/relocation_defines.h | 6 +- source/elfio/elf_types.hpp | 1 + source/elfio/elfio.hpp | 1 + source/elfio/elfio_dump.hpp | 1 + source/elfio/elfio_dynamic.hpp | 1 + source/elfio/elfio_header.hpp | 1 + source/elfio/elfio_note.hpp | 1 + source/elfio/elfio_relocation.hpp | 1 + source/elfio/elfio_section.hpp | 1 + source/elfio/elfio_segment.hpp | 1 + source/elfio/elfio_strings.hpp | 1 + source/elfio/elfio_symbols.hpp | 1 + source/elfio/elfio_utils.hpp | 1 + source/fs/CFile.cpp | 18 ++- source/fs/CFile.hpp | 6 +- source/fs/DirList.cpp | 4 +- source/fs/DirList.h | 3 +- source/kernel.cpp | 37 +++--- source/kernel.h | 4 +- source/main.cpp | 60 +++++---- source/module/ImportRPLInformation.h | 7 +- source/module/ModuleData.h | 6 +- source/module/ModuleDataFactory.cpp | 10 +- source/module/ModuleDataFactory.h | 8 +- source/module/RelocationData.h | 6 +- source/utils/DrawUtils.cpp | 168 ++++++++++-------------- source/utils/DrawUtils.h | 29 ++-- source/utils/StringTools.cpp | 19 ++- source/utils/StringTools.h | 3 +- source/utils/logger.c | 8 +- source/utils/logger.h | 13 +- 39 files changed, 326 insertions(+), 236 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..92399ef --- /dev/null +++ b/.clang-format @@ -0,0 +1,66 @@ +# Generated from CLion C/C++ Code Style settings +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: None +AlignOperands: Align +AllowAllArgumentsOnNextLine: false +AllowAllConstructorInitializersOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Always +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Always +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterReturnType: None +AlwaysBreakTemplateDeclarations: Yes +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: true +BreakBeforeBinaryOperators: None +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +ColumnLimit: 0 +CompactNamespaces: false +ContinuationIndentWidth: 8 +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 4 +KeepEmptyLinesAtTheStartOfBlocks: true +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: All +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PointerAlignment: Right +ReflowComments: false +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 0 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInContainerLiterals: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +TabWidth: 4 +UseTab: Never diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a580b7e..10ee17e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,8 +6,16 @@ on: - main jobs: + clang-format: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: clang-format + run: | + docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source build-binary: runs-on: ubuntu-18.04 + needs: clang-format steps: - uses: actions/checkout@v2 - name: build binary diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f907f7e..7464b72 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -3,8 +3,16 @@ name: CI-PR on: [pull_request] jobs: + clang-format: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: clang-format + run: | + docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source build-binary: runs-on: ubuntu-18.04 + needs: clang-format steps: - uses: actions/checkout@v2 - name: build binary diff --git a/README.md b/README.md index 9b7668d..48e16a6 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,9 @@ docker run -it --rm -v ${PWD}:/project environmentloader-builder make docker run -it --rm -v ${PWD}:/project environmentloader-builder make clean ``` +## Format the code via docker + +`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source -i` ## Credits - maschell diff --git a/source/ElfUtils.cpp b/source/ElfUtils.cpp index a7b6945..bb5795a 100644 --- a/source/ElfUtils.cpp +++ b/source/ElfUtils.cpp @@ -1,15 +1,15 @@ -#include +#include "utils/logger.h" +#include #include +#include +#include #include -#include #include #include -#include -#include -#include "utils/logger.h" +#include -#include "elfio/elfio.hpp" #include "ElfUtils.h" +#include "elfio/elfio.hpp" int32_t LoadFileToMem(const char *relativefilepath, char **fileOut, uint32_t *sizeOut) { char path[256]; @@ -33,7 +33,7 @@ int32_t LoadFileToMem(const char *relativefilepath, char **fileOut, uint32_t *si goto exit; } - exit: +exit: WHBUnmountSdCard(); return result; } @@ -111,13 +111,13 @@ uint32_t load_loader_elf(unsigned char *baseAddress, char *elf_data, uint32_t fi bool ElfUtils::doRelocation(std::vector> &relocData, relocation_trampolin_entry_t *tramp_data, uint32_t tramp_length) { - for (auto const &curReloc: relocData) { + for (auto const &curReloc : relocData) { std::string functionName = curReloc->getName(); std::string rplName = curReloc->getImportRPLInformation()->getName(); int32_t isData = curReloc->getImportRPLInformation()->isData(); OSDynLoad_Module rplHandle = nullptr; - - + + auto err = OSDynLoad_IsModuleLoaded(rplName.c_str(), &rplHandle); if (err != OS_DYNLOAD_OK || rplHandle == 0) { // only acquire if not already loaded. @@ -234,19 +234,19 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des } if (freeSlot == nullptr) { DEBUG_FUNCTION_LINE("***24-bit relative branch cannot hit target. Trampolin data list is full\n"); - DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X\n", value, target, (target - (uint32_t) &(freeSlot->trampolin[0]))); + DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X\n", value, target, (target - (uint32_t) & (freeSlot->trampolin[0]))); return false; } - if (target - (uint32_t) &(freeSlot->trampolin[0]) > 0x1FFFFFC) { + if (target - (uint32_t) & (freeSlot->trampolin[0]) > 0x1FFFFFC) { DEBUG_FUNCTION_LINE("**Cannot link 24-bit jump (too far to tramp buffer)."); - DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X\n", value, target, (target - (uint32_t) &(freeSlot->trampolin[0]))); + DEBUG_FUNCTION_LINE("***value %08X - target %08X = distance %08X\n", value, target, (target - (uint32_t) & (freeSlot->trampolin[0]))); return false; } - freeSlot->trampolin[0] = 0x3D600000 | ((((uint32_t) value) >> 16) & 0x0000FFFF); // lis r11, real_addr@h - freeSlot->trampolin[1] = 0x616B0000 | (((uint32_t) value) & 0x0000ffff); // ori r11, r11, real_addr@l - freeSlot->trampolin[2] = 0x7D6903A6; // mtctr r11 - freeSlot->trampolin[3] = 0x4E800420; // bctr + freeSlot->trampolin[0] = 0x3D600000 | ((((uint32_t) value) >> 16) & 0x0000FFFF);// lis r11, real_addr@h + freeSlot->trampolin[1] = 0x616B0000 | (((uint32_t) value) & 0x0000ffff); // ori r11, r11, real_addr@l + freeSlot->trampolin[2] = 0x7D6903A6; // mtctr r11 + freeSlot->trampolin[3] = 0x4E800420; // bctr DCFlushRange((void *) freeSlot->trampolin, sizeof(freeSlot->trampolin)); ICInvalidateRange((unsigned char *) freeSlot->trampolin, sizeof(freeSlot->trampolin)); @@ -256,7 +256,7 @@ bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t des // Relocations for the imports may be overridden freeSlot->status = RELOC_TRAMP_IMPORT_DONE; } - auto symbolValue = (uint32_t) &(freeSlot->trampolin[0]); + auto symbolValue = (uint32_t) & (freeSlot->trampolin[0]); value = symbolValue + addend; distance = static_cast(value) - static_cast(target); } diff --git a/source/ElfUtils.h b/source/ElfUtils.h index 98ff6d8..63b0ab8 100644 --- a/source/ElfUtils.h +++ b/source/ElfUtils.h @@ -1,11 +1,11 @@ #pragma once +#include "common/relocation_defines.h" +#include "module/RelocationData.h" #include #include -#include "common/relocation_defines.h" #include #include -#include "module/RelocationData.h" #ifdef __cplusplus @@ -17,6 +17,7 @@ int32_t LoadFileToMem(const char *relativefilepath, char **fileOut, uint32_t *si uint32_t load_loader_elf_from_sd(unsigned char *baseAddress, const char *relativePath); uint32_t load_loader_elf(unsigned char *baseAddress, char *elf_data, uint32_t fileSize); +// clang-format off #define R_PPC_NONE 0 #define R_PPC_ADDR32 1 #define R_PPC_ADDR16_LO 4 @@ -44,6 +45,7 @@ uint32_t load_loader_elf(unsigned char *baseAddress, char *elf_data, uint32_t fi #define PPC_LOW24 0x03FFFFFC #define PPC_LOW14 0x0020FFFC #define PPC_HALF16 0xFFFF +// clang-format on #ifdef __cplusplus } diff --git a/source/common/dynamic_linking_defines.h b/source/common/dynamic_linking_defines.h index 7f5102e..9ef300f 100644 --- a/source/common/dynamic_linking_defines.h +++ b/source/common/dynamic_linking_defines.h @@ -17,13 +17,14 @@ #pragma once -#include #include +#include #ifdef __cplusplus extern "C" { #endif +// clang-format off #define DYN_LINK_FUNCTION_NAME_LENGTH 351 #define DYN_LINK_IMPORT_NAME_LENGTH 50 @@ -31,6 +32,7 @@ extern "C" { #define DYN_LINK_IMPORT_LIST_LENGTH 50 #define DYN_LINK_TRAMPOLIN_LIST_LENGTH DYN_LINK_FUNCTION_LIST_LENGTH +// clang-format on typedef struct _dyn_linking_function_t { char functionName[DYN_LINK_FUNCTION_NAME_LENGTH + 1]; diff --git a/source/common/module_defines.h b/source/common/module_defines.h index 2795c91..e7b684e 100644 --- a/source/common/module_defines.h +++ b/source/common/module_defines.h @@ -17,10 +17,10 @@ #pragma once -#include -#include #include "dynamic_linking_defines.h" #include "relocation_defines.h" +#include +#include #ifdef __cplusplus extern "C" { diff --git a/source/common/relocation_defines.h b/source/common/relocation_defines.h index 73c1256..f098f4c 100644 --- a/source/common/relocation_defines.h +++ b/source/common/relocation_defines.h @@ -19,14 +19,15 @@ #include -typedef enum RelocationTrampolinStatus{ +// clang-format off +typedef enum RelocationTrampolinStatus { RELOC_TRAMP_FREE = 0, RELOC_TRAMP_FIXED = 1, RELOC_TRAMP_IMPORT_IN_PROGRESS = 2, RELOC_TRAMP_IMPORT_DONE = 3, } RelocationTrampolinStatus; -typedef enum RelocationType{ +typedef enum RelocationType { RELOC_TYPE_FIXED = 0, RELOC_TYPE_IMPORT = 1 } RelocationType; @@ -35,3 +36,4 @@ typedef struct relocation_trampolin_entry_t { uint32_t trampolin[4]; RelocationTrampolinStatus status; } relocation_trampolin_entry_t; +// clang-format on \ No newline at end of file diff --git a/source/elfio/elf_types.hpp b/source/elfio/elf_types.hpp index 63d025a..9a20040 100644 --- a/source/elfio/elf_types.hpp +++ b/source/elfio/elf_types.hpp @@ -1,3 +1,4 @@ +// clang-format off /* Copyright (C) 2001-2015 by Serge Lamikhov-Center diff --git a/source/elfio/elfio.hpp b/source/elfio/elfio.hpp index 2a0174e..1d691b1 100644 --- a/source/elfio/elfio.hpp +++ b/source/elfio/elfio.hpp @@ -1,3 +1,4 @@ +// clang-format off /* Copyright (C) 2001-2015 by Serge Lamikhov-Center diff --git a/source/elfio/elfio_dump.hpp b/source/elfio/elfio_dump.hpp index 4ace665..015cff2 100644 --- a/source/elfio/elfio_dump.hpp +++ b/source/elfio/elfio_dump.hpp @@ -1,3 +1,4 @@ +// clang-format off /* Copyright (C) 2001-2015 by Serge Lamikhov-Center diff --git a/source/elfio/elfio_dynamic.hpp b/source/elfio/elfio_dynamic.hpp index 42f2680..36de384 100644 --- a/source/elfio/elfio_dynamic.hpp +++ b/source/elfio/elfio_dynamic.hpp @@ -1,3 +1,4 @@ +// clang-format off /* Copyright (C) 2001-2015 by Serge Lamikhov-Center diff --git a/source/elfio/elfio_header.hpp b/source/elfio/elfio_header.hpp index 6f8da02..e7b9a24 100644 --- a/source/elfio/elfio_header.hpp +++ b/source/elfio/elfio_header.hpp @@ -1,3 +1,4 @@ +// clang-format off /* Copyright (C) 2001-2015 by Serge Lamikhov-Center diff --git a/source/elfio/elfio_note.hpp b/source/elfio/elfio_note.hpp index 8619c73..fbfc51c 100644 --- a/source/elfio/elfio_note.hpp +++ b/source/elfio/elfio_note.hpp @@ -1,3 +1,4 @@ +// clang-format off /* Copyright (C) 2001-2015 by Serge Lamikhov-Center diff --git a/source/elfio/elfio_relocation.hpp b/source/elfio/elfio_relocation.hpp index 4a3fab0..641031a 100644 --- a/source/elfio/elfio_relocation.hpp +++ b/source/elfio/elfio_relocation.hpp @@ -1,3 +1,4 @@ +// clang-format off /* Copyright (C) 2001-2015 by Serge Lamikhov-Center diff --git a/source/elfio/elfio_section.hpp b/source/elfio/elfio_section.hpp index ed3b908..52d3102 100644 --- a/source/elfio/elfio_section.hpp +++ b/source/elfio/elfio_section.hpp @@ -1,3 +1,4 @@ +// clang-format off /* Copyright (C) 2001-2015 by Serge Lamikhov-Center diff --git a/source/elfio/elfio_segment.hpp b/source/elfio/elfio_segment.hpp index e906f3e..fa370fb 100644 --- a/source/elfio/elfio_segment.hpp +++ b/source/elfio/elfio_segment.hpp @@ -1,3 +1,4 @@ +// clang-format off /* Copyright (C) 2001-2015 by Serge Lamikhov-Center diff --git a/source/elfio/elfio_strings.hpp b/source/elfio/elfio_strings.hpp index 552f000..5fc9bb1 100644 --- a/source/elfio/elfio_strings.hpp +++ b/source/elfio/elfio_strings.hpp @@ -1,3 +1,4 @@ +// clang-format off /* Copyright (C) 2001-2015 by Serge Lamikhov-Center diff --git a/source/elfio/elfio_symbols.hpp b/source/elfio/elfio_symbols.hpp index d18756a..6205bd2 100644 --- a/source/elfio/elfio_symbols.hpp +++ b/source/elfio/elfio_symbols.hpp @@ -1,3 +1,4 @@ +// clang-format off /* Copyright (C) 2001-2015 by Serge Lamikhov-Center diff --git a/source/elfio/elfio_utils.hpp b/source/elfio/elfio_utils.hpp index 2baf5a7..e567d41 100644 --- a/source/elfio/elfio_utils.hpp +++ b/source/elfio/elfio_utils.hpp @@ -1,3 +1,4 @@ +// clang-format off /* Copyright (C) 2001-2015 by Serge Lamikhov-Center diff --git a/source/fs/CFile.cpp b/source/fs/CFile.cpp index c8e78d2..a5a141e 100644 --- a/source/fs/CFile.cpp +++ b/source/fs/CFile.cpp @@ -1,9 +1,9 @@ -#include -#include -#include -#include #include +#include +#include +#include +#include CFile::CFile() { iFd = -1; @@ -35,16 +35,16 @@ int32_t CFile::open(const std::string &filepath, eOpenTypes mode) { switch (mode) { default: - case ReadOnly: // file must exist + case ReadOnly:// file must exist openMode = O_RDONLY; break; - case WriteOnly: // file will be created / zerod + case WriteOnly:// file will be created / zerod openMode = O_TRUNC | O_CREAT | O_WRONLY; break; - case ReadWrite: // file must exist + case ReadWrite:// file must exist openMode = O_RDWR; break; - case Append: // append to file, file will be created if missing. write only + case Append:// append to file, file will be created if missing. write only openMode = O_CREAT | O_APPEND | O_WRONLY; break; } @@ -171,5 +171,3 @@ int32_t CFile::fwrite(const char *format, ...) { return result; } - - diff --git a/source/fs/CFile.hpp b/source/fs/CFile.hpp index 6c0421b..2bc9dfc 100644 --- a/source/fs/CFile.hpp +++ b/source/fs/CFile.hpp @@ -1,10 +1,10 @@ #ifndef CFILE_HPP_ #define CFILE_HPP_ -#include -#include -#include #include +#include +#include +#include #include #include diff --git a/source/fs/DirList.cpp b/source/fs/DirList.cpp index ab2fea4..a18f048 100644 --- a/source/fs/DirList.cpp +++ b/source/fs/DirList.cpp @@ -24,14 +24,14 @@ * DirList Class * for WiiXplorer 2010 ***************************************************************************/ +#include #include #include #include #include #include -#include -#include #include +#include #include #include diff --git a/source/fs/DirList.h b/source/fs/DirList.h index 08b3fbc..749d9de 100644 --- a/source/fs/DirList.h +++ b/source/fs/DirList.h @@ -27,8 +27,8 @@ #ifndef ___DIRLIST_H_ #define ___DIRLIST_H_ -#include #include +#include #include typedef struct { @@ -97,6 +97,7 @@ public: Dirs = 0x02, CheckSubfolders = 0x08, }; + protected: // Internal parser BOOL InternalLoadPath(std::string &path); diff --git a/source/kernel.cpp b/source/kernel.cpp index 014a666..08aa31b 100644 --- a/source/kernel.cpp +++ b/source/kernel.cpp @@ -33,23 +33,22 @@ void KernelWriteU32(uint32_t addr, uint32_t value) { } /* Write a 32-bit word with kernel permissions */ -void __attribute__ ((noinline)) kern_write(void *addr, uint32_t value) { - asm volatile ( - "li 3,1\n" - "li 4,0\n" - "mr 5,%1\n" - "li 6,0\n" - "li 7,0\n" - "lis 8,1\n" - "mr 9,%0\n" - "mr %1,1\n" - "li 0,0x3500\n" - "sc\n" - "nop\n" - "mr 1,%1\n" - : - : "r"(addr), "r"(value) - : "memory", "ctr", "lr", "0", "3", "4", "5", "6", "7", "8", "9", "10", - "11", "12" - ); +void __attribute__((noinline)) kern_write(void *addr, uint32_t value) { + asm volatile( + "li 3,1\n" + "li 4,0\n" + "mr 5,%1\n" + "li 6,0\n" + "li 7,0\n" + "lis 8,1\n" + "mr 9,%0\n" + "mr %1,1\n" + "li 0,0x3500\n" + "sc\n" + "nop\n" + "mr 1,%1\n" + : + : "r"(addr), "r"(value) + : "memory", "ctr", "lr", "0", "3", "4", "5", "6", "7", "8", "9", "10", + "11", "12"); } diff --git a/source/kernel.h b/source/kernel.h index 484554f..860fe88 100644 --- a/source/kernel.h +++ b/source/kernel.h @@ -2,6 +2,7 @@ #include +// clang-format off #define ADDRESS_main_entry_hook 0x0101C56C #define KERN_SYSCALL_TBL_1 0xFFE84C70 // unknown @@ -9,9 +10,10 @@ #define KERN_SYSCALL_TBL_3 0xFFE85470 // works with loader #define KERN_SYSCALL_TBL_4 0xFFEAAA60 // works with home menu #define KERN_SYSCALL_TBL_5 0xFFEAAE60 // works with browser (previously KERN_SYSCALL_TBL) +// clang-format on void RevertMainHook(); void KernelWriteU32(uint32_t addr, uint32_t value); -void __attribute__ ((noinline)) kern_write(void *addr, uint32_t value); +void __attribute__((noinline)) kern_write(void *addr, uint32_t value); diff --git a/source/main.cpp b/source/main.cpp index 606a036..a8948d3 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,41 +1,42 @@ #include -#include +#include "utils/StringTools.h" +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "utils/StringTools.h" +#include -#include "fs/DirList.h" -#include "module/ModuleDataFactory.h" #include "ElfUtils.h" -#include "kernel.h" #include "common/module_defines.h" +#include "fs/DirList.h" +#include "kernel.h" +#include "module/ModuleDataFactory.h" #include "utils/DrawUtils.h" +// clang-format off #define MEMORY_REGION_START 0x00A00000 #define MEMORY_REGION_SIZE 0x00600000 #define MEMORY_REGION_END (MEMORY_REGION_START + MEMORY_REGION_SIZE) #define AUTOBOOT_CONFIG_PATH "fs:/vol/external01/wiiu/environments/default.cfg" +// clang-format on bool CheckRunning() { switch (ProcUIProcessMessages(true)) { @@ -109,7 +110,7 @@ int main(int argc, char **argv) { auto handle = IOS_Open("/dev/mcp", IOS_OPEN_READ); if (handle >= 0) { - int in = 0xF9; // IPC_CUSTOM_COPY_ENVIRONMENT_PATH + int in = 0xF9;// IPC_CUSTOM_COPY_ENVIRONMENT_PATH if (IOS_Ioctl(handle, 100, &in, sizeof(in), environmentPath, sizeof(environmentPath)) == IOS_ERROR_OK) { DEBUG_FUNCTION_LINE("Boot into %s", environmentPath); } @@ -200,7 +201,9 @@ int main(int argc, char **argv) { DEBUG_FUNCTION_LINE("Calling entrypoint @%08X", moduleData.value()->getEntrypoint()); char *arr[1]; arr[0] = (char *) environment_path.c_str(); - ((int (*)(int, char **)) moduleData.value()->getEntrypoint())(1, arr); + // clang-format off + ((int(*)(int, char **)) moduleData.value()->getEntrypoint())(1, arr); + // clang-format on DEBUG_FUNCTION_LINE("Back from module"); } } else { @@ -211,7 +214,9 @@ int main(int argc, char **argv) { if ((i + 1) < argc) { i++; DEBUG_FUNCTION_LINE("call forceDefaultTitleIDToWiiUMenu"); - auto forceDefaultTitleIDToWiiUMenu = (void (*)()) argv[i]; + // clang-format off + auto forceDefaultTitleIDToWiiUMenu = (void(*)()) argv[i]; + // clang-format on forceDefaultTitleIDToWiiUMenu(); } } @@ -233,6 +238,7 @@ int main(int argc, char **argv) { return 0; } +// clang-format off #define COLOR_WHITE Color(0xffffffff) #define COLOR_BLACK Color(0, 0, 0, 255) #define COLOR_RED Color(237, 28, 36, 255) @@ -242,7 +248,7 @@ int main(int argc, char **argv) { #define COLOR_AUTOBOOT Color(0xaeea00ff) #define COLOR_BORDER Color(204, 204, 204, 255) #define COLOR_BORDER_HIGHLIGHTED Color(0x3478e4ff) - +// clang-format on std::string EnvironmentSelectionScreen(const std::map &payloads, int32_t autobootIndex) { OSScreenInit(); @@ -301,7 +307,7 @@ std::string EnvironmentSelectionScreen(const std::map uint32_t index = 8 + 24 + 8 + 4; uint32_t i = 0; if (!payloads.empty()) { - for (auto const&[key, val]: payloads) { + for (auto const &[key, val] : payloads) { if (i == selected) { DrawUtils::drawRect(16, index, SCREEN_WIDTH - 16 * 2, 44, 4, COLOR_BORDER_HIGHLIGHTED); } else { @@ -362,7 +368,7 @@ std::string EnvironmentSelectionScreen(const std::map writeFileContent(AUTOBOOT_CONFIG_PATH, "-1"); } else { int i = 0; - for (auto const&[key, val]: payloads) { + for (auto const &[key, val] : payloads) { if (i == autoBoot) { DEBUG_FUNCTION_LINE("Save config"); writeFileContent(AUTOBOOT_CONFIG_PATH, key); @@ -374,7 +380,7 @@ std::string EnvironmentSelectionScreen(const std::map } int i = 0; - for (auto const&[key, val]: payloads) { + for (auto const &[key, val] : payloads) { if (i == selected) { return val; } diff --git a/source/module/ImportRPLInformation.h b/source/module/ImportRPLInformation.h index 49d1d54..a4bd92f 100644 --- a/source/module/ImportRPLInformation.h +++ b/source/module/ImportRPLInformation.h @@ -17,10 +17,11 @@ #pragma once -#include -#include -#include #include "utils/logger.h" +#include +#include +#include +#include class ImportRPLInformation { diff --git a/source/module/ModuleData.h b/source/module/ModuleData.h index 31cd907..ea0f1d7 100644 --- a/source/module/ModuleData.h +++ b/source/module/ModuleData.h @@ -17,11 +17,11 @@ #pragma once -#include -#include +#include "RelocationData.h" #include #include -#include "RelocationData.h" +#include +#include class ModuleData { public: diff --git a/source/module/ModuleDataFactory.cpp b/source/module/ModuleDataFactory.cpp index f97842e..027e015 100644 --- a/source/module/ModuleDataFactory.cpp +++ b/source/module/ModuleDataFactory.cpp @@ -15,12 +15,12 @@ * along with this program. If not, see . ****************************************************************************/ -#include -#include -#include -#include #include "ModuleDataFactory.h" #include "ElfUtils.h" +#include +#include +#include +#include using namespace ELFIO; @@ -144,7 +144,7 @@ ModuleDataFactory::load(const std::string &path, uint32_t destination_address_en } auto relocationData = getImportRelocationData(reader, destinations); - for (auto const &reloc: relocationData) { + for (auto const &reloc : relocationData) { moduleData->addRelocationData(reloc); } diff --git a/source/module/ModuleDataFactory.h b/source/module/ModuleDataFactory.h index fc8dd2d..f012199 100644 --- a/source/module/ModuleDataFactory.h +++ b/source/module/ModuleDataFactory.h @@ -17,12 +17,12 @@ #pragma once -#include -#include -#include +#include "../common/relocation_defines.h" #include "ModuleData.h" #include "elfio/elfio.hpp" -#include "../common/relocation_defines.h" +#include +#include +#include class ModuleDataFactory { public: diff --git a/source/module/RelocationData.h b/source/module/RelocationData.h index cbf4b8c..0a181a3 100644 --- a/source/module/RelocationData.h +++ b/source/module/RelocationData.h @@ -17,10 +17,10 @@ #pragma once -#include -#include -#include #include "ImportRPLInformation.h" +#include +#include +#include class RelocationData { diff --git a/source/utils/DrawUtils.cpp b/source/utils/DrawUtils.cpp index eda1401..d59cca7 100644 --- a/source/utils/DrawUtils.cpp +++ b/source/utils/DrawUtils.cpp @@ -1,11 +1,11 @@ #include "DrawUtils.h" #include +#include #include #include -#include -#include #include +#include #include FT_FREETYPE_H // buffer width @@ -14,9 +14,9 @@ bool DrawUtils::isBackBuffer; -uint8_t* DrawUtils::tvBuffer = nullptr; +uint8_t *DrawUtils::tvBuffer = nullptr; uint32_t DrawUtils::tvSize = 0; -uint8_t* DrawUtils::drcBuffer = nullptr; +uint8_t *DrawUtils::drcBuffer = nullptr; uint32_t DrawUtils::drcSize = 0; // Don't put those into the class or we have to include ft everywhere @@ -24,32 +24,29 @@ static FT_Library ft_lib = nullptr; static FT_Face ft_face = nullptr; static Color font_col = {0xFFFFFFFF}; -void DrawUtils::initBuffers(void* tvBuffer, uint32_t tvSize, void* drcBuffer, uint32_t drcSize) -{ - DrawUtils::tvBuffer = (uint8_t*) tvBuffer; +void DrawUtils::initBuffers(void *tvBuffer, uint32_t tvSize, void *drcBuffer, uint32_t drcSize) { + DrawUtils::tvBuffer = (uint8_t *) tvBuffer; DrawUtils::tvSize = tvSize; - DrawUtils::drcBuffer = (uint8_t*) drcBuffer; + DrawUtils::drcBuffer = (uint8_t *) drcBuffer; DrawUtils::drcSize = drcSize; } -void DrawUtils::beginDraw() -{ - uint32_t pixel = *(uint32_t*) tvBuffer; +void DrawUtils::beginDraw() { + uint32_t pixel = *(uint32_t *) tvBuffer; // check which buffer is currently used OSScreenPutPixelEx(SCREEN_TV, 0, 0, 0xABCDEF90); - if (*(uint32_t*) tvBuffer == 0xABCDEF90) { + if (*(uint32_t *) tvBuffer == 0xABCDEF90) { isBackBuffer = false; } else { isBackBuffer = true; } // restore the pixel we used for checking - *(uint32_t*) tvBuffer = pixel; + *(uint32_t *) tvBuffer = pixel; } -void DrawUtils::endDraw() -{ +void DrawUtils::endDraw() { // OSScreenFlipBuffersEx already flushes the cache? // DCFlushRange(tvBuffer, tvSize); // DCFlushRange(drcBuffer, drcSize); @@ -58,14 +55,12 @@ void DrawUtils::endDraw() OSScreenFlipBuffersEx(SCREEN_TV); } -void DrawUtils::clear(Color col) -{ +void DrawUtils::clear(Color col) { OSScreenClearBufferEx(SCREEN_TV, col.color); OSScreenClearBufferEx(SCREEN_DRC, col.color); } -void DrawUtils::drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a) -{ +void DrawUtils::drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { float opacity = a / 255.0f; // put pixel in the drc buffer @@ -75,12 +70,11 @@ void DrawUtils::drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t i += drcSize / 2; } if (a == 0xFF) { - drcBuffer[i ] = r; + drcBuffer[i] = r; drcBuffer[i + 1] = g; drcBuffer[i + 2] = b; - } - else { - drcBuffer[i ] = r * opacity + drcBuffer[i ] * (1 - opacity); + } else { + drcBuffer[i] = r * opacity + drcBuffer[i] * (1 - opacity); drcBuffer[i + 1] = g * opacity + drcBuffer[i + 1] * (1 - opacity); drcBuffer[i + 2] = b * opacity + drcBuffer[i + 2] * (1 - opacity); } @@ -88,29 +82,27 @@ void DrawUtils::drawPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t // scale and put pixel in the tv buffer for (uint32_t yy = (y * 1.5); yy < ((y * 1.5) + 1); yy++) { - for (uint32_t xx = (x * 1.5); xx < ((x * 1.5) + 1); xx++) { + for (uint32_t xx = (x * 1.5); xx < ((x * 1.5) + 1); xx++) { uint32_t i = (xx + yy * TV_WIDTH) * 4; if (i + 3 < tvSize / 2) { if (isBackBuffer) { i += tvSize / 2; } if (a == 0xFF) { - tvBuffer[i ] = r; + tvBuffer[i] = r; tvBuffer[i + 1] = g; tvBuffer[i + 2] = b; - } - else { - tvBuffer[i ] = r * opacity + tvBuffer[i ] * (1 - opacity); + } else { + tvBuffer[i] = r * opacity + tvBuffer[i] * (1 - opacity); tvBuffer[i + 1] = g * opacity + tvBuffer[i + 1] * (1 - opacity); tvBuffer[i + 2] = b * opacity + tvBuffer[i + 2] * (1 - opacity); } } - } - } + } + } } -void DrawUtils::drawRectFilled(uint32_t x, uint32_t y, uint32_t w, uint32_t h, Color col) -{ +void DrawUtils::drawRectFilled(uint32_t x, uint32_t y, uint32_t w, uint32_t h, Color col) { for (uint32_t yy = y; yy < y + h; yy++) { for (uint32_t xx = x; xx < x + w; xx++) { drawPixel(xx, yy, col); @@ -118,30 +110,28 @@ void DrawUtils::drawRectFilled(uint32_t x, uint32_t y, uint32_t w, uint32_t h, C } } -void DrawUtils::drawRect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t borderSize, Color col) -{ +void DrawUtils::drawRect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t borderSize, Color col) { drawRectFilled(x, y, w, borderSize, col); drawRectFilled(x, y + h - borderSize, w, borderSize, col); drawRectFilled(x, y, borderSize, h, col); drawRectFilled(x + w - borderSize, y, borderSize, h, col); } -void DrawUtils::drawBitmap(uint32_t x, uint32_t y, uint32_t target_width, uint32_t target_height, const uint8_t* data) -{ - if ( data[0] != 'B' || data[1] != 'M' ) { - // invalid header - return; - } +void DrawUtils::drawBitmap(uint32_t x, uint32_t y, uint32_t target_width, uint32_t target_height, const uint8_t *data) { + if (data[0] != 'B' || data[1] != 'M') { + // invalid header + return; + } - uint32_t dataPos = __builtin_bswap32(*(uint32_t*)&(data[0x0A])); - uint32_t width = __builtin_bswap32(*(uint32_t*)&(data[0x12])); - uint32_t height = __builtin_bswap32(*(uint32_t*)&(data[0x16])); + uint32_t dataPos = __builtin_bswap32(*(uint32_t *) &(data[0x0A])); + uint32_t width = __builtin_bswap32(*(uint32_t *) &(data[0x12])); + uint32_t height = __builtin_bswap32(*(uint32_t *) &(data[0x16])); - if (dataPos == 0) { - dataPos = 54; - } + if (dataPos == 0) { + dataPos = 54; + } - data += dataPos; + data += dataPos; // TODO flip image since bitmaps are stored upside down @@ -153,28 +143,26 @@ void DrawUtils::drawBitmap(uint32_t x, uint32_t y, uint32_t target_width, uint32 } } -static void png_read_data(png_structp png_ptr, png_bytep outBytes, png_size_t byteCountToRead) -{ - void** data = (void**) png_get_io_ptr(png_ptr); +static void png_read_data(png_structp png_ptr, png_bytep outBytes, png_size_t byteCountToRead) { + void **data = (void **) png_get_io_ptr(png_ptr); memcpy(outBytes, *data, byteCountToRead); - *((uint8_t**) data) += byteCountToRead; + *((uint8_t **) data) += byteCountToRead; } -void DrawUtils::drawPNG(uint32_t x, uint32_t y, const uint8_t* data) -{ +void DrawUtils::drawPNG(uint32_t x, uint32_t y, const uint8_t *data) { png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if(png_ptr == NULL) { + if (png_ptr == NULL) { return; } png_infop info_ptr = png_create_info_struct(png_ptr); - if(info_ptr == NULL) { + if (info_ptr == NULL) { png_destroy_read_struct(&png_ptr, NULL, NULL); return; } - png_set_read_fn(png_ptr, (void*) &data, png_read_data); + png_set_read_fn(png_ptr, (void *) &data, png_read_data); png_read_info(png_ptr, info_ptr); @@ -183,22 +171,21 @@ void DrawUtils::drawPNG(uint32_t x, uint32_t y, const uint8_t* data) int bitDepth = 0; int colorType = -1; uint32_t retval = png_get_IHDR(png_ptr, info_ptr, &width, &height, &bitDepth, &colorType, NULL, NULL, NULL); - if(retval != 1) { + if (retval != 1) { return; } uint32_t bytesPerRow = png_get_rowbytes(png_ptr, info_ptr); - uint8_t* rowData = new uint8_t[bytesPerRow]; + uint8_t *rowData = new uint8_t[bytesPerRow]; - for(uint32_t yy = y; yy < y + height; yy++) { - png_read_row(png_ptr, (png_bytep)rowData, NULL); + for (uint32_t yy = y; yy < y + height; yy++) { + png_read_row(png_ptr, (png_bytep) rowData, NULL); for (uint32_t xx = x; xx < x + width; xx++) { if (colorType == PNG_COLOR_TYPE_RGB_ALPHA) { uint32_t i = (xx - x) * 4; drawPixel(xx, yy, rowData[i], rowData[i + 1], rowData[i + 2], rowData[i + 3]); - } - else if (colorType == PNG_COLOR_TYPE_RGB) { + } else if (colorType == PNG_COLOR_TYPE_RGB) { uint32_t i = (xx - x) * 3; drawPixel(xx, yy, rowData[i], rowData[i + 1], rowData[i + 2], 0xFF); } @@ -209,39 +196,34 @@ void DrawUtils::drawPNG(uint32_t x, uint32_t y, const uint8_t* data) png_destroy_read_struct(&png_ptr, &info_ptr, NULL); } -void DrawUtils::initFont() -{ - void* font = NULL; +void DrawUtils::initFont() { + void *font = NULL; uint32_t size = 0; OSGetSharedData(OS_SHAREDDATATYPE_FONT_STANDARD, 0, &font, &size); if (font && size) { FT_Init_FreeType(&ft_lib); - FT_New_Memory_Face(ft_lib, (FT_Byte*) font, size, 0, &ft_face); + FT_New_Memory_Face(ft_lib, (FT_Byte *) font, size, 0, &ft_face); } } -void DrawUtils::deinitFont() -{ +void DrawUtils::deinitFont() { FT_Done_Face(ft_face); FT_Done_FreeType(ft_lib); } -void DrawUtils::setFontSize(uint32_t size) -{ +void DrawUtils::setFontSize(uint32_t size) { FT_Set_Pixel_Sizes(ft_face, 0, size); } -void DrawUtils::setFontColor(Color col) -{ +void DrawUtils::setFontColor(Color col) { font_col = col; } -static void draw_freetype_bitmap(FT_Bitmap* bitmap, FT_Int x, FT_Int y) -{ - FT_Int i, j, p, q; - FT_Int x_max = x + bitmap->width; - FT_Int y_max = y + bitmap->rows; +static void draw_freetype_bitmap(FT_Bitmap *bitmap, FT_Int x, FT_Int y) { + FT_Int i, j, p, q; + FT_Int x_max = x + bitmap->width; + FT_Int y_max = y + bitmap->rows; for (i = x, p = 0; i < x_max; i++, p++) { for (j = y, q = 0; j < y_max; j++, q++) { @@ -255,25 +237,23 @@ static void draw_freetype_bitmap(FT_Bitmap* bitmap, FT_Int x, FT_Int y) } } -void DrawUtils::print(uint32_t x, uint32_t y, const char* string, bool alignRight) -{ - wchar_t* buffer = new wchar_t[strlen(string) + 1]; +void DrawUtils::print(uint32_t x, uint32_t y, const char *string, bool alignRight) { + wchar_t *buffer = new wchar_t[strlen(string) + 1]; size_t num = mbstowcs(buffer, string, strlen(string)); if (num > 0) { buffer[num] = 0; - } - else { - wchar_t* tmp = buffer; - while ((*tmp++ = *string++)); + } else { + wchar_t *tmp = buffer; + while ((*tmp++ = *string++)) + ; } print(x, y, buffer, alignRight); delete[] buffer; } -void DrawUtils::print(uint32_t x, uint32_t y, const wchar_t* string, bool alignRight) -{ +void DrawUtils::print(uint32_t x, uint32_t y, const wchar_t *string, bool alignRight) { FT_GlyphSlot slot = ft_face->glyph; FT_Vector pen = {(int) x, (int) y}; @@ -298,17 +278,16 @@ void DrawUtils::print(uint32_t x, uint32_t y, const wchar_t* string, bool alignR } } -uint32_t DrawUtils::getTextWidth(const char* string) -{ - wchar_t* buffer = new wchar_t[strlen(string) + 1]; +uint32_t DrawUtils::getTextWidth(const char *string) { + wchar_t *buffer = new wchar_t[strlen(string) + 1]; size_t num = mbstowcs(buffer, string, strlen(string)); if (num > 0) { buffer[num] = 0; - } - else { - wchar_t* tmp = buffer; - while ((*tmp++ = *string++)); + } else { + wchar_t *tmp = buffer; + while ((*tmp++ = *string++)) + ; } uint32_t width = getTextWidth(buffer); @@ -317,8 +296,7 @@ uint32_t DrawUtils::getTextWidth(const char* string) return width; } -uint32_t DrawUtils::getTextWidth(const wchar_t* string) -{ +uint32_t DrawUtils::getTextWidth(const wchar_t *string) { FT_GlyphSlot slot = ft_face->glyph; uint32_t width = 0; diff --git a/source/utils/DrawUtils.h b/source/utils/DrawUtils.h index dee4a87..10b211b 100644 --- a/source/utils/DrawUtils.h +++ b/source/utils/DrawUtils.h @@ -7,11 +7,14 @@ #define SCREEN_HEIGHT 480 union Color { - Color(uint32_t color) { - this->color = color; + Color(uint32_t color) { + this->color = color; } - Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { - this->r = r; this->g = g; this->b = b; this->a = a; + Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { + this->r = r; + this->g = g; + this->b = b; + this->a = a; } uint32_t color; @@ -25,7 +28,7 @@ union Color { class DrawUtils { public: - static void initBuffers(void* tvBuffer, uint32_t tvSize, void* drcBuffer, uint32_t drcSize); + static void initBuffers(void *tvBuffer, uint32_t tvSize, void *drcBuffer, uint32_t drcSize); static void beginDraw(); static void endDraw(); static void clear(Color col); @@ -35,23 +38,23 @@ public: static void drawRectFilled(uint32_t x, uint32_t y, uint32_t w, uint32_t h, Color col); static void drawRect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t borderSize, Color col); - static void drawBitmap(uint32_t x, uint32_t y, uint32_t target_width, uint32_t target_height, const uint8_t* data); - static void drawPNG(uint32_t x, uint32_t y, const uint8_t* data); + static void drawBitmap(uint32_t x, uint32_t y, uint32_t target_width, uint32_t target_height, const uint8_t *data); + static void drawPNG(uint32_t x, uint32_t y, const uint8_t *data); static void initFont(); static void deinitFont(); static void setFontSize(uint32_t size); static void setFontColor(Color col); - static void print(uint32_t x, uint32_t y, const char* string, bool alignRight = false); - static void print(uint32_t x, uint32_t y, const wchar_t* string, bool alignRight = false); - static uint32_t getTextWidth(const char* string); - static uint32_t getTextWidth(const wchar_t* string); + static void print(uint32_t x, uint32_t y, const char *string, bool alignRight = false); + static void print(uint32_t x, uint32_t y, const wchar_t *string, bool alignRight = false); + static uint32_t getTextWidth(const char *string); + static uint32_t getTextWidth(const wchar_t *string); private: static bool isBackBuffer; - static uint8_t* tvBuffer; + static uint8_t *tvBuffer; static uint32_t tvSize; - static uint8_t* drcBuffer; + static uint8_t *drcBuffer; static uint32_t drcSize; }; diff --git a/source/utils/StringTools.cpp b/source/utils/StringTools.cpp index a97e3b9..f2f9de3 100644 --- a/source/utils/StringTools.cpp +++ b/source/utils/StringTools.cpp @@ -23,17 +23,16 @@ * * for WiiXplorer 2010 ***************************************************************************/ -#include -#include -#include #include +#include #include -#include -#include +#include +#include #include -#include -#include #include +#include +#include +#include BOOL StringTools::EndsWith(const std::string &a, const std::string &b) { @@ -249,7 +248,7 @@ char *StringTools::str_replace(char *orig, char *rep, char *with) { char *tmp; // varies int len_rep; // length of rep (the string to remove) int len_with; // length of with (the string to replace rep with) - int len_front; // distance between rep and end of last rep + int len_front;// distance between rep and end of last rep int count; // number of replacements // sanity checks and initialization @@ -257,7 +256,7 @@ char *StringTools::str_replace(char *orig, char *rep, char *with) { return NULL; len_rep = strlen(rep); if (len_rep == 0) - return NULL; // empty rep causes infinite loop during count + return NULL;// empty rep causes infinite loop during count if (!with) with = (char *) ""; len_with = strlen(with); @@ -283,7 +282,7 @@ char *StringTools::str_replace(char *orig, char *rep, char *with) { len_front = ins - orig; tmp = strncpy(tmp, orig, len_front) + len_front; tmp = strcpy(tmp, with) + len_with; - orig += len_front + len_rep; // move to next "end of rep" + orig += len_front + len_rep;// move to next "end of rep" } strcpy(tmp, orig); return result; diff --git a/source/utils/StringTools.h b/source/utils/StringTools.h index 851aa73..d1a1570 100644 --- a/source/utils/StringTools.h +++ b/source/utils/StringTools.h @@ -26,8 +26,8 @@ #ifndef __STRING_TOOLS_H #define __STRING_TOOLS_H -#include #include +#include #include class StringTools { @@ -62,4 +62,3 @@ public: }; #endif /* __STRING_TOOLS_H */ - diff --git a/source/utils/logger.c b/source/utils/logger.c index 0411db7..0ed05e6 100644 --- a/source/utils/logger.c +++ b/source/utils/logger.c @@ -1,13 +1,13 @@ #ifdef DEBUG #include -#include #include #include +#include uint32_t moduleLogInit = false; uint32_t cafeLogInit = false; uint32_t udpLogInit = false; -#endif // DEBUG +#endif// DEBUG void initLogging() { #ifdef DEBUG @@ -15,7 +15,7 @@ void initLogging() { cafeLogInit = WHBLogCafeInit(); udpLogInit = WHBLogUdpInit(); } -#endif // DEBUG +#endif// DEBUG } void deinitLogging() { @@ -32,5 +32,5 @@ void deinitLogging() { WHBLogUdpDeinit(); udpLogInit = false; } -#endif // DEBUG +#endif// DEBUG } \ No newline at end of file diff --git a/source/utils/logger.h b/source/utils/logger.h index 6ff5ae2..2321b2b 100644 --- a/source/utils/logger.h +++ b/source/utils/logger.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #ifdef __cplusplus extern "C" { @@ -14,12 +14,14 @@ extern "C" { #define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0) -#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \ - WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \ +#define DEBUG_FUNCTION_LINE(FMT, ARGS...) \ + do { \ + WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \ } while (0) -#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \ - WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \ +#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \ + do { \ + WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \ } while (0) #else @@ -39,4 +41,3 @@ void deinitLogging(); #ifdef __cplusplus } #endif -