From d873a26f4139a320faf0b86626e465bc1d08e0c4 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Mon, 12 Dec 2022 19:25:31 +0100 Subject: [PATCH] all: clang-format-15.0.6 --- .clang-format | 48 +++++++++++++++++++++++++++--------------- src/bele.h | 2 +- src/compress_lzma.cpp | 8 +++---- src/linker.cpp | 44 +++++++++++++++++++------------------- src/p_com.cpp | 2 +- src/p_tos.cpp | 2 +- src/s_djgpp2.cpp | 6 ++++-- src/s_win32.cpp | 6 +++--- src/util/membuffer.cpp | 2 +- 9 files changed, 68 insertions(+), 52 deletions(-) diff --git a/.clang-format b/.clang-format index dd060d5a..5b93ff42 100644 --- a/.clang-format +++ b/.clang-format @@ -3,26 +3,40 @@ # for clang-format-15.0.6 from https://github.com/upx/upx-stubtools/releases --- BasedOnStyle: LLVM -AccessModifierOffset: -4 -AlwaysBreakTemplateDeclarations: true ColumnLimit: 100 IndentWidth: 4 +--- +Language: Cpp +AccessModifierOffset: -4 +AlwaysBreakTemplateDeclarations: true +AttributeMacros: + - __acc_cdecl + - __acc_cdecl_atexit + - __acc_cdecl_qsort + - __acc_cdecl_sighandler + - __acc_forceinline + - __acc_noinline + - __acc_static_noinline + - __acc_static_forceinline +EmptyLineBeforeAccessModifier: Leave SortIncludes: false SpaceAfterCStyleCast: true Standard: Cpp03 -StatementMacros: [ - ACCCHK_ASSERT, - ACCCHK_ASSERT_IS_SIGNED_T, - ACCCHK_ASSERT_IS_UNSIGNED_T, - ACCCHK_ASSERT_SIGN_T, - ACC_BLOCK_BEGIN, - ACC_COMPILE_TIME_ASSERT, - ACC_COMPILE_TIME_ASSERT_HEADER, - ACC_CXX_DISABLE_NEW_DELETE, - ACC_CXX_TRIGGER_FUNCTION, - ACC_CXX_TRIGGER_FUNCTION_IMPL, - CLANG_FORMAT_DUMMY_STATEMENT, - COMPILE_TIME_ASSERT, - COMPILE_TIME_ASSERT_ALIGNED1, -] +StatementMacros: + - ACCCHK_ASSERT + - ACCCHK_ASSERT_IS_SIGNED_T + - ACCCHK_ASSERT_IS_UNSIGNED_T + - ACCCHK_ASSERT_SIGN_T + - ACC_BLOCK_BEGIN + - ACC_COMPILE_TIME_ASSERT + - ACC_COMPILE_TIME_ASSERT_HEADER + - ACC_CXX_DISABLE_NEW_DELETE + - ACC_CXX_TRIGGER_FUNCTION + - ACC_CXX_TRIGGER_FUNCTION_IMPL + - CLANG_FORMAT_DUMMY_STATEMENT + - COMPILE_TIME_ASSERT + - COMPILE_TIME_ASSERT_ALIGNED1 +WhitespaceSensitiveMacros: + - ACC_PP_MACRO_EXPAND + - ACC_PP_STRINGIZE ... diff --git a/src/bele.h b/src/bele.h index 71b03b15..7e0b24e3 100644 --- a/src/bele.h +++ b/src/bele.h @@ -57,7 +57,7 @@ __acc_static_forceinline upx_uint64_t get_ne64(const void *p) { } __acc_static_forceinline void set_ne16(void *p, unsigned vv) { - upx_uint16_t v = (upx_uint16_t)(vv & 0xffff); + upx_uint16_t v = (upx_uint16_t) (vv & 0xffff); upx_memcpy_inline(p, &v, sizeof(v)); } diff --git a/src/compress_lzma.cpp b/src/compress_lzma.cpp index 57f14327..b64dc916 100644 --- a/src/compress_lzma.cpp +++ b/src/compress_lzma.cpp @@ -216,7 +216,7 @@ error: #undef NULL #define NULL nullptr #include -//#include +// #include #include namespace MyLzma { @@ -298,12 +298,12 @@ STDMETHODIMP ProgressInfo::SetRatioInfo(const UInt64 *inSize, const UInt64 *outS #include #include -//#include +// #include #include #include #include -//#include -//#include +// #include +// #include #include #include #undef RC_NORMALIZE diff --git a/src/linker.cpp b/src/linker.cpp index dfe487a6..0fbe9f41 100644 --- a/src/linker.cpp +++ b/src/linker.cpp @@ -198,8 +198,7 @@ void ElfLinker::preprocessSections(char *start, char const *end) { char *n = strstr(start, name); n[strlen(name)] = 0; addSection(n, input + offset, size, align); - - // printf("section %s preprocessed\n", n); + NO_printf("section %s preprocessed\n", n); } } addSection("*ABS*", nullptr, 0, 0); @@ -224,21 +223,21 @@ void ElfLinker::preprocessSymbols(char *start, char const *end) { assert(offset == 0); } #if 0 - else if (sscanf(start, "%x%*8c %1023s %*x %1023s", + else if (sscanf(start, "%x%*8c %1023s %*x %1023s", &offset, section, symbol) == 3) #else // work around broken scanf() implementations // http://bugs.winehq.org/show_bug.cgi?id=10401 (fixed in Wine 0.9.58) - else if (sscanf(start, "%x%*c%*c%*c%*c%*c%*c%*c%*c %1023s %*x %1023s", + else if (sscanf(start, "%x%*c%*c%*c%*c%*c%*c%*c%*c %1023s %*x %1023s", &offset, section, + symbol) == 3) #endif - &offset, section, symbol) == 3) { - char *s = strstr(start, symbol); - s[strlen(symbol)] = 0; - if (strcmp(section, "*UND*") == 0) - offset = 0xdeaddead; - assert(strcmp(section, "*ABS*") != 0); - addSymbol(s, section, offset); - } + char *s = strstr(start, symbol); + s[strlen(symbol)] = 0; + if (strcmp(section, "*UND*") == 0) + offset = 0xdeaddead; + assert(strcmp(section, "*ABS*") != 0); + addSymbol(s, section, offset); + } } } @@ -290,8 +289,8 @@ void ElfLinker::preprocessRelocations(char *start, char const *end) { if (section) { addRelocation(section->name, offset, t, symbol, add); - // printf("relocation %s %s %x %llu preprocessed\n", section->name, symbol, offset, - // (unsigned long long) add); + NO_printf("relocation %s %s %x %llu preprocessed\n", section->name, symbol, offset, + (unsigned long long) add); } } } @@ -317,7 +316,7 @@ ElfLinker::Symbol *ElfLinker::findSymbol(const char *name, bool fatal) const { ElfLinker::Section *ElfLinker::addSection(const char *sname, const void *sdata, int slen, unsigned p2align) { - // printf("addSection: %s len=%d align=%d\n", sname, slen, p2align); + NO_printf("addSection: %s len=%d align=%d\n", sname, slen, p2align); if (!sdata && (!strcmp("ABS*", sname) || !strcmp("UND*", sname))) return nullptr; if (update_capacity(nsections, &nsections_capacity)) @@ -335,7 +334,7 @@ ElfLinker::Section *ElfLinker::addSection(const char *sname, const void *sdata, ElfLinker::Symbol *ElfLinker::addSymbol(const char *name, const char *section, upx_uint64_t offset) { - // printf("addSymbol: %s %s 0x%x\n", name, section, offset); + NO_printf("addSymbol: %s %s 0x%llx\n", name, section, offset); if (update_capacity(nsymbols, &nsymbols_capacity)) symbols = static_cast(realloc(symbols, nsymbols_capacity * sizeof(Symbol *))); assert(symbols != nullptr); @@ -410,7 +409,7 @@ int ElfLinker::addLoader(const char *sname) { } memcpy(output + outputlen, section->input, section->size); section->output = output + outputlen; - // printf("section added: 0x%04x %3d %s\n", outputlen, section->size, section->name); + NO_printf("section added: 0x%04x %3d %s\n", outputlen, section->size, section->name); outputlen += section->size; if (head) { @@ -479,11 +478,12 @@ void ElfLinker::relocate() { value = rel->value->section->offset + rel->value->offset + rel->add; } upx_byte *location = rel->section->output + rel->offset; - // printf("%-28s %-28s %-10s %#16llx %#16llx\n", rel->section->name, rel->value->name, - // rel->type, (long long) value, (long long) value - rel->section->offset - rel->offset); - // printf(" %llx %d %llx %d %llx : %d\n", (long long) value, - // (int)rel->value->section->offset, - // rel->value->offset, rel->offset, (long long) rel->add, *location); + NO_printf("%-28s %-28s %-10s %#16llx %#16llx\n", rel->section->name, rel->value->name, + rel->type, (long long) value, + (long long) value - rel->section->offset - rel->offset); + NO_printf(" %llx %d %llx %d %llx :%d\n", (long long) value, + (int) rel->value->section->offset, rel->value->offset, rel->offset, + (long long) rel->add, *location); relocate1(rel, location, value, rel->type); } } diff --git a/src/p_com.cpp b/src/p_com.cpp index a353579e..e7e85ff9 100644 --- a/src/p_com.cpp +++ b/src/p_com.cpp @@ -35,7 +35,7 @@ static const CLANG_FORMAT_DUMMY_STATEMENT #include "stub/i086-dos16.com.h" -//#define TESTING 1 +// #define TESTING 1 /************************************************************************* // diff --git a/src/p_tos.cpp b/src/p_tos.cpp index aae63eb3..3500ddc8 100644 --- a/src/p_tos.cpp +++ b/src/p_tos.cpp @@ -36,7 +36,7 @@ static const CLANG_FORMAT_DUMMY_STATEMENT #include "stub/m68k-atari.tos.h" -//#define TESTING 1 +// #define TESTING 1 /************************************************************************* // diff --git a/src/s_djgpp2.cpp b/src/s_djgpp2.cpp index 3792b418..3cdded32 100644 --- a/src/s_djgpp2.cpp +++ b/src/s_djgpp2.cpp @@ -81,7 +81,9 @@ struct screen_data_t { }; /* atExit information */ -static struct { int cursor_shape; } ae = {-1}; +static struct { + int cursor_shape; +} ae = {-1}; #if USE_SCROLLBACK static __inline__ void sb_add(screen_t *this, int *val, int inc) { @@ -107,7 +109,7 @@ static void refresh(screen_t *this) { UNUSED(this); } static __inline__ Cell make_cell(screen_t *this, int ch, int attr) { UNUSED(this); - return (Cell)(((attr & 0xff) << 8) | (ch & 0xff)); + return (Cell) (((attr & 0xff) << 8) | (ch & 0xff)); } static int getMode(const screen_t *this) { diff --git a/src/s_win32.cpp b/src/s_win32.cpp index b6a3ba7f..c28260f1 100644 --- a/src/s_win32.cpp +++ b/src/s_win32.cpp @@ -76,7 +76,7 @@ struct screen_data_t { CHAR_INFO empty_line[256]; }; -#define P(x) ((SHORT)(x)) +#define P(x) ((SHORT) (x)) static const COORD pos00 = {0, 0}; static const COORD size11 = {1, 1}; @@ -111,12 +111,12 @@ static int getFg(const screen_t *this) { return this->data->attr & mask_fg; } static int getBg(const screen_t *this) { return this->data->attr & mask_bg; } static void setFg(screen_t *this, int fg) { - this->data->attr = (WORD)((this->data->attr & mask_bg) | (fg & mask_fg)); + this->data->attr = (WORD) ((this->data->attr & mask_bg) | (fg & mask_fg)); SetConsoleTextAttribute(this->data->ho, this->data->attr); } static void setBg(screen_t *this, int bg) { - this->data->attr = (WORD)((this->data->attr & mask_fg) | (bg & mask_bg)); + this->data->attr = (WORD) ((this->data->attr & mask_fg) | (bg & mask_bg)); SetConsoleTextAttribute(this->data->ho, this->data->attr); } diff --git a/src/util/membuffer.cpp b/src/util/membuffer.cpp index dd6b766e..a8d81ba1 100644 --- a/src/util/membuffer.cpp +++ b/src/util/membuffer.cpp @@ -152,7 +152,7 @@ void MemBuffer::fill(unsigned off, unsigned len, int value) { // **************************************************************************/ -#define PTR_BITS(p) ((unsigned) ((upx_uintptr_t)(p) &0xffffffff)) +#define PTR_BITS(p) ((unsigned) ((upx_uintptr_t) (p) &0xffffffff)) #define MAGIC1(p) ((PTR_BITS(p) ^ 0xfefdbeeb) | 1) #define MAGIC2(p) ((PTR_BITS(p) ^ 0xfefdbeeb ^ 0x80024011) | 1)