From 2205f3623faa7da10a04a66e6f80503e2bc5a932 Mon Sep 17 00:00:00 2001 From: Dhruv Maroo Date: Fri, 5 Aug 2022 23:30:07 +0530 Subject: [PATCH] Use clang-format 14 instead of 13 (#2846) --- .github/workflows/linter.yml | 10 ++-- DEVELOPERS.md | 4 +- librz/asm/arch/include/mybfd.h | 42 ------------- librz/asm/arch/rsp/rsp_idec.c | 88 +++++++++++++++++++++------- librz/bin/pdb/omap.c | 4 +- librz/include/rz_cons.h | 4 +- librz/include/rz_util/rz_serialize.h | 4 +- 7 files changed, 82 insertions(+), 74 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 7ab6a113fd..bf3b23ec01 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -70,18 +70,18 @@ jobs: - name: Install wget, software-properties-common, lsb-release (dependencies of LLVM install script) run: sudo apt --assume-yes install wget software-properties-common lsb-release - - name: Install automatic LLVM 13 - run: wget https://apt.llvm.org/llvm.sh -O /tmp/llvm-install.sh; chmod +x /tmp/llvm-install.sh; sudo /tmp/llvm-install.sh 13 + - name: Install automatic LLVM 14 + run: wget https://apt.llvm.org/llvm.sh -O /tmp/llvm-install.sh; chmod +x /tmp/llvm-install.sh; sudo /tmp/llvm-install.sh 14 - - name: Install clang-format-13 - run: sudo apt --assume-yes install clang-format-13 + - name: Install clang-format-14 + run: sudo apt --assume-yes install clang-format-14 - name: Install gitpython run: sudo pip install gitpython - name: Run clang-format run: | - sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-13 130 + sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-14 140 clang-format --version python sys/clang-format.py --check --verbose diff --git a/DEVELOPERS.md b/DEVELOPERS.md index 519be72475..91a8538589 100644 --- a/DEVELOPERS.md +++ b/DEVELOPERS.md @@ -49,13 +49,13 @@ E.g.: `Bug fix did not change the general behavior of the function. No documenta In order to contribute with patches or plugins, we encourage you to use the same coding style as the rest of the code base. -* Use git-clang-format 13 to format your code. If clang-format-13 is not available on +* Use git-clang-format 14 to format your code. If clang-format-14 is not available on your Debian-based distribution, you can install it from https://apt.llvm.org/. You should invoke it as below (after making sure that your local copy of `dev` is up-to-date and your branch is up-to-date with `dev`): ```bash -git-clang-format-13 --extensions c,cpp,h,hpp,inc --style file dev +git-clang-format-14 --extensions c,cpp,h,hpp,inc --style file dev ``` * Lines should be at most 100 chars. A tab is considered as 8 chars. If it makes diff --git a/librz/asm/arch/include/mybfd.h b/librz/asm/arch/include/mybfd.h index ee7c4931f6..9cd6134b4e 100644 --- a/librz/asm/arch/include/mybfd.h +++ b/librz/asm/arch/include/mybfd.h @@ -1467,48 +1467,6 @@ extern const struct bfd_symbol *const bfd_ind_symbol; #define bfd_section_removed_from_list(ABFD, S) \ ((S)->next ? (S)->next->prev != (S) : (ABFD)->section_last != (S)) -#define BFD_FAKE_SECTION(SEC, FLAGS, SYM, SYM_PTR, NAME, IDX) \ - /* name, id, index, next, prev, flags, user_set_vma, */ \ - { \ - NAME, IDX, 0, NULL, NULL, FLAGS, 0, \ -\ - /* linker_mark, linker_has_input, gc_mark, gc_mark_from_eh, */ \ - 0, 0, 1, 0, \ -\ - /* segment_mark, sec_info_type, use_rela_p, has_tls_reloc, */ \ - 0, 0, 0, 0, \ -\ - /* has_gp_reloc, need_finalize_relax, reloc_done, */ \ - 0, 0, 0, \ -\ - /* vma, lma, size, rawsize */ \ - 0, 0, 0, 0, \ -\ - /* output_offset, output_section, alignment_power, */ \ - 0, (struct bfd_section *)&SEC, 0, \ -\ - /* relocation, orelocation, reloc_count, filepos, rel_filepos, */ \ - NULL, NULL, 0, 0, 0, \ -\ - /* line_filepos, userdata, contents, lineno, lineno_count, */ \ - 0, NULL, NULL, NULL, 0, \ -\ - /* entsize, kept_section, moving_line_filepos, */ \ - 0, NULL, 0, \ -\ - /* target_index, used_by_bfd, constructor_chain, owner, */ \ - 0, NULL, NULL, NULL, \ -\ - /* symbol, */ \ - (struct bfd_symbol *)SYM, \ -\ - /* symbol_ptr_ptr, */ \ - (struct bfd_symbol **)SYM_PTR, \ -\ - /* map_head, map_tail */ \ - { NULL }, { NULL } \ - } - void bfd_section_list_clear(bfd *); asection *bfd_get_section_by_name(bfd *abfd, const char *name); diff --git a/librz/asm/arch/rsp/rsp_idec.c b/librz/asm/arch/rsp/rsp_idec.c index 69e7ac0906..7ce56b5390 100644 --- a/librz/asm/arch/rsp/rsp_idec.c +++ b/librz/asm/arch/rsp/rsp_idec.c @@ -132,49 +132,93 @@ const char *rsp_c2_vreg_element_names[] = { /* Operands description */ #define OPNDS_NONE 0, #define OPNDS_TARGET \ - 1, { TARGET_DECODER } + 1, { \ + TARGET_DECODER \ + } #define OPNDS_RS_OFFSET \ - 2, { RS_DECODER, OFFSET_DECODER } + 2, { \ + RS_DECODER, OFFSET_DECODER \ + } #define OPNDS_RS_RT_OFFSET \ - 3, { RS_DECODER, RT_DECODER, OFFSET_DECODER } + 3, { \ + RS_DECODER, RT_DECODER, OFFSET_DECODER \ + } #define OPNDS_RT_BASE_OFFSET \ - 2, { RT_DECODER, BASE_OFFSET_DECODER } + 2, { \ + RT_DECODER, BASE_OFFSET_DECODER \ + } #define OPNDS_RS \ - 1, { RS_DECODER } + 1, { \ + RS_DECODER \ + } #define OPNDS_RT_LUI \ - 2, { RT_DECODER, LUI_DECODER } + 2, { \ + RT_DECODER, LUI_DECODER \ + } #define OPNDS_RT_RS_SIMM \ - 3, { RT_DECODER, RS_DECODER, SIMM_DECODER } + 3, { \ + RT_DECODER, RS_DECODER, SIMM_DECODER \ + } #define OPNDS_RT_RS_ZIMM \ - 3, { RT_DECODER, RS_DECODER, ZIMM_DECODER } + 3, { \ + RT_DECODER, RS_DECODER, ZIMM_DECODER \ + } #define OPNDS_RD_RT_SA \ - 3, { RD_DECODER, RT_DECODER, SA_DECODER } + 3, { \ + RD_DECODER, RT_DECODER, SA_DECODER \ + } #define OPNDS_RD_RT_RS \ - 3, { RD_DECODER, RT_DECODER, RS_DECODER } + 3, { \ + RD_DECODER, RT_DECODER, RS_DECODER \ + } #define OPNDS_RD_RS_RT \ - 3, { RD_DECODER, RS_DECODER, RT_DECODER } + 3, { \ + RD_DECODER, RS_DECODER, RT_DECODER \ + } #define OPNDS_RT_C0_REG \ - 2, { RT_DECODER, C0_REG_DECODER } + 2, { \ + RT_DECODER, C0_REG_DECODER \ + } #define OPNDS_RT_C2_CREG \ - 2, { RT_DECODER, C2_CREG_DECODER } + 2, { \ + RT_DECODER, C2_CREG_DECODER \ + } #define OPNDS_RT_VSB \ - 2, { RT_DECODER, VS_BYTE_DECODER } + 2, { \ + RT_DECODER, VS_BYTE_DECODER \ + } #define OPNDS_VDS_VTS \ - 2, { VD_SCALAR_DECODER, VT_SCALAR_DECODER } + 2, { \ + VD_SCALAR_DECODER, VT_SCALAR_DECODER \ + } #define OPNDS_VTB_BASE_OFFSET1 \ - 2, { VT_BYTE_DECODER, BASE_VOFFSET1_DECODER } + 2, { \ + VT_BYTE_DECODER, BASE_VOFFSET1_DECODER \ + } #define OPNDS_VTB_BASE_OFFSET2 \ - 2, { VT_BYTE_DECODER, BASE_VOFFSET2_DECODER } + 2, { \ + VT_BYTE_DECODER, BASE_VOFFSET2_DECODER \ + } #define OPNDS_VTB_BASE_OFFSET4 \ - 2, { VT_BYTE_DECODER, BASE_VOFFSET4_DECODER } + 2, { \ + VT_BYTE_DECODER, BASE_VOFFSET4_DECODER \ + } #define OPNDS_VTB_BASE_OFFSET8 \ - 2, { VT_BYTE_DECODER, BASE_VOFFSET8_DECODER } + 2, { \ + VT_BYTE_DECODER, BASE_VOFFSET8_DECODER \ + } #define OPNDS_VTB_BASE_OFFSET16 \ - 2, { VT_BYTE_DECODER, BASE_VOFFSET16_DECODER } + 2, { \ + VT_BYTE_DECODER, BASE_VOFFSET16_DECODER \ + } #define OPNDS_VD_VS_C2_ACCU \ - 3, { VD_DECODER, VS_DECODER, C2_ACCU_DECODER } + 3, { \ + VD_DECODER, VS_DECODER, C2_ACCU_DECODER \ + } #define OPNDS_VD_VS_VTE \ - 3, { VD_DECODER, VS_DECODER, VT_ELEMENT_DECODER } + 3, { \ + VD_DECODER, VS_DECODER, VT_ELEMENT_DECODER \ + } /* Instructions description */ #define INVALID \ diff --git a/librz/bin/pdb/omap.c b/librz/bin/pdb/omap.c index 3e000cf413..70c41e48f0 100644 --- a/librz/bin/pdb/omap.c +++ b/librz/bin/pdb/omap.c @@ -45,7 +45,9 @@ RZ_IPI void free_omap_stream(RzPdbOmapStream *stream) { } OmapEntry *entry; RzListIter *it; - rz_list_foreach (stream->entries, it, entry) { RZ_FREE(entry); } + rz_list_foreach (stream->entries, it, entry) { + RZ_FREE(entry); + } rz_list_free(stream->entries); free(stream); } diff --git a/librz/include/rz_cons.h b/librz/include/rz_cons.h index ed31978205..478b7af416 100644 --- a/librz/include/rz_cons.h +++ b/librz/include/rz_cons.h @@ -659,7 +659,9 @@ typedef struct rz_cons_t { { 0, a, r, g, b, bgr, bgg, bgb, id16 } #else #define RZCOLOR(a, r, g, b, bgr, bgg, bgb, id16) \ - (RzColor) { 0, a, r, g, b, bgr, bgg, bgb, id16 } + (RzColor) { \ + 0, a, r, g, b, bgr, bgg, bgb, id16 \ + } #endif #define RzColor_NULL RZCOLOR(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -1) #if __WINDOWS__ diff --git a/librz/include/rz_util/rz_serialize.h b/librz/include/rz_util/rz_serialize.h index 77dc5549c3..f026da1256 100644 --- a/librz/include/rz_util/rz_serialize.h +++ b/librz/include/rz_util/rz_serialize.h @@ -82,7 +82,9 @@ static inline void rz_key_parser_add(RzKeyParser *parser, const char *key, int v #define RZ_KEY_PARSER_JSON(parser, json, child, body) \ if (json->type == RZ_JSON_OBJECT) { \ for (RzJson *child = json->children.first; child; child = child->next) { \ - RZ_KEY_PARSER_SWITCH(parser, child->key) { body } \ + RZ_KEY_PARSER_SWITCH(parser, child->key) { \ + body \ + } \ } \ }