diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 708ded06..3e381bb4 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -10,9 +10,9 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: DoozyX/clang-format-lint-action@v0.18 + - uses: DoozyX/clang-format-lint-action@v0.18.1.1 with: source: '.' exclude: 'examples/vpp-plugin' extensions: 'h,cpp,c,cc' - clangFormatVersion: 17 + clangFormatVersion: 18.1.8 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3458e378..1a4cc7ad 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: hooks: - id: yamllint - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v19.1.4 + rev: v18.1.1 hooks: - id: clang-format types_or: [c++, c] diff --git a/lib/core/hash/cne_hash_crc.h b/lib/core/hash/cne_hash_crc.h index 2e1900db..3d941c83 100644 --- a/lib/core/hash/cne_hash_crc.h +++ b/lib/core/hash/cne_hash_crc.h @@ -296,7 +296,7 @@ static const uint32_t crc32c_tables[8][256] = {{ // clang-format on #define CRC32_UPD(crc, n) \ - (crc32c_tables[(n)][(crc) & 0xFF] ^ crc32c_tables[(n)-1][((crc) >> 8) & 0xFF]) + (crc32c_tables[(n)][(crc) & 0xFF] ^ crc32c_tables[(n) - 1][((crc) >> 8) & 0xFF]) static inline uint32_t crc32c_1byte(uint8_t data, uint32_t init_val) diff --git a/lib/core/ring/cne_ring.c b/lib/core/ring/cne_ring.c index 94418ac8..f567929d 100644 --- a/lib/core/ring/cne_ring.c +++ b/lib/core/ring/cne_ring.c @@ -27,7 +27,7 @@ #include "ring_private.h" // for cne_ring, cne_ring_headtail, CNE_... /* true if x is a power of 2 */ -#define POWEROF2(x) ((((x)-1) & (x)) == 0) +#define POWEROF2(x) ((((x) - 1) & (x)) == 0) #define RING_DFLT_ELEM_SZ sizeof(void *) /** The default ring element size*/ ssize_t diff --git a/lib/include/cne_common.h b/lib/include/cne_common.h index 68b7ae51..0091fda2 100644 --- a/lib/include/cne_common.h +++ b/lib/include/cne_common.h @@ -149,7 +149,7 @@ typedef uint16_t unaligned_uint16_t; */ #define CNE_SET_USED(x) (void)(x) -#define cne_roundup(_x, _y) ((((_x) + ((_y)-1)) / (_y)) * (_y)) +#define cne_roundup(_x, _y) ((((_x) + ((_y) - 1)) / (_y)) * (_y)) #define cne_ctz(_v) __builtin_ctz(_v) #define cne_prefixbits(_v) ((__typeof__(_v))(sizeof(_v) * 8) - cne_ctz(_v)) #define cne_numbytes(_v) ((cne_prefixbits(_v) + 7) / 8) @@ -269,7 +269,7 @@ typedef uint16_t unaligned_uint16_t; * bigger than the first parameter. Second parameter must be a * power-of-two value. */ -#define CNE_ALIGN_FLOOR(val, align) (typeof(val))((val) & (~((typeof(val))((align)-1)))) +#define CNE_ALIGN_FLOOR(val, align) (typeof(val))((val) & (~((typeof(val))((align) - 1)))) /** * Macro to align a pointer to a given power-of-two. The resultant @@ -278,7 +278,7 @@ typedef uint16_t unaligned_uint16_t; * must be a power-of-two value. */ #define CNE_PTR_ALIGN_CEIL(ptr, align) \ - CNE_PTR_ALIGN_FLOOR((typeof(ptr))CNE_PTR_ADD(ptr, (align)-1), align) + CNE_PTR_ALIGN_FLOOR((typeof(ptr))CNE_PTR_ADD(ptr, (align) - 1), align) /** * Macro to align a value to a given power-of-two. The resultant value @@ -286,7 +286,7 @@ typedef uint16_t unaligned_uint16_t; * than the first parameter. Second parameter must be a power-of-two * value. */ -#define CNE_ALIGN_CEIL(val, align) CNE_ALIGN_FLOOR(((val) + ((typeof(val))(align)-1)), align) +#define CNE_ALIGN_CEIL(val, align) CNE_ALIGN_FLOOR(((val) + ((typeof(val))(align) - 1)), align) /** * Macro to align a pointer to a given power-of-two. The resultant @@ -312,7 +312,7 @@ typedef uint16_t unaligned_uint16_t; * than the first parameter. */ #define CNE_ALIGN_MUL_CEIL(v, mul) \ - (((v + (typeof(v))(mul)-1) / ((typeof(v))(mul))) * (typeof(v))(mul)) + (((v + (typeof(v))(mul) - 1) / ((typeof(v))(mul))) * (typeof(v))(mul)) /** * Macro to align a value to the multiple of given value. The resultant @@ -397,7 +397,7 @@ __extension__ typedef uint64_t CNE_MARKER64[0]; /** Physical address */ typedef uint64_t phys_addr_t; -#define CNE_BAD_PHYS_ADDR ((phys_addr_t)-1) +#define CNE_BAD_PHYS_ADDR ((phys_addr_t) - 1) /** * IO virtual address type. @@ -407,7 +407,7 @@ typedef uint64_t phys_addr_t; * Otherwise, in virtual mode (IOVA as VA), an IOMMU may do the translation. */ typedef uint64_t cne_iova_t; -#define CNE_BAD_IOVA ((cne_iova_t)-1) +#define CNE_BAD_IOVA ((cne_iova_t) - 1) /** * Combines 32b inputs most significant set bits into the least @@ -459,7 +459,7 @@ cne_combine64ms1b(uint64_t v) /** * Macro to return 1 if n is a power of 2, 0 otherwise */ -#define CNE_IS_POWER_OF_2(n) ((n) && !(((n)-1) & (n))) +#define CNE_IS_POWER_OF_2(n) ((n) && !(((n) - 1) & (n))) /** * Returns true if n is a power of 2 @@ -773,7 +773,9 @@ cne_log2_u64(uint64_t v) #define CNE_FMT_TAIL(fmt, ...) __VA_ARGS__ /** Mask value of type "tp" for the first "ln" bit set. */ -#define CNE_LEN2MASK(ln, tp) ((tp)((uint64_t)-1 >> (sizeof(uint64_t) * CHAR_BIT - (ln)))) +// clang-format off +#define CNE_LEN2MASK(ln, tp) ((tp)((uint64_t) - 1 >> (sizeof(uint64_t) * CHAR_BIT - (ln)))) +// clang-format on /** Number of elements in the array. */ #define CNE_DIM(a) (int)(sizeof(a) / sizeof((a)[0])) diff --git a/lib/usr/app/cli/cli.h b/lib/usr/app/cli/cli.h index 92d9b017..60ab72b9 100644 --- a/lib/usr/app/cli/cli.h +++ b/lib/usr/app/cli/cli.h @@ -203,25 +203,25 @@ struct cli_cmd { const char *name; /**< Name of command */ cli_cfunc_t cfunc; /**< Function pointer */ const char *short_desc; /**< Short description */ -}; /**< List of commands for cli_add_cmds() */ +}; /**< List of commands for cli_add_cmds() */ struct cli_alias { const char *name; /**< Name of command */ const char *alias_atr; /**< Alias string */ const char *short_desc; /**< Short description */ -}; /**< List of alias for cli_add_aliases() */ +}; /**< List of alias for cli_add_aliases() */ struct cli_file { const char *name; /**< Name of command */ cli_ffunc_t ffunc; /**< Read/Write function pointer */ const char *short_desc; /**< Short description */ -}; /**< List of alias for cli_add_aliases() */ +}; /**< List of alias for cli_add_aliases() */ struct cli_str { const char *name; /**< Name of command */ cli_sfunc_t sfunc; /**< Function pointer */ const char *string; /**< Default string */ -}; /**< List of commands for cli_add_str() */ +}; /**< List of commands for cli_add_str() */ struct cli_tree { node_type_t type; /**< type of node to create */ diff --git a/lib/usr/clib/acl/cne_acl.h b/lib/usr/clib/acl/cne_acl.h index 799a11ca..f799023a 100644 --- a/lib/usr/clib/acl/cne_acl.h +++ b/lib/usr/clib/acl/cne_acl.h @@ -96,7 +96,7 @@ enum { }; #define CNE_ACL_MASKLEN_TO_BITMASK(v, s) \ - ((v) == 0 ? (v) : (typeof(v))((uint64_t)-1 << ((s) * CHAR_BIT - (v)))) + ((v) == 0 ? (v) : (typeof(v))((uint64_t) - 1 << ((s) * CHAR_BIT - (v)))) /** * Miscellaneous data for ACL rule. diff --git a/lib/usr/clib/cthread/cthread_pool.h b/lib/usr/clib/cthread/cthread_pool.h index 90a0be7f..8cae8696 100644 --- a/lib/usr/clib/cthread/cthread_pool.h +++ b/lib/usr/clib/cthread/cthread_pool.h @@ -168,7 +168,8 @@ _qnode_pool_insert(struct qnode_pool *p, struct qnode *n) * @return * NULL on error or qnode pointer */ -static inline struct qnode *__attribute__((always_inline)) _pool_remove(struct qnode_pool *p) +static inline struct qnode *__attribute__((always_inline)) +_pool_remove(struct qnode_pool *p) { struct qnode *head; struct qnode *tail = p->tail; @@ -212,7 +213,8 @@ static inline struct qnode *__attribute__((always_inline)) _pool_remove(struct q * @return * The qnode removed from queue or NULL on error */ -static inline struct qnode *__attribute__((always_inline)) _qnode_pool_remove(struct qnode_pool *p) +static inline struct qnode *__attribute__((always_inline)) +_qnode_pool_remove(struct qnode_pool *p) { struct qnode *n; @@ -230,7 +232,8 @@ static inline struct qnode *__attribute__((always_inline)) _qnode_pool_remove(st * Allocate a node from the pool * If the pool is empty add mode nodes */ -static inline struct qnode *__attribute__((always_inline)) _qnode_alloc(void) +static inline struct qnode *__attribute__((always_inline)) +_qnode_alloc(void) { struct qnode_pool *p = (THIS_SCHED)->qnode_pool; int prealloc_size = p->pre_alloc; @@ -263,7 +266,8 @@ static inline struct qnode *__attribute__((always_inline)) _qnode_alloc(void) /* * free a queue node to the per scheduler pool from which it came */ -static inline void __attribute__((always_inline)) _qnode_free(struct qnode *n) +static inline void __attribute__((always_inline)) +_qnode_free(struct qnode *n) { struct qnode_pool *p = n->pool; diff --git a/lib/usr/clib/cthread/cthread_sched.h b/lib/usr/clib/cthread/cthread_sched.h index 6445238c..850f11fa 100644 --- a/lib/usr/clib/cthread/cthread_sched.h +++ b/lib/usr/clib/cthread/cthread_sched.h @@ -101,14 +101,16 @@ _sched_now(void) return 1; } -static inline void __attribute__((always_inline)) _affinitize(void) +static inline void __attribute__((always_inline)) +_affinitize(void) { struct cthread *ct = THIS_CTHREAD; cthread_switch(&(THIS_SCHED)->ctx, &ct->ctx); } -static inline void __attribute__((always_inline)) _suspend(void) +static inline void __attribute__((always_inline)) +_suspend(void) { struct cthread *ct = THIS_CTHREAD; @@ -117,7 +119,8 @@ static inline void __attribute__((always_inline)) _suspend(void) (THIS_SCHED)->nb_blocked_threads--; } -static inline void __attribute__((always_inline)) _reschedule(void) +static inline void __attribute__((always_inline)) +_reschedule(void) { struct cthread *ct = THIS_CTHREAD; diff --git a/lib/usr/clib/utils/crc32.h b/lib/usr/clib/utils/crc32.h index ab45b10c..be55bb32 100644 --- a/lib/usr/clib/utils/crc32.h +++ b/lib/usr/clib/utils/crc32.h @@ -43,8 +43,8 @@ extern const uint32_t crc32_tab[]; #define rounddown(x, y) (((x) / (y)) * (y)) -#define rounddown2(x, y) ((x) & (~((y)-1))) /* if y is power of two */ -#define roundup2(x, y) (((x) + ((y)-1)) & (~((y)-1))) /* if y is power of two */ +#define rounddown2(x, y) ((x) & (~((y) - 1))) /* if y is power of two */ +#define roundup2(x, y) (((x) + ((y) - 1)) & (~((y) - 1))) /* if y is power of two */ static __inline uint32_t crc32_raw(const void *buf, size_t size, uint32_t crc)