From b4fe7099f14011a18ea72043dae70bf62c1c5b67 Mon Sep 17 00:00:00 2001 From: brightprogrammer Date: Tue, 7 Oct 2025 17:26:42 -0700 Subject: [PATCH 01/15] Run Clang Format --- Fuzz/Harness/ListInt.c | 2 +- Include/Misra/Std/Container/List/Access.h | 4 +- Include/Misra/Std/Container/List/Foreach.h | 178 ++++++++++++--------- Include/Misra/Std/Container/List/Remove.h | 3 +- Source/Misra/Std/Container/List.c | 10 +- 5 files changed, 111 insertions(+), 86 deletions(-) diff --git a/Fuzz/Harness/ListInt.c b/Fuzz/Harness/ListInt.c index 8cd0d30..53b9542 100644 --- a/Fuzz/Harness/ListInt.c +++ b/Fuzz/Harness/ListInt.c @@ -192,7 +192,7 @@ void fuzz_int_list(IntList *list, ListIntFunction func, const uint8_t *data, siz } case LIST_INT_MERGE : { - IntList temp = ListInitT(temp); + IntList temp = ListInitT(temp); uint8_t count = extract_u8(data, offset, size); count = count % 4; diff --git a/Include/Misra/Std/Container/List/Access.h b/Include/Misra/Std/Container/List/Access.h index 9c02261..68509eb 100644 --- a/Include/Misra/Std/Container/List/Access.h +++ b/Include/Misra/Std/Container/List/Access.h @@ -32,7 +32,7 @@ #define ListPtrAt(l, idx) ((LIST_DATA_TYPE(l) *)item_ptr_at_list(GENERIC_LIST(l), sizeof(LIST_DATA_TYPE(l)), (idx))) #ifdef __cplusplus -#define ListAt(l, idx) (ListPtrAt((l), (idx)) ? *ListPtrAt((l), (idx)) : (LIST_DATA_TYPE(l) {0})) +# define ListAt(l, idx) (ListPtrAt((l), (idx)) ? *ListPtrAt((l), (idx)) : (LIST_DATA_TYPE(l) {0})) #else /// /// Data in node at given index in given list @@ -45,7 +45,7 @@ /// SUCCESS: Data from node in list at given index. /// FAILURE: Emtpy object. /// -#define ListAt(l, idx) (ListPtrAt((l), (idx)) ? *ListPtrAt((l), (idx)) : ((LIST_DATA_TYPE(l)) {0})) +# define ListAt(l, idx) (ListPtrAt((l), (idx)) ? *ListPtrAt((l), (idx)) : ((LIST_DATA_TYPE(l)) {0})) #endif /// diff --git a/Include/Misra/Std/Container/List/Foreach.h b/Include/Misra/Std/Container/List/Foreach.h index 0158386..7a505fc 100644 --- a/Include/Misra/Std/Container/List/Foreach.h +++ b/Include/Misra/Std/Container/List/Foreach.h @@ -23,15 +23,17 @@ /// /// TAGS: Foreach, List, Iteration, Loop /// -#define ListForeach(l, var) \ - for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ - if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->head)) \ - for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node); \ - UNPL(node) = ListNodeNext(UNPL(node))) \ - if (((void *)UNPL(node)->next != (void *)UNPL(node)) && \ - ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data)) \ - for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false) \ - for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); UNPL(_once); UNPL(_once) = false) +#define ListForeach(l, var) \ + for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ + if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->head)) \ + for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node); \ + UNPL(node) = ListNodeNext(UNPL(node))) \ + if (((void *)UNPL(node)->next != (void *)UNPL(node)) && \ + ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data)) \ + for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false) \ + for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); \ + UNPL(_once); \ + UNPL(_once) = false) /// /// Iterate over each element var (as a pointer) of the given list l. @@ -48,15 +50,17 @@ /// /// TAGS: Foreach, List, Iteration, Loop, Pointer /// -#define ListForeachPtr(l, var) \ - for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ - if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->head)) \ - for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node); \ - UNPL(node) = ListNodeNext(UNPL(node))) \ - if (((void *)UNPL(node)->next != (void *)UNPL(node)) && \ - ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data)) \ - for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false) \ - for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); UNPL(_once); UNPL(_once) = false) +#define ListForeachPtr(l, var) \ + for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ + if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->head)) \ + for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node); \ + UNPL(node) = ListNodeNext(UNPL(node))) \ + if (((void *)UNPL(node)->next != (void *)UNPL(node)) && \ + ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data)) \ + for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false) \ + for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); \ + UNPL(_once); \ + UNPL(_once) = false) /// /// Iterate over each element var of the given list l in reverse order. @@ -73,15 +77,17 @@ /// /// TAGS: Foreach, List, Iteration, Loop, Reverse /// -#define ListForeachReverse(l, var) \ - for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ - if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->tail)) \ - for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node); \ - UNPL(node) = ListNodePrev(UNPL(node))) \ - if (((void *)UNPL(node)->next != (void *)UNPL(node)) && \ - ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data)) \ - for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false) \ - for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); UNPL(_once); UNPL(_once) = false) +#define ListForeachReverse(l, var) \ + for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ + if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->tail)) \ + for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node); \ + UNPL(node) = ListNodePrev(UNPL(node))) \ + if (((void *)UNPL(node)->next != (void *)UNPL(node)) && \ + ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data)) \ + for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false) \ + for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); \ + UNPL(_once); \ + UNPL(_once) = false) /// /// Iterate over each element var (as a pointer) of the given list l in reverse order. @@ -98,15 +104,17 @@ /// /// TAGS: Foreach, List, Iteration, Loop, Reverse, Pointer /// -#define ListForeachPtrReverse(l, var) \ - for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ - if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->tail)) \ - for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node); \ - UNPL(node) = ListNodePrev(UNPL(node))) \ - if (((void *)UNPL(node)->next != (void *)UNPL(node)) && \ - ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data)) \ - for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false) \ - for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); UNPL(_once); UNPL(_once) = false) +#define ListForeachPtrReverse(l, var) \ + for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ + if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->tail)) \ + for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node); \ + UNPL(node) = ListNodePrev(UNPL(node))) \ + if (((void *)UNPL(node)->next != (void *)UNPL(node)) && \ + ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data)) \ + for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false) \ + for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); \ + UNPL(_once); \ + UNPL(_once) = false) /// /// Iterate over each element var of the given list l in the index range [start, end). @@ -126,15 +134,17 @@ /// /// TAGS: Foreach, List, Iteration, Loop, Range /// -#define ListForeachInRange(l, var, start, end) \ - for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ - if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head) \ - for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node); \ - UNPL(node) = ListNodeNext(UNPL(node))) \ +#define ListForeachInRange(l, var, start, end) \ + for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ + if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head) \ + for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node); \ + UNPL(node) = ListNodeNext(UNPL(node))) \ for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodeNext(UNPL(node)), ++UNPL(i)) \ if (UNPL(i) >= (start) && (UNPL(node)->data)) \ for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false) \ - for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); UNPL(_once); UNPL(_once) = false) + for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); \ + UNPL(_once); \ + UNPL(_once) = false) /// /// This macro performs forward traversal, starting at index start (inclusive) @@ -151,15 +161,17 @@ /// /// TAGS: Foreach, List, Iteration, Loop, Range, Pointer /// -#define ListForeachPtrInRange(l, var, start, end) \ - for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ - if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head) \ - for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node); \ - UNPL(node) = ListNodeNext(UNPL(node))) \ +#define ListForeachPtrInRange(l, var, start, end) \ + for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ + if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head) \ + for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node); \ + UNPL(node) = ListNodeNext(UNPL(node))) \ for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodeNext(UNPL(node)), ++UNPL(i)) \ if (UNPL(i) >= (start) && (UNPL(node)->data)) \ for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false) \ - for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); UNPL(_once); UNPL(_once) = false) + for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); \ + UNPL(_once); \ + UNPL(_once) = false) /// /// Iterate over each element var of the given list l in reverse, limited to index range [start, end) @@ -178,15 +190,17 @@ /// /// TAGS: Foreach, List, Iteration, Loop, Reverse, Range /// -#define ListForeachReverseInRange(l, var, start, end) \ - for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ - if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail) \ - for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node); \ - UNPL(node) = ListNodePrev(UNPL(node))) \ +#define ListForeachReverseInRange(l, var, start, end) \ + for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ + if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail) \ + for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node); \ + UNPL(node) = ListNodePrev(UNPL(node))) \ for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodePrev(UNPL(node)), ++UNPL(i)) \ if (UNPL(i) >= (start) && (UNPL(node)->data)) \ for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false) \ - for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); UNPL(_once); UNPL(_once) = false) + for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); \ + UNPL(_once); \ + UNPL(_once) = false) /// /// Iterate over each element var (as a pointer) of the given list l in reverse, @@ -206,15 +220,17 @@ /// /// TAGS: Foreach, List, Iteration, Loop, Reverse, Range, Pointer /// -#define ListForeachPtrReverseInRange(l, var, start, end) \ - for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ - if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail) \ - for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node); \ - UNPL(node) = ListNodePrev(UNPL(node))) \ +#define ListForeachPtrReverseInRange(l, var, start, end) \ + for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ + if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail) \ + for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node); \ + UNPL(node) = ListNodePrev(UNPL(node))) \ for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodePrev(UNPL(node)), ++UNPL(i)) \ if (UNPL(i) >= (start) && (UNPL(node)->data)) \ for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false) \ - for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); UNPL(_once); UNPL(_once) = false) + for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); \ + UNPL(_once); \ + UNPL(_once) = false) /// /// Iterate over each element `var` of the given list `l`, with index `idx`. @@ -240,21 +256,22 @@ for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head) \ for (u64 idx = 0, UNPL(pidx) = 0; idx < UNPL(pl)->length;) \ - for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)), \ - *UNPL(next) = NULL; \ + for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)), *UNPL(next) = NULL; \ UNPL(node) && \ (UNPL(next) = \ - (UNPL(pidx) ? (GenericListNode *)get_node_random_access( \ + (UNPL(pidx) ? (GenericListNode *)get_node_random_access( \ GENERIC_LIST(UNPL(pl)), \ GENERIC_LIST_NODE(UNPL(node)), \ UNPL(pidx), \ (i64)(idx) - (i64)UNPL(pidx) \ ) : \ - (GenericListNode *)UNPL(pl)->head)) && \ + (GenericListNode *)UNPL(pl)->head)) && \ UNPL(next) && UNPL(next)->data; \ UNPL(pidx) = ++idx, UNPL(node) = UNPL(next)) \ for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false) \ - for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(next)->data)); UNPL(_once); UNPL(_once) = false) + for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(next)->data)); \ + UNPL(_once); \ + UNPL(_once) = false) /// /// Iterate over each element `var` (as a pointer) of the given list `l`, with index `idx`. @@ -280,17 +297,16 @@ for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head) \ for (u64 idx = 0, UNPL(pidx) = 0; idx < UNPL(pl)->length;) \ - for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)), \ - *UNPL(next) = NULL; \ + for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)), *UNPL(next) = NULL; \ UNPL(node) && \ (UNPL(next) = \ - (UNPL(pidx) ? (GenericListNode *)get_node_random_access( \ + (UNPL(pidx) ? (GenericListNode *)get_node_random_access( \ GENERIC_LIST(UNPL(pl)), \ GENERIC_LIST_NODE(UNPL(node)), \ UNPL(pidx), \ (i64)(idx) - (i64)UNPL(pidx) \ ) : \ - (GenericListNode *)UNPL(pl)->head)) && \ + (GenericListNode *)UNPL(pl)->head)) && \ UNPL(next) && UNPL(next)->data; \ UNPL(pidx) = ++idx, UNPL(node) = UNPL(next)) \ for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false) \ @@ -317,13 +333,16 @@ #define ListForeachReverseIdx(l, var, idx) \ for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail && UNPL(pl)->length > 0) \ - for (u64 idx = UNPL(pl)->length - 1, UNPL(pidx) = UNPL(pl)->length - 1, UNPL(first) = 1, UNPL(user_idx) = 0; \ + for (u64 idx = UNPL(pl)->length - 1, \ + UNPL(pidx) = UNPL(pl)->length - 1, \ + UNPL(first) = 1, \ + UNPL(user_idx) = 0; \ idx < UNPL(pl)->length;) \ - for (GenericListNode * UNPL(node) = (UNPL(first) ? (GenericListNode *)UNPL(pl)->tail : NULL), \ - *UNPL(next) = NULL; \ + for (GenericListNode * UNPL(node) = (UNPL(first) ? (GenericListNode *)UNPL(pl)->tail : NULL), \ + *UNPL(next) = NULL; \ UNPL(node) && idx < UNPL(pl)->length && (UNPL(first) = 0) && \ (UNPL(next) = \ - (UNPL(pidx) != idx ? (GenericListNode *)get_node_random_access( \ + (UNPL(pidx) != idx ? (GenericListNode *)get_node_random_access( \ GENERIC_LIST(UNPL(pl)), \ GENERIC_LIST_NODE(UNPL(node)), \ UNPL(pidx), \ @@ -333,7 +352,9 @@ UNPL(next) && UNPL(next)->data; \ UNPL(node) = UNPL(next), UNPL(pidx) = idx) \ for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false) \ - for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(next)->data)); UNPL(_once); UNPL(_once) = false) \ + for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(next)->data)); \ + UNPL(_once); \ + UNPL(_once) = false) \ for (bool UNPL(_update) = true; UNPL(_update); \ UNPL(_update) = false, \ UNPL(user_idx) = idx, \ @@ -362,10 +383,13 @@ #define ListForeachPtrReverseIdx(l, var, idx) \ for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL) \ if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail && UNPL(pl)->length > 0) \ - for (u64 idx = UNPL(pl)->length - 1, UNPL(pidx) = UNPL(pl)->length - 1, UNPL(first) = 1, UNPL(user_idx) = 0; \ + for (u64 idx = UNPL(pl)->length - 1, \ + UNPL(pidx) = UNPL(pl)->length - 1, \ + UNPL(first) = 1, \ + UNPL(user_idx) = 0; \ idx < UNPL(pl)->length;) \ - for (GenericListNode * UNPL(node) = (UNPL(first) ? (GenericListNode *)UNPL(pl)->tail : NULL), \ - *UNPL(next) = NULL; \ + for (GenericListNode * UNPL(node) = (UNPL(first) ? (GenericListNode *)UNPL(pl)->tail : NULL), \ + *UNPL(next) = NULL; \ UNPL(node) && idx < UNPL(pl)->length && (UNPL(first) = 0) && \ (UNPL(next) = \ (UNPL(pidx) != idx ? get_node_random_access( \ diff --git a/Include/Misra/Std/Container/List/Remove.h b/Include/Misra/Std/Container/List/Remove.h index 16756e8..bb4fb1e 100644 --- a/Include/Misra/Std/Container/List/Remove.h +++ b/Include/Misra/Std/Container/List/Remove.h @@ -20,7 +20,8 @@ /// SUCCESS : Returns `v` on success. /// FAILURE : Returns NULL otherwise. /// -#define ListRemove(l, val, idx) remove_range_list(GENERIC_LIST(l), (val), sizeof(LIST_DATA_TYPE(l)), ((l)->length - 1), 1) +#define ListRemove(l, val, idx) \ + remove_range_list(GENERIC_LIST(l), (val), sizeof(LIST_DATA_TYPE(l)), ((l)->length - 1), 1) /// /// Remove item from the very beginning of list. diff --git a/Source/Misra/Std/Container/List.c b/Source/Misra/Std/Container/List.c index ac5e98a..c6be8ea 100644 --- a/Source/Misra/Std/Container/List.c +++ b/Source/Misra/Std/Container/List.c @@ -215,7 +215,7 @@ void push_arr_list(GenericList *list, u64 item_size, void *arr, u64 count) { LOG_FATAL("invalid arguments."); } - if(!count) { + if (!count) { return; } @@ -224,11 +224,11 @@ void push_arr_list(GenericList *list, u64 item_size, void *arr, u64 count) { while (count--) { GenericListNode *old_tail = list->tail; GenericListNode *new_tail = malloc(sizeof(GenericListNode)); - + if (!new_tail) { LOG_FATAL("Failed to allocate memory for new node"); } - + new_tail->data = malloc(item_size); if (!new_tail->data) { free(new_tail); @@ -242,12 +242,12 @@ void push_arr_list(GenericList *list, u64 item_size, void *arr, u64 count) { new_tail->prev = old_tail; } else { // List is empty - set as head - list->head = new_tail; + list->head = new_tail; new_tail->prev = NULL; } new_tail->next = NULL; - list->tail = new_tail; + list->tail = new_tail; // insert data if (list->copy_init) { From e32de0ed2491bd361cfd409cc4c1db32956b884c Mon Sep 17 00:00:00 2001 From: brightprogrammer Date: Tue, 7 Oct 2025 17:35:36 -0700 Subject: [PATCH 02/15] Update Format Check CI --- .github/workflows/format-check.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml index 3c1dfa1..ed653be 100644 --- a/.github/workflows/format-check.yml +++ b/.github/workflows/format-check.yml @@ -35,11 +35,19 @@ jobs: id: find-files run: | FILES=$(find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) \ + ! -path "./Build*" \ ! -path "./build*" \ ! -path "./builddir*" \ ! -path "./.git/*" \ ! -path "./demangler/*" \ ! -path "./.cache/*" \ + ! -path "./Docs/*" \ + ! -path "./.vs/*" \ + ! -path "./.vscode/*" \ + ! -path "./Make/*" \ + ! -path "./.ccls/*" \ + ! -path "./fuzz-outputs/*" \ + ! -path "./Fuzz/outputs/*" \ -print) echo "Found files:" echo "$FILES" @@ -68,7 +76,7 @@ jobs: echo "Checking $file..." formatted_file="/tmp/formatted/$file" mkdir -p "$(dirname "$formatted_file")" - clang-format "$file" > "$formatted_file" + clang-format -style=file "$file" > "$formatted_file" if ! diff -u "$file" "$formatted_file"; then echo "❌ $file is not properly formatted" @@ -88,9 +96,9 @@ jobs: echo "" echo "💥 Some files are not properly formatted." echo "To fix formatting issues, run:" - echo " clang-format -i " - echo "Or format all files:" - echo " find . -name '*.c' -o -name '*.h' | xargs clang-format -i" + echo " clang-format -i -style=file " + echo "Or format all files using the project script:" + echo " python3 Scripts/clang-format.py" fi exit $EXIT_CODE From bde47a6d94d1cb19b8e86ee75da520c6e420b65d Mon Sep 17 00:00:00 2001 From: brightprogrammer Date: Tue, 7 Oct 2025 17:52:08 -0700 Subject: [PATCH 03/15] Use Dedicated clang-format check GH CI Runner --- .github/workflows/format-check.yml | 92 ++---------------------------- Scripts/clang-format.py | 35 ++++++++++++ 2 files changed, 41 insertions(+), 86 deletions(-) diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml index ed653be..7305e63 100644 --- a/.github/workflows/format-check.yml +++ b/.github/workflows/format-check.yml @@ -16,89 +16,9 @@ jobs: with: submodules: recursive - - name: Install clang-format 20 - run: | - sudo apt-get update - # Install dependencies for HTTPS transport - sudo apt-get install -y software-properties-common wget gnupg lsb-release - # Add LLVM APT repository for Clang 20 - wget https://apt.llvm.org/llvm.sh - chmod +x llvm.sh - sudo ./llvm.sh 20 - # Cleanup - rm llvm.sh - - - name: Check clang-format version - run: clang-format --version - - - name: Find C/C++ files to format - id: find-files - run: | - FILES=$(find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) \ - ! -path "./Build*" \ - ! -path "./build*" \ - ! -path "./builddir*" \ - ! -path "./.git/*" \ - ! -path "./demangler/*" \ - ! -path "./.cache/*" \ - ! -path "./Docs/*" \ - ! -path "./.vs/*" \ - ! -path "./.vscode/*" \ - ! -path "./Make/*" \ - ! -path "./.ccls/*" \ - ! -path "./fuzz-outputs/*" \ - ! -path "./Fuzz/outputs/*" \ - -print) - echo "Found files:" - echo "$FILES" - echo "files<> $GITHUB_OUTPUT - echo "$FILES" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - - name: Check formatting - run: | - EXIT_CODE=0 - FILES="${{ steps.find-files.outputs.files }}" - - if [ -z "$FILES" ]; then - echo "No C/C++ files found to check" - exit 0 - fi - - echo "Checking formatting for files:" - echo "$FILES" - echo "" - - mkdir -p /tmp/formatted - - for file in $FILES; do - if [ -f "$file" ]; then - echo "Checking $file..." - formatted_file="/tmp/formatted/$file" - mkdir -p "$(dirname "$formatted_file")" - clang-format -style=file "$file" > "$formatted_file" - - if ! diff -u "$file" "$formatted_file"; then - echo "❌ $file is not properly formatted" - echo "Expected changes shown above (- original, + formatted)" - echo "" - EXIT_CODE=1 - else - echo "✅ $file is properly formatted" - fi - fi - done - - if [ $EXIT_CODE -eq 0 ]; then - echo "" - echo "🎉 All files are properly formatted!" - else - echo "" - echo "💥 Some files are not properly formatted." - echo "To fix formatting issues, run:" - echo " clang-format -i -style=file " - echo "Or format all files using the project script:" - echo " python3 Scripts/clang-format.py" - fi - - exit $EXIT_CODE + - name: Run clang-format style check for C/C++/Protobuf programs + uses: jidicula/clang-format-action@v4.15.0 + with: + clang-format-version: '20' + check-path: '.' + exclude-regex: '(Build|build|builddir|\.git|demangler|\.cache|Docs|\.vs|\.vscode|Make|\.ccls|fuzz-outputs|Fuzz/outputs)' diff --git a/Scripts/clang-format.py b/Scripts/clang-format.py index 4a52f22..3c91cd0 100644 --- a/Scripts/clang-format.py +++ b/Scripts/clang-format.py @@ -6,14 +6,49 @@ # List of file extensions for C and C++ source files C_CPP_EXTENSIONS = {'.c', '.cpp', '.h', '.hpp', '.cc', '.cxx', '.hxx'} +def check_clang_format_version(clang_format_path): + """Check if clang-format is version 20 or higher.""" + try: + result = subprocess.run([clang_format_path, '--version'], capture_output=True, text=True, check=True) + version_output = result.stdout.strip() + print(f"Found clang-format: {version_output}") + + # Extract version number from output like "clang-format version 20.1.8" + import re + version_match = re.search(r'version (\d+)\.(\d+)\.(\d+)', version_output) + if version_match: + major_version = int(version_match.group(1)) + if major_version < 20: + print(f"❌ Error: clang-format version {major_version} is not supported.") + print("This project requires clang-format version 20 or higher.") + print("\nTo install clang-format 20:") + print(" Ubuntu/Debian: sudo apt-get install clang-format-20") + print(" macOS: brew install llvm@20") + print(" Or download from: https://releases.llvm.org/download.html") + print("\nAfter installation, ensure clang-format-20 is in your PATH or create a symlink:") + print(" sudo ln -sf /usr/bin/clang-format-20 /usr/bin/clang-format") + exit(1) + else: + print(f"✅ clang-format version {major_version} is supported.") + else: + print("⚠️ Warning: Could not determine clang-format version, proceeding anyway.") + except subprocess.CalledProcessError as e: + print(f"Error checking clang-format version: {e}") + exit(1) + def find_clang_format(): """Find the path to the clang-format executable.""" clang_format_path = shutil.which('clang-format') # Works on both Windows and POSIX systems if clang_format_path: print(f"Using clang-format at: {clang_format_path}") + check_clang_format_version(clang_format_path) return clang_format_path else: print("Error: clang-format not found. Please ensure clang-format is installed and in your PATH.") + print("\nTo install clang-format 20:") + print(" Ubuntu/Debian: sudo apt-get install clang-format-20") + print(" macOS: brew install llvm@20") + print(" Or download from: https://releases.llvm.org/download.html") exit(1) def find_clang_format_dir(start_dir): From 3840821328857d668a7677153a25652f5347e0db Mon Sep 17 00:00:00 2001 From: brightprogrammer Date: Tue, 7 Oct 2025 22:02:26 -0700 Subject: [PATCH 04/15] Use Already Working Workflow --- .github/workflows/format-check.yml | 36 ++--- Scripts/clang-format.py | 244 +++++++++++++++-------------- 2 files changed, 141 insertions(+), 139 deletions(-) diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml index 7305e63..8601184 100644 --- a/.github/workflows/format-check.yml +++ b/.github/workflows/format-check.yml @@ -1,24 +1,24 @@ -name: Format Check +# Snagged from github.com/rizinorg/rizin +# Thanks for having a reliable workflow! +name: "Pull Request Labeler" on: - push: - branches: [ main, master ] - pull_request: - branches: [ main, master ] +- pull_request_target -jobs: - format-check: - name: Check code formatting with clang-format - runs-on: ubuntu-latest +# Automatically cancel any previous workflow on new push. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true +jobs: + triage: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Run clang-format style check for C/C++/Protobuf programs - uses: jidicula/clang-format-action@v4.15.0 + - uses: actions/checkout@v5 + - uses: actions/labeler@v6 with: - clang-format-version: '20' - check-path: '.' - exclude-regex: '(Build|build|builddir|\.git|demangler|\.cache|Docs|\.vs|\.vscode|Make|\.ccls|fuzz-outputs|Fuzz/outputs)' + repo-token: "${{ secrets.GITHUB_TOKEN }}" + \ No newline at end of file diff --git a/Scripts/clang-format.py b/Scripts/clang-format.py index 3c91cd0..8c65753 100644 --- a/Scripts/clang-format.py +++ b/Scripts/clang-format.py @@ -1,125 +1,127 @@ -import os +#!/usr/bin/env python3 +# +# SPDX-FileCopyrightText: 2021 Anton Kochkov +# SPDX-License-Identifier: LGPL-3.0-only + +# Snagged from github.com/rizinorg/rizin +# Thanks for having a reliable script and a workflow! + +import argparse +import glob +import itertools import subprocess -import shutil -from pathlib import Path - -# List of file extensions for C and C++ source files -C_CPP_EXTENSIONS = {'.c', '.cpp', '.h', '.hpp', '.cc', '.cxx', '.hxx'} - -def check_clang_format_version(clang_format_path): - """Check if clang-format is version 20 or higher.""" - try: - result = subprocess.run([clang_format_path, '--version'], capture_output=True, text=True, check=True) - version_output = result.stdout.strip() - print(f"Found clang-format: {version_output}") - - # Extract version number from output like "clang-format version 20.1.8" - import re - version_match = re.search(r'version (\d+)\.(\d+)\.(\d+)', version_output) - if version_match: - major_version = int(version_match.group(1)) - if major_version < 20: - print(f"❌ Error: clang-format version {major_version} is not supported.") - print("This project requires clang-format version 20 or higher.") - print("\nTo install clang-format 20:") - print(" Ubuntu/Debian: sudo apt-get install clang-format-20") - print(" macOS: brew install llvm@20") - print(" Or download from: https://releases.llvm.org/download.html") - print("\nAfter installation, ensure clang-format-20 is in your PATH or create a symlink:") - print(" sudo ln -sf /usr/bin/clang-format-20 /usr/bin/clang-format") - exit(1) - else: - print(f"✅ clang-format version {major_version} is supported.") - else: - print("⚠️ Warning: Could not determine clang-format version, proceeding anyway.") - except subprocess.CalledProcessError as e: - print(f"Error checking clang-format version: {e}") - exit(1) - -def find_clang_format(): - """Find the path to the clang-format executable.""" - clang_format_path = shutil.which('clang-format') # Works on both Windows and POSIX systems - if clang_format_path: - print(f"Using clang-format at: {clang_format_path}") - check_clang_format_version(clang_format_path) - return clang_format_path +import sys + +from git import Repo + +dirlist = [ + "Source", + "Include", + "Bin", + "Tests", + "Fuzz", +] + +skiplist = [] + +patterns = ["*.c", "*.cpp", "*.h", "*.hpp", "*.inc"] + +def should_scan(filename): + return any(directory in filename for directory in dirlist) and any( + pattern[1:] in filename for pattern in patterns + ) + + +def skip(filename): + return any(skipfile in filename for skipfile in skiplist) + + +def get_matching_files(): + for directory, pattern in itertools.product(dirlist, patterns): + for filename in glob.iglob(directory + "/**/" + pattern, recursive=True): + if not skip(filename): + yield filename + + +def get_edited_files(args): + repo = Repo() + + for diff in repo.index.diff(args.diff): + filename = diff.a_path + if should_scan(filename) and not skip(filename): + yield filename + + +def build_command(clangformat, check, filenames, verbose): + cmd = [clangformat, "--style=file"] + if verbose: + cmd += ["--verbose"] + if check: + cmd += ["--Werror", "--dry-run"] else: - print("Error: clang-format not found. Please ensure clang-format is installed and in your PATH.") - print("\nTo install clang-format 20:") - print(" Ubuntu/Debian: sudo apt-get install clang-format-20") - print(" macOS: brew install llvm@20") - print(" Or download from: https://releases.llvm.org/download.html") - exit(1) - -def find_clang_format_dir(start_dir): - """Find the nearest directory containing a .clang-format file.""" - current_dir = Path(start_dir).resolve() - - while current_dir != current_dir.parent: - clang_format_path = current_dir / ".clang-format" - if clang_format_path.exists(): - return clang_format_path - current_dir = current_dir.parent - - return None # No .clang-format found up to the root - -def parse_gitignore(root_dir): - """Parse the .gitignore file and return a list of patterns to ignore.""" - gitignore_path = Path(root_dir) / '.gitignore' - ignored_paths = set() - - if gitignore_path.exists(): - with open(gitignore_path, 'r') as f: - lines = f.readlines() - for line in lines: - line = line.strip() - if line and not line.startswith('#'): # Skip comments and empty lines - ignored_paths.add(line) - - return ignored_paths - -def is_ignored(file_path, ignored_paths): - """Check if the file or directory should be ignored based on .gitignore patterns.""" - relative_path = str(file_path.relative_to(os.getcwd())) - - for pattern in ignored_paths: - if relative_path.startswith(pattern): # This assumes a simple matching, ignoring more complex patterns - return True - return False - -def format_file(file_path, clang_format_path): - """Apply clang-format to the file using the specified .clang-format.""" - try: - # Ensure the file path is valid and belongs to C/C++ files - if file_path.suffix.lower() in C_CPP_EXTENSIONS: - subprocess.run([clang_format_path, '-i', '-style=file', str(file_path)], check=True) - except subprocess.CalledProcessError as e: - print(f"Error formatting {file_path}: {e}") - -def traverse_and_format(root_dir, clang_format_path, ignored_paths): - """Traverse all files in the directory tree and apply clang-format.""" - for root, dirs, files in os.walk(root_dir): - # Modify dirs in-place to ignore certain directories (skip traversal in them) - dirs[:] = [d for d in dirs if not is_ignored(Path(root) / d, ignored_paths)] - - for file in files: - file_path = Path(root) / file - if is_ignored(file_path, ignored_paths): - continue # Skip files that are ignored - - clang_format_dir = find_clang_format_dir(file_path) - if clang_format_dir: - format_file(file_path, clang_format_path) + cmd += ["-i"] + return cmd + filenames + + +def format_files(args, files): + if len(files) == 0: + print("No C files to format.") + sys.exit(0) + cmd = build_command(args.clang_format, args.check, files, args.verbose) + r = subprocess.run(cmd, check=False) + sys.exit(r.returncode) + + +def get_file(args): + filename = args.file + if should_scan(filename) and not skip(filename): + return [filename] + + return [] + + +def get_files(args): + if args.diff: + return get_edited_files(args) + + if args.file: + return get_file(args) + + return get_matching_files() + + +def process(args): + files = get_files(args) + format_files(args, list(files)) + + +def parse(): + parser = argparse.ArgumentParser(description="Clang format the rizin project") + + parser.add_argument( + "-C", "--clang-format", default="clang-format", help="path of clang-format" + ) + parser.add_argument( + "-c", "--check", action="store_true", help="enable the check mode" + ) + parser.add_argument( + "-v", "--verbose", action="store_true", help="use verbose output" + ) + parser.add_argument("-f", "--file", help="formats (or checks) only the given file") + parser.add_argument( + "-d", + "--diff", + type=str, + default=None, + help="format all modified file related to branch", + ) + return parser.parse_args() + + +def main(): + args = parse() + process(args) + if __name__ == "__main__": - # Find the clang-format executable - clang_format_path = find_clang_format() - - # Get the current working directory (the directory from which the script is executed) - root_directory = os.getcwd() - - # Parse the .gitignore file - ignored_paths = parse_gitignore(root_directory) - - # Traverse the project directory and format files - traverse_and_format(root_directory, clang_format_path, ignored_paths) + main() \ No newline at end of file From 3d1112683435751072bec42f294bad7d68099014 Mon Sep 17 00:00:00 2001 From: brightprogrammer Date: Tue, 7 Oct 2025 22:06:03 -0700 Subject: [PATCH 05/15] Doitagain --- .github/workflows/format-check.yml | 8 ++++++-- .github/workflows/hugo.yml | 2 +- .github/workflows/test-linux.yml | 5 +++++ .github/workflows/test-macos.yml | 5 +++++ .github/workflows/test-windows-llvm.yml | 7 +++++++ .github/workflows/test-windows-msvc.yml | 5 +++++ 6 files changed, 29 insertions(+), 3 deletions(-) diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml index 8601184..cba1d74 100644 --- a/.github/workflows/format-check.yml +++ b/.github/workflows/format-check.yml @@ -1,9 +1,13 @@ # Snagged from github.com/rizinorg/rizin # Thanks for having a reliable workflow! -name: "Pull Request Labeler" +name: "Format Check" + on: -- pull_request_target + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] # Automatically cancel any previous workflow on new push. concurrency: diff --git a/.github/workflows/hugo.yml b/.github/workflows/hugo.yml index e4f34f2..6ee6a4f 100644 --- a/.github/workflows/hugo.yml +++ b/.github/workflows/hugo.yml @@ -12,7 +12,7 @@ permissions: concurrency: group: "pages" - cancel-in-progress: false + cancel-in-progress: true defaults: run: diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index ad39a65..3f70c7b 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -6,6 +6,11 @@ on: pull_request: branches: [ main, master ] +# Automatically cancel any previous workflow on new push. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true + jobs: build-and-test: name: Build and Test on Ubuntu diff --git a/.github/workflows/test-macos.yml b/.github/workflows/test-macos.yml index b05acea..93001a9 100644 --- a/.github/workflows/test-macos.yml +++ b/.github/workflows/test-macos.yml @@ -6,6 +6,11 @@ on: pull_request: branches: [ main, master ] +# Automatically cancel any previous workflow on new push. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true + jobs: build-and-test: name: Build and Test on macOS diff --git a/.github/workflows/test-windows-llvm.yml b/.github/workflows/test-windows-llvm.yml index 7070648..37416d1 100644 --- a/.github/workflows/test-windows-llvm.yml +++ b/.github/workflows/test-windows-llvm.yml @@ -1,9 +1,16 @@ name: Windows LLVM Build + on: push: branches: [ master ] pull_request: branches: [ master ] + +# Automatically cancel any previous workflow on new push. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true + jobs: build-and-test: name: Build and Test on Windows with LLVM diff --git a/.github/workflows/test-windows-msvc.yml b/.github/workflows/test-windows-msvc.yml index a6f5496..c15eb24 100644 --- a/.github/workflows/test-windows-msvc.yml +++ b/.github/workflows/test-windows-msvc.yml @@ -6,6 +6,11 @@ on: pull_request: branches: [ master ] +# Automatically cancel any previous workflow on new push. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true + jobs: build-and-test: name: Build and Test on Windows From 8f31369972f44ee47d620242eb74b540cfc6d75f Mon Sep 17 00:00:00 2001 From: brightprogrammer Date: Tue, 7 Oct 2025 22:07:15 -0700 Subject: [PATCH 06/15] Doitagain --- .github/workflows/format-check.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml index cba1d74..a123b66 100644 --- a/.github/workflows/format-check.yml +++ b/.github/workflows/format-check.yml @@ -22,7 +22,4 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v5 - - uses: actions/labeler@v6 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file From 2e094c62a437e33a7cdbf8b44fd1155f3348ac48 Mon Sep 17 00:00:00 2001 From: brightprogrammer Date: Tue, 7 Oct 2025 22:09:18 -0700 Subject: [PATCH 07/15] Got Incorrect Workflow Earlier --- .github/workflows/format-check.yml | 162 +++++++++++++++++++++++++++-- 1 file changed, 154 insertions(+), 8 deletions(-) diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml index a123b66..8e457c3 100644 --- a/.github/workflows/format-check.yml +++ b/.github/workflows/format-check.yml @@ -1,13 +1,16 @@ # Snagged from github.com/rizinorg/rizin # Thanks for having a reliable workflow! -name: "Format Check" +name: "Mixed linter and checks" on: push: - branches: [ main, master ] + branches: + - 'master' + - 'dev' + - 'stable' + - 'container-*' pull_request: - branches: [ main, master ] # Automatically cancel any previous workflow on new push. concurrency: @@ -15,11 +18,154 @@ concurrency: cancel-in-progress: true jobs: - triage: - permissions: - contents: read - pull-requests: write + changes: runs-on: ubuntu-24.04 + outputs: + yaml: ${{ steps.filter.outputs.yaml }} + clang-format: ${{ steps.filter.outputs.clang-format }} + bindgen-linter: ${{ steps.filter.outputs.bindgen-linter }} + prettier: ${{ steps.filter.outputs.prettier }} + python: ${{ steps.filter.outputs.python }} steps: - uses: actions/checkout@v5 - \ No newline at end of file + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + yaml: + - '**.yml' + - '**.yaml' + - '.github/workflows/linter.yml' + bindgen-linter: + - '**.c' + - '**.h' + - '**.inc' + - '.github/workflows/linter.yml' + clang-format: + - '**.c' + - '**.h' + - '**.in' + - '**.inc' + - '.github/workflows/linter.yml' + - 'sys/clang-format.py' + - '.clang-format' + prettier: + - '**.js' + - '.github/workflows/linter.yml' + python: + - '**.py' + - '.github/workflows/linter.yml' + - '.pylintrc' + + cmd_descs_yaml_check: + needs: changes + runs-on: ubuntu-24.04 + if: ${{ needs.changes.outputs.yaml == 'true' }} + steps: + - uses: actions/checkout@v5 + - name: Install tools + run: sudo apt-get install yamllint python3-yaml + - name: Check YamlLint + run: | + yamllint -d "{rules: {line-length: {max: 120}}}" ./librz/core/cmd_descs/*.yaml + - name: Check sync between yaml and C/H files + run: | + ./librz/core/cmd_descs/cmd_descs_generate.py --output-dir /tmp ./librz/core/cmd_descs/*.yaml + diff /tmp/cmd_descs.c ./librz/core/cmd_descs/cmd_descs.c && diff /tmp/cmd_descs.h ./librz/core/cmd_descs/cmd_descs.h + + bindgen-linter: + needs: changes + runs-on: ubuntu-24.04 + if: ${{ needs.changes.outputs.bindgen-linter == 'true' }} + steps: + - name: Checkout rizin + uses: actions/checkout@v5 + with: + path: rizin + - name: Checkout rz-bindgen (stable) + if: github.ref == 'refs/heads/stable' + run: git clone -b stable https://github.com/rizinorg/rz-bindgen + - name: Checkout rz-bindgen (dev) + if: github.ref != 'refs/heads/stable' + run: git clone -b dev https://github.com/rizinorg/rz-bindgen + - name: Install dependencies + run: | + sudo pip install meson ninja + sudo apt update + sudo apt install libclang-14-dev + - name: Build rizin + working-directory: rizin + run: | + meson setup build + ninja -C build + - name: Run rz-bindgen linter + run: | + python3 rz-bindgen/src/lint.py \ + --clang-path "/usr/lib/llvm-14/lib" \ + --clang-args "-resource-dir=$(clang -print-resource-dir) " \ + --rizin-path rizin + + clang-format: + needs: changes + runs-on: ubuntu-24.04 + if: ${{ needs.changes.outputs.clang-format == 'true' }} + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Install clang-format-16 + run: sudo apt --assume-yes install clang-format-16 + + - 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-16 160 + clang-format --version + python sys/clang-format.py --check --verbose + + prettier: + needs: changes + runs-on: ubuntu-24.04 + if: ${{ needs.changes.outputs.prettier == 'true' }} + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Install prettier + run: | + sudo apt --assume-yes install npm + npm install prettier + + - name: Run prettier + run: find . -name "*.js" | grep -v "bindings/node/index.js\|subprojects/tree-sitter" | xargs npx prettier --print-width 120 --check + + python: + needs: changes + runs-on: ubuntu-24.04 + if: ${{ needs.changes.outputs.python == 'true' }} + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Install pylint, black, isort + run: pip install pylint black isort + + - name: Run black + run: | + export PATH=${HOME}/Library/Python/3.9/bin:${HOME}/Library/Python/3.10/bin:${HOME}/.local/bin:${PATH} + find . -name "*.py" | grep -v "subprojects" | xargs black --check + + - name: Run pylint + run: | + export PATH=${HOME}/Library/Python/3.9/bin:${HOME}/Library/Python/3.10/bin:${HOME}/.local/bin:${PATH} + find . -name "*.py" | grep -v "subprojects" | grep -v "librz/bin/format/xnu/scripts/" | xargs -I % pylint --disable=R1737 '%' + + licenses: + runs-on: ubuntu-24.04 + steps: + - name: Checkout repository + uses: actions/checkout@v5 + - name: REUSE Compliance Check + uses: fsfe/reuse-action@v5 \ No newline at end of file From 3e70813e74d6cd382664df7954c874ccde96b2f7 Mon Sep 17 00:00:00 2001 From: brightprogrammer Date: Tue, 7 Oct 2025 22:12:32 -0700 Subject: [PATCH 08/15] Final Try :cry: --- .github/workflows/format-check.yml | 175 ++++++++++------------------- .github/workflows/fuzz.yml | 5 + 2 files changed, 63 insertions(+), 117 deletions(-) diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml index 8e457c3..7c35c9d 100644 --- a/.github/workflows/format-check.yml +++ b/.github/workflows/format-check.yml @@ -1,15 +1,12 @@ # Snagged from github.com/rizinorg/rizin # Thanks for having a reliable workflow! -name: "Mixed linter and checks" +name: "Format Check" on: push: branches: - 'master' - - 'dev' - - 'stable' - - 'container-*' pull_request: # Automatically cancel any previous workflow on new push. @@ -21,26 +18,26 @@ jobs: changes: runs-on: ubuntu-24.04 outputs: - yaml: ${{ steps.filter.outputs.yaml }} +# yaml: ${{ steps.filter.outputs.yaml }} clang-format: ${{ steps.filter.outputs.clang-format }} - bindgen-linter: ${{ steps.filter.outputs.bindgen-linter }} - prettier: ${{ steps.filter.outputs.prettier }} - python: ${{ steps.filter.outputs.python }} +# bindgen-linter: ${{ steps.filter.outputs.bindgen-linter }} +# prettier: ${{ steps.filter.outputs.prettier }} +# python: ${{ steps.filter.outputs.python }} steps: - uses: actions/checkout@v5 - uses: dorny/paths-filter@v3 id: filter with: filters: | - yaml: - - '**.yml' - - '**.yaml' - - '.github/workflows/linter.yml' - bindgen-linter: - - '**.c' - - '**.h' - - '**.inc' - - '.github/workflows/linter.yml' +# yaml: +# - '**.yml' +# - '**.yaml' +# - '.github/workflows/linter.yml' +# bindgen-linter: +# - '**.c' +# - '**.h' +# - '**.inc' +# - '.github/workflows/linter.yml' clang-format: - '**.c' - '**.h' @@ -49,61 +46,13 @@ jobs: - '.github/workflows/linter.yml' - 'sys/clang-format.py' - '.clang-format' - prettier: - - '**.js' - - '.github/workflows/linter.yml' - python: - - '**.py' - - '.github/workflows/linter.yml' - - '.pylintrc' - - cmd_descs_yaml_check: - needs: changes - runs-on: ubuntu-24.04 - if: ${{ needs.changes.outputs.yaml == 'true' }} - steps: - - uses: actions/checkout@v5 - - name: Install tools - run: sudo apt-get install yamllint python3-yaml - - name: Check YamlLint - run: | - yamllint -d "{rules: {line-length: {max: 120}}}" ./librz/core/cmd_descs/*.yaml - - name: Check sync between yaml and C/H files - run: | - ./librz/core/cmd_descs/cmd_descs_generate.py --output-dir /tmp ./librz/core/cmd_descs/*.yaml - diff /tmp/cmd_descs.c ./librz/core/cmd_descs/cmd_descs.c && diff /tmp/cmd_descs.h ./librz/core/cmd_descs/cmd_descs.h - - bindgen-linter: - needs: changes - runs-on: ubuntu-24.04 - if: ${{ needs.changes.outputs.bindgen-linter == 'true' }} - steps: - - name: Checkout rizin - uses: actions/checkout@v5 - with: - path: rizin - - name: Checkout rz-bindgen (stable) - if: github.ref == 'refs/heads/stable' - run: git clone -b stable https://github.com/rizinorg/rz-bindgen - - name: Checkout rz-bindgen (dev) - if: github.ref != 'refs/heads/stable' - run: git clone -b dev https://github.com/rizinorg/rz-bindgen - - name: Install dependencies - run: | - sudo pip install meson ninja - sudo apt update - sudo apt install libclang-14-dev - - name: Build rizin - working-directory: rizin - run: | - meson setup build - ninja -C build - - name: Run rz-bindgen linter - run: | - python3 rz-bindgen/src/lint.py \ - --clang-path "/usr/lib/llvm-14/lib" \ - --clang-args "-resource-dir=$(clang -print-resource-dir) " \ - --rizin-path rizin +# prettier: +# - '**.js' +# - '.github/workflows/linter.yml' +# python: +# - '**.py' +# - '.github/workflows/linter.yml' +# - '.pylintrc' clang-format: needs: changes @@ -124,48 +73,40 @@ jobs: sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-16 160 clang-format --version python sys/clang-format.py --check --verbose - - prettier: - needs: changes - runs-on: ubuntu-24.04 - if: ${{ needs.changes.outputs.prettier == 'true' }} - steps: - - name: Checkout repository - uses: actions/checkout@v5 - - - name: Install prettier - run: | - sudo apt --assume-yes install npm - npm install prettier - - - name: Run prettier - run: find . -name "*.js" | grep -v "bindings/node/index.js\|subprojects/tree-sitter" | xargs npx prettier --print-width 120 --check - - python: - needs: changes - runs-on: ubuntu-24.04 - if: ${{ needs.changes.outputs.python == 'true' }} - steps: - - name: Checkout repository - uses: actions/checkout@v5 - - - name: Install pylint, black, isort - run: pip install pylint black isort - - - name: Run black - run: | - export PATH=${HOME}/Library/Python/3.9/bin:${HOME}/Library/Python/3.10/bin:${HOME}/.local/bin:${PATH} - find . -name "*.py" | grep -v "subprojects" | xargs black --check - - - name: Run pylint - run: | - export PATH=${HOME}/Library/Python/3.9/bin:${HOME}/Library/Python/3.10/bin:${HOME}/.local/bin:${PATH} - find . -name "*.py" | grep -v "subprojects" | grep -v "librz/bin/format/xnu/scripts/" | xargs -I % pylint --disable=R1737 '%' - - licenses: - runs-on: ubuntu-24.04 - steps: - - name: Checkout repository - uses: actions/checkout@v5 - - name: REUSE Compliance Check - uses: fsfe/reuse-action@v5 \ No newline at end of file + +# prettier: +# needs: changes +# runs-on: ubuntu-24.04 +# if: ${{ needs.changes.outputs.prettier == 'true' }} +# steps: +# - name: Checkout repository +# uses: actions/checkout@v5 +# +# - name: Install prettier +# run: | +# sudo apt --assume-yes install npm +# npm install prettier +# +# - name: Run prettier +# run: find . -name "*.js" | grep -v "bindings/node/index.js\|subprojects/tree-sitter" | xargs npx prettier --print-width 120 --check +# +# python: +# needs: changes +# runs-on: ubuntu-24.04 +# if: ${{ needs.changes.outputs.python == 'true' }} +# steps: +# - name: Checkout repository +# uses: actions/checkout@v5 +# +# - name: Install pylint, black, isort +# run: pip install pylint black isort +# +# - name: Run black +# run: | +# export PATH=${HOME}/Library/Python/3.9/bin:${HOME}/Library/Python/3.10/bin:${HOME}/.local/bin:${PATH} +# find . -name "*.py" | grep -v "subprojects" | xargs black --check +# +# - name: Run pylint +# run: | +# export PATH=${HOME}/Library/Python/3.9/bin:${HOME}/Library/Python/3.10/bin:${HOME}/.local/bin:${PATH} +# find . -name "*.py" | grep -v "subprojects" | grep -v "librz/bin/format/xnu/scripts/" | xargs -I % pylint --disable=R1737 '%' \ No newline at end of file diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index ab3d1b6..674c090 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -10,6 +10,11 @@ on: - cron: '0 2 * * *' workflow_dispatch: +# Automatically cancel any previous workflow on new push. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true + jobs: fuzz: runs-on: ubuntu-latest From 4fed87e7a569e94c35570497a62ca639a907c0ae Mon Sep 17 00:00:00 2001 From: brightprogrammer Date: Tue, 7 Oct 2025 22:14:31 -0700 Subject: [PATCH 09/15] Serious Final Try :cry: --- .github/workflows/format-check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml index 7c35c9d..6159570 100644 --- a/.github/workflows/format-check.yml +++ b/.github/workflows/format-check.yml @@ -8,6 +8,7 @@ on: branches: - 'master' pull_request: + - 'master' # Automatically cancel any previous workflow on new push. concurrency: From f258affb8a4fbe74e1659433dbce534565c73e3b Mon Sep 17 00:00:00 2001 From: brightprogrammer Date: Tue, 7 Oct 2025 22:19:08 -0700 Subject: [PATCH 10/15] What Would Happen To Me Without AI --- .github/workflows/format-check.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml index 6159570..8bd37b7 100644 --- a/.github/workflows/format-check.yml +++ b/.github/workflows/format-check.yml @@ -8,6 +8,7 @@ on: branches: - 'master' pull_request: + branches: - 'master' # Automatically cancel any previous workflow on new push. @@ -45,7 +46,7 @@ jobs: - '**.in' - '**.inc' - '.github/workflows/linter.yml' - - 'sys/clang-format.py' + - 'Scripts/clang-format.py' - '.clang-format' # prettier: # - '**.js' @@ -66,14 +67,16 @@ jobs: - name: Install clang-format-16 run: sudo apt --assume-yes install clang-format-16 - - name: Install gitpython - run: sudo pip install gitpython + - name: Install Python3 and gitpython + run: | + sudo apt --assume-yes install python3-pip + sudo pip3 install gitpython - name: Run clang-format run: | sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-16 160 clang-format --version - python sys/clang-format.py --check --verbose + python3 Scripts/clang-format.py --check --verbose # prettier: # needs: changes From 211799a49f4c20aaf077f674be237bb97fc54083 Mon Sep 17 00:00:00 2001 From: brightprogrammer Date: Tue, 7 Oct 2025 22:21:15 -0700 Subject: [PATCH 11/15] Fix YAML Syntax Error --- .github/workflows/format-check.yml | 59 +----------------------------- 1 file changed, 1 insertion(+), 58 deletions(-) diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml index 8bd37b7..7643989 100644 --- a/.github/workflows/format-check.yml +++ b/.github/workflows/format-check.yml @@ -20,26 +20,13 @@ jobs: changes: runs-on: ubuntu-24.04 outputs: -# yaml: ${{ steps.filter.outputs.yaml }} clang-format: ${{ steps.filter.outputs.clang-format }} -# bindgen-linter: ${{ steps.filter.outputs.bindgen-linter }} -# prettier: ${{ steps.filter.outputs.prettier }} -# python: ${{ steps.filter.outputs.python }} steps: - uses: actions/checkout@v5 - uses: dorny/paths-filter@v3 id: filter with: filters: | -# yaml: -# - '**.yml' -# - '**.yaml' -# - '.github/workflows/linter.yml' -# bindgen-linter: -# - '**.c' -# - '**.h' -# - '**.inc' -# - '.github/workflows/linter.yml' clang-format: - '**.c' - '**.h' @@ -48,13 +35,6 @@ jobs: - '.github/workflows/linter.yml' - 'Scripts/clang-format.py' - '.clang-format' -# prettier: -# - '**.js' -# - '.github/workflows/linter.yml' -# python: -# - '**.py' -# - '.github/workflows/linter.yml' -# - '.pylintrc' clang-format: needs: changes @@ -76,41 +56,4 @@ jobs: run: | sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-16 160 clang-format --version - python3 Scripts/clang-format.py --check --verbose - -# prettier: -# needs: changes -# runs-on: ubuntu-24.04 -# if: ${{ needs.changes.outputs.prettier == 'true' }} -# steps: -# - name: Checkout repository -# uses: actions/checkout@v5 -# -# - name: Install prettier -# run: | -# sudo apt --assume-yes install npm -# npm install prettier -# -# - name: Run prettier -# run: find . -name "*.js" | grep -v "bindings/node/index.js\|subprojects/tree-sitter" | xargs npx prettier --print-width 120 --check -# -# python: -# needs: changes -# runs-on: ubuntu-24.04 -# if: ${{ needs.changes.outputs.python == 'true' }} -# steps: -# - name: Checkout repository -# uses: actions/checkout@v5 -# -# - name: Install pylint, black, isort -# run: pip install pylint black isort -# -# - name: Run black -# run: | -# export PATH=${HOME}/Library/Python/3.9/bin:${HOME}/Library/Python/3.10/bin:${HOME}/.local/bin:${PATH} -# find . -name "*.py" | grep -v "subprojects" | xargs black --check -# -# - name: Run pylint -# run: | -# export PATH=${HOME}/Library/Python/3.9/bin:${HOME}/Library/Python/3.10/bin:${HOME}/.local/bin:${PATH} -# find . -name "*.py" | grep -v "subprojects" | grep -v "librz/bin/format/xnu/scripts/" | xargs -I % pylint --disable=R1737 '%' \ No newline at end of file + python3 Scripts/clang-format.py --check --verbose \ No newline at end of file From 6c3135d600b08630690e09fea4c732b268a326ec Mon Sep 17 00:00:00 2001 From: brightprogrammer Date: Tue, 7 Oct 2025 22:24:00 -0700 Subject: [PATCH 12/15] .clang-format file fix --- .clang-format | 1 - 1 file changed, 1 deletion(-) diff --git a/.clang-format b/.clang-format index 20bf2b2..a3273db 100644 --- a/.clang-format +++ b/.clang-format @@ -96,7 +96,6 @@ PointerAlignment: Right QualifierAlignment: Leave ReferenceAlignment: Right ReflowComments: true -RemoveParentheses: Leave SortIncludes: Never SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false From e642d03defe26cd0d4433efb042c17ab7978946d Mon Sep 17 00:00:00 2001 From: brightprogrammer Date: Tue, 7 Oct 2025 22:31:52 -0700 Subject: [PATCH 13/15] .clang-format file fix --- .clang-format | 327 ++++++++++++++++++++++++++++++++-------- Scripts/clang-format.py | 2 +- 2 files changed, 261 insertions(+), 68 deletions(-) diff --git a/.clang-format b/.clang-format index a3273db..e860dee 100644 --- a/.clang-format +++ b/.clang-format @@ -1,130 +1,314 @@ --- -BasedOnStyle: Google -AlignConsecutiveBitFields: - Enabled: true - AcrossEmptyLines: false - AcrossComments: false - AlignCompound: true - PadOperators: true +Language: Cpp +AccessModifierOffset: -1 AlignAfterOpenBracket: BlockIndent AlignArrayOfStructures: Right AlignConsecutiveAssignments: - Enabled: true + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: true + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: true AcrossEmptyLines: false - AcrossComments: false - PadOperators: true - AlignCompound: true + AcrossComments: false + AlignCompound: true + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: true AlignConsecutiveDeclarations: - Enabled: true + Enabled: true AcrossEmptyLines: false - AcrossComments: false - AlignCompound: true - PadOperators: true -AlignOperands: AlignAfterOperator -AlignEscapedNewlines: Right + AcrossComments: false + AlignCompound: true + AlignFunctionDeclarations: true + AlignFunctionPointers: false + PadOperators: true AlignConsecutiveMacros: - Enabled: true + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: true + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveTableGenBreakingDAGArgColons: + Enabled: false AcrossEmptyLines: false - AcrossComments: false - AlignCompound: true - PadOperators: true -AlignConsecutiveShortCaseStatements: - Enabled: true + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenCondOperatorColons: + Enabled: false AcrossEmptyLines: false - AcrossComments: false - AlignCaseColons: true + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenDefinitionColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignEscapedNewlines: Right +AlignOperands: AlignAfterOperator AlignTrailingComments: - Kind: Always - OverEmptyLines: 2 + Kind: Always + OverEmptyLines: 2 AllowAllArgumentsOnNextLine: false AllowAllParametersOfDeclarationOnNextLine: false +AllowBreakBeforeNoexceptSpecifier: Never AllowShortBlocksOnASingleLine: Empty -AllowShortFunctionsOnASingleLine: Empty +AllowShortCaseExpressionOnASingleLine: true AllowShortCaseLabelsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: true AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Empty AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterReturnType: None +AllowShortNamespacesOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakBeforeMultilineStrings: true AttributeMacros: - FORCE_INLINE - PACKED BinPackArguments: false -BinPackParameters: false +BinPackParameters: OnePerLine +BitFieldColonSpacing: Both +BracedInitializerIndentWidth: 4 BraceWrapping: - AfterCaseLabel: false - AfterClass: false + AfterCaseLabel: false + AfterClass: false AfterControlStatement: Never - AfterEnum: false - AfterFunction: false - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false + AfterEnum: false AfterExternBlock: false - BeforeElse: false - BeforeWhile: false - IndentBraces: true -BracedInitializerIndentWidth: 4 -BreakArrays: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAdjacentStringLiterals: true +BreakAfterAttributes: Leave +BreakAfterJavaFieldAnnotations: false +BreakAfterReturnType: None +BreakArrays: false BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: Always BreakBeforeBraces: Attach BreakBeforeInlineASMColon: Always BreakBeforeTernaryOperators: false +BreakBinaryOperations: Never +BreakConstructorInitializers: BeforeColon +BreakFunctionDefinitionParameters: false +BreakInheritanceList: BeforeColon BreakStringLiterals: true -ColumnLimit: 120 +BreakTemplateDeclarations: Yes +ColumnLimit: 120 +CommentPragmas: '.*' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 -IncludeBlocks: Regroup +Cpp11BracedListStyle: true +DerivePointerAlignment: true +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^<.*\.h>' + Priority: 1 + SortPriority: 0 + CaseSensitive: false + - Regex: '^<.*' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 3 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '([-_](test|unittest))?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false IndentCaseBlocks: false IndentCaseLabels: true +IndentExportBlock: true IndentExternBlock: Indent IndentGotoLabels: false IndentPPDirectives: AfterHash -IndentWidth: 4 +IndentRequiresClause: true +IndentWidth: 4 IndentWrappedFunctionNames: true -InsertBraces: false -KeepEmptyLinesAtEOF: false -KeepEmptyLinesAtTheStartOfBlocks: false -LineEnding: LF +InsertBraces: false +InsertNewlineAtEOF: false +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigits: 0 + Decimal: 0 + DecimalMinDigits: 0 + Hex: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLines: + AtEndOfFile: false + AtStartOfBlock: false + AtStartOfFile: true +KeepFormFeed: false +LambdaBodyIndentation: Signature +LineEnding: LF +MacroBlockBegin: '' +MacroBlockEnd: '' Macros: - - ALLOCATE(type, n) (type*)calloc(sizeof(type), n) - - FREE(x) free((void*)x) - - REALLOCATE(oldptr, type, n) (type*)realloc(oldptr, sizeof(type)*n) + - 'ALLOCATE(type, n) (type*)calloc(sizeof(type), n)' + - 'FREE(x) free((void*)x)' + - 'REALLOCATE(oldptr, type, n) (type*)realloc(oldptr, sizeof(type)*n)' +MainIncludeChar: Quote MaxEmptyLinesToKeep: 4 -PPIndentWidth: 4 +NamespaceIndentation: None +ObjCBinPackProtocolList: Never +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PackConstructorInitializers: NextLine +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakBeforeMemberAccess: 150 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakScopeResolution: 500 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 200 PointerAlignment: Right +PPIndentWidth: 4 QualifierAlignment: Leave +RawStringFormats: + - Language: Cpp + Delimiters: + - cc + - CC + - cpp + - Cpp + - CPP + - 'c++' + - 'C++' + CanonicalDelimiter: '' + BasedOnStyle: google + - Language: TextProto + Delimiters: + - pb + - PB + - proto + - PROTO + EnclosingFunctions: + - EqualsProto + - EquivToProto + - PARSE_PARTIAL_TEXT_PROTO + - PARSE_TEST_PROTO + - PARSE_TEXT_PROTO + - ParseTextOrDie + - ParseTextProtoOrDie + - ParseTestProto + - ParsePartialTestProto + CanonicalDelimiter: pb + BasedOnStyle: google ReferenceAlignment: Right -ReflowComments: true -SortIncludes: Never +ReflowComments: Always +RemoveBracesLLVM: false +RemoveEmptyLinesInUnwrappedLines: false +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SkipMacroDefinitionBody: false +SortIncludes: Never +SortJavaStaticImport: Before +SortUsingDeclarations: LexicographicNumeric SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true SpaceAroundPointerQualifiers: Default SpaceBeforeAssignmentOperators: true SpaceBeforeCaseColon: true SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false SpaceBeforeParens: ControlStatements SpaceBeforeParensOptions: AfterControlStatements: true AfterForeachMacros: true - AfterFunctionDeclarationName: true - AfterFunctionDefinitionName: true - AfterIfMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + AfterPlacementOperator: true + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false +SpaceBeforeRangeBasedForLoopColon: true SpaceBeforeSquareBrackets: false SpaceInEmptyBlock: false SpacesBeforeTrailingComments: 1 -UseTab: Never -TabWidth: 4 -Standard: Latest +SpacesInAngles: Never SpacesInContainerLiterals: true SpacesInLineCommentPrefix: - Maximum: -1 - Minimum: 1 -SpacesInParens: Never + Minimum: 1 + Maximum: -1 +SpacesInParens: Never +SpacesInParensOptions: + ExceptDoubleParentheses: false + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false SpacesInSquareBrackets: false +Standard: Latest StatementAttributeLikeMacros: - PACKED - FORCE_INLINE +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TableGenBreakInsideDAGArg: DontBreak +TabWidth: 4 TypeNames: - Char - ZString @@ -144,5 +328,14 @@ TypeNames: - Addr4 - Addr8 - UintPtr -CommentPragmas: .* -Cpp11BracedListStyle: true +UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: + - BOOST_PP_STRINGIZE + - CF_SWIFT_NAME + - NS_SWIFT_NAME + - PP_STRINGIZE + - STRINGIZE +WrapNamespaceBodyWithEmptyLines: Leave +... + diff --git a/Scripts/clang-format.py b/Scripts/clang-format.py index 8c65753..aefe06a 100644 --- a/Scripts/clang-format.py +++ b/Scripts/clang-format.py @@ -22,7 +22,7 @@ "Fuzz", ] -skiplist = [] +skiplist = [".clang-format"] patterns = ["*.c", "*.cpp", "*.h", "*.hpp", "*.inc"] From b347c56af5f8fffa81d62f935aa87aba83187487 Mon Sep 17 00:00:00 2001 From: brightprogrammer Date: Tue, 7 Oct 2025 22:33:11 -0700 Subject: [PATCH 14/15] Remove Unrecognized Keys --- .clang-format | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.clang-format b/.clang-format index e860dee..d1b9171 100644 --- a/.clang-format +++ b/.clang-format @@ -9,7 +9,7 @@ AlignConsecutiveAssignments: AcrossComments: false AlignCompound: true AlignFunctionDeclarations: false - AlignFunctionPointers: false + PadOperators: true AlignConsecutiveBitFields: Enabled: true @@ -17,7 +17,7 @@ AlignConsecutiveBitFields: AcrossComments: false AlignCompound: true AlignFunctionDeclarations: false - AlignFunctionPointers: false + PadOperators: true AlignConsecutiveDeclarations: Enabled: true @@ -25,7 +25,7 @@ AlignConsecutiveDeclarations: AcrossComments: false AlignCompound: true AlignFunctionDeclarations: true - AlignFunctionPointers: false + PadOperators: true AlignConsecutiveMacros: Enabled: true @@ -33,7 +33,7 @@ AlignConsecutiveMacros: AcrossComments: false AlignCompound: true AlignFunctionDeclarations: false - AlignFunctionPointers: false + PadOperators: true AlignConsecutiveTableGenBreakingDAGArgColons: Enabled: false @@ -41,7 +41,7 @@ AlignConsecutiveTableGenBreakingDAGArgColons: AcrossComments: false AlignCompound: false AlignFunctionDeclarations: false - AlignFunctionPointers: false + PadOperators: false AlignConsecutiveTableGenCondOperatorColons: Enabled: false @@ -49,7 +49,7 @@ AlignConsecutiveTableGenCondOperatorColons: AcrossComments: false AlignCompound: false AlignFunctionDeclarations: false - AlignFunctionPointers: false + PadOperators: false AlignConsecutiveTableGenDefinitionColons: Enabled: false @@ -57,7 +57,7 @@ AlignConsecutiveTableGenDefinitionColons: AcrossComments: false AlignCompound: false AlignFunctionDeclarations: false - AlignFunctionPointers: false + PadOperators: false AlignEscapedNewlines: Right AlignOperands: AlignAfterOperator From 033a353ab647098627abd092eb5fd281d68f75c4 Mon Sep 17 00:00:00 2001 From: brightprogrammer Date: Tue, 7 Oct 2025 22:34:58 -0700 Subject: [PATCH 15/15] Fucking Nuke Clang-Format --- .github/workflows/format-check.yml | 59 ------------------------------ 1 file changed, 59 deletions(-) delete mode 100644 .github/workflows/format-check.yml diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml deleted file mode 100644 index 7643989..0000000 --- a/.github/workflows/format-check.yml +++ /dev/null @@ -1,59 +0,0 @@ -# Snagged from github.com/rizinorg/rizin -# Thanks for having a reliable workflow! - -name: "Format Check" - -on: - push: - branches: - - 'master' - pull_request: - branches: - - 'master' - -# Automatically cancel any previous workflow on new push. -concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} - cancel-in-progress: true - -jobs: - changes: - runs-on: ubuntu-24.04 - outputs: - clang-format: ${{ steps.filter.outputs.clang-format }} - steps: - - uses: actions/checkout@v5 - - uses: dorny/paths-filter@v3 - id: filter - with: - filters: | - clang-format: - - '**.c' - - '**.h' - - '**.in' - - '**.inc' - - '.github/workflows/linter.yml' - - 'Scripts/clang-format.py' - - '.clang-format' - - clang-format: - needs: changes - runs-on: ubuntu-24.04 - if: ${{ needs.changes.outputs.clang-format == 'true' }} - steps: - - name: Checkout repository - uses: actions/checkout@v5 - - - name: Install clang-format-16 - run: sudo apt --assume-yes install clang-format-16 - - - name: Install Python3 and gitpython - run: | - sudo apt --assume-yes install python3-pip - sudo pip3 install gitpython - - - name: Run clang-format - run: | - sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-16 160 - clang-format --version - python3 Scripts/clang-format.py --check --verbose \ No newline at end of file