Skip to content

Commit

Permalink
Merge branch 'main' into feat-devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
KeithWiles authored Nov 25, 2024
2 parents 618c2fc + c1a0236 commit 354697f
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 99 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: DoozyX/[email protected]
- uses: DoozyX/[email protected].2
with:
source: '.'
exclude: 'examples/vpp-plugin'
extensions: 'h,cpp,c,cc'
clangFormatVersion: 17
clangFormatVersion: 18.1.8
25 changes: 25 additions & 0 deletions .github/workflows/pre-commit-auto-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Pre-commit auto-update
on: # yamllint disable-line rule:truthy
schedule:
- cron: 0 0 1 * *
jobs:
auto-update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit autoupdate
run: pre-commit autoupdate
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: update/pre-commit-autoupdate
title: Auto-update pre-commit hooks
commit-message: Auto-update pre-commit hooks
body: |
Update pre-commit hooks to latest version
labels: dependencies
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -12,13 +12,13 @@ repos:
hooks:
- id: yamllint
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
rev: v18.1.8
hooks:
- id: clang-format
types_or: [c++, c]
args: [-i, --style=file]
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.9.2
rev: v0.15.0
hooks:
- id: markdownlint-cli2-rules-docker
- repo: https://github.com/codespell-project/codespell
Expand Down
6 changes: 2 additions & 4 deletions lib/cnet/netlink/netlink_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
extern "C" {
#endif

#define DUMP_PARAMS_INIT(info, dump) \
{ \
.dp_type = dump, .dp_fd = stdout, .dp_dump_msgtype = 1, .dp_data = info \
}
#define DUMP_PARAMS_INIT(info, dump) \
{.dp_type = dump, .dp_fd = stdout, .dp_dump_msgtype = 1, .dp_data = info}

#define NL_DEBUG(...) \
do { \
Expand Down
18 changes: 5 additions & 13 deletions lib/cnet/tcp/cnet_tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,9 @@ typedef enum {
TCPS_TIME_WAIT /**< Connection is in time wait state */
} tcb_state_t;

#define TCP_INPUT_STATES \
{ \
"Free", "Closed", "Listen", "SYN Sent", "SYN Rcvd", "Established", "CloseWait", "Fin1", \
"Closing", "LastAck", "Fin2", "TimeWait", "DeleteTCB" \
}
#define TCP_INPUT_STATES \
{"Free", "Closed", "Listen", "SYN Sent", "SYN Rcvd", "Established", "CloseWait", \
"Fin1", "Closing", "LastAck", "Fin2", "TimeWait", "DeleteTCB"}

#define TCPS_HAVE_RCVD_SYN(s) ((s) >= TCPS_SYN_RCVD)
#define TCPS_HAVE_ESTABLISHED (s)((s) >= TCPS_ESTABLISHED)
Expand All @@ -163,10 +161,7 @@ enum {
};

/* Keep in bit order with above enums */
#define TCP_FLAGS \
{ \
"FIN", "SYN", "RST", "PSH", "ACK", "URG" \
}
#define TCP_FLAGS {"FIN", "SYN", "RST", "PSH", "ACK", "URG"}

// clang-format off
/* State of the flags for all possible states in TCP */
Expand All @@ -190,10 +185,7 @@ enum {
/* TCP Output Events to drive the output Finite State Machine. */
enum { SEND_EVENT, PERSIST_EVENT, RETRANSMIT_EVENT, DELETE_EVENT };

#define TCP_OUTPUT_EVENTS \
{ \
"Send", "Persist", "Rexmit", "Delete" \
}
#define TCP_OUTPUT_EVENTS {"Send", "Persist", "Rexmit", "Delete"}

/* TCP Option values */
enum {
Expand Down
2 changes: 1 addition & 1 deletion lib/core/hash/cne_hash_crc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/core/ring/cne_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 11 additions & 9 deletions lib/include/cne_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -278,15 +278,15 @@ 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
* will be of the same type as the first parameter, and will be no lower
* 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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]))
Expand Down
5 changes: 1 addition & 4 deletions lib/include/cne_rwlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ typedef struct __cne_lockable {
/**
* A static rwlock initializer.
*/
#define CNE_RWLOCK_INITIALIZER \
{ \
0 \
}
#define CNE_RWLOCK_INITIALIZER {0}

/**
* Initialize the rwlock to an unlocked state.
Expand Down
10 changes: 2 additions & 8 deletions lib/include/cne_spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ typedef struct {
/**
* A static spinlock initializer.
*/
#define CNE_SPINLOCK_INITIALIZER \
{ \
0 \
}
#define CNE_SPINLOCK_INITIALIZER {0}

/**
* Initialize the spinlock to an unlocked state.
Expand Down Expand Up @@ -189,10 +186,7 @@ typedef struct {
/**
* A static recursive spinlock initializer.
*/
#define CNE_SPINLOCK_RECURSIVE_INITIALIZER \
{ \
CNE_SPINLOCK_INITIALIZER, -1, 0 \
}
#define CNE_SPINLOCK_RECURSIVE_INITIALIZER {CNE_SPINLOCK_INITIALIZER, -1, 0}

/**
* Initialize the recursive spinlock to an unlocked state.
Expand Down
13 changes: 5 additions & 8 deletions lib/usr/app/cli/cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ typedef enum {
} node_type_t;

/* Keep this list in sync with the node_type_t enum above */
#define CLI_NODE_TYPES \
{ \
"Unknown", "Directory", "Command", "File", "Alias", "String", NULL \
}
#define CLI_NODE_TYPES {"Unknown", "Directory", "Command", "File", "Alias", "String", NULL}

enum {
CLI_EXE_TYPE = (CLI_CMD_NODE | CLI_ALIAS_NODE),
Expand Down Expand Up @@ -203,25 +200,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 */
Expand Down
8 changes: 4 additions & 4 deletions lib/usr/app/jcfg/jcfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ struct json_object;
*
* @note: make sure this matches the jcfg_cb_type_t enum order.
*/
#define JCFG_TAG_NAMES \
{ \
APP_TAG, DEFAULT_TAG, OPTION_TAG, UMEM_TAG, LPORT_TAG, LGROUP_TAG, THREAD_TAG, \
LPORT_GROUP_TAG, USER_TAG, \
#define JCFG_TAG_NAMES \
{ \
APP_TAG, DEFAULT_TAG, OPTION_TAG, UMEM_TAG, LPORT_TAG, \
LGROUP_TAG, THREAD_TAG, LPORT_GROUP_TAG, USER_TAG, \
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/usr/clib/acl/cne_acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 5 additions & 3 deletions lib/usr/clib/cthread/cthread_cond.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ struct cthread_cond {
char name[MAX_COND_NAME_SIZE]; /**< Name of the condition variable */
} __cne_cache_aligned;

#define CTHREAD_COND_INIT(name) \
{ \
.name = #name, .blocked = NULL, .sched = NULL, \
#define CTHREAD_COND_INIT(name) \
{ \
.name = #name, \
.blocked = NULL, \
.sched = NULL, \
}

#ifdef __cplusplus
Expand Down
12 changes: 8 additions & 4 deletions lib/usr/clib/cthread/cthread_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
Loading

0 comments on commit 354697f

Please sign in to comment.