This is an automated email from the ASF dual-hosted git repository. janc pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 7759d4f8b72c40474902c32e886a54344d0d5751 Author: Wojciech Pietraszewski <[email protected]> AuthorDate: Thu Jun 20 14:54:48 2024 +0200 kernel/os_mbuf: Update function parameters names Adds missing variables names in function declarations. Updates existing variables names in function definitions for improved consistency. --- kernel/os/include/os/os_mbuf.h | 27 +++++++++++++-------------- kernel/os/src/os_mbuf.c | 42 +++++++++++++++++++++++------------------- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/kernel/os/include/os/os_mbuf.h b/kernel/os/include/os/os_mbuf.h index a6c869f28..0ecb4e523 100644 --- a/kernel/os/include/os/os_mbuf.h +++ b/kernel/os/include/os/os_mbuf.h @@ -272,7 +272,7 @@ int os_mqueue_init(struct os_mqueue *mq, os_event_fn *ev_cb, void *arg); * * @return The next mbuf in the queue, or NULL if queue has no mbufs. */ -struct os_mbuf *os_mqueue_get(struct os_mqueue *); +struct os_mbuf *os_mqueue_get(struct os_mqueue *mq); /** * Adds a packet (i.e. packet header mbuf) to an mqueue. The event associated @@ -284,7 +284,7 @@ struct os_mbuf *os_mqueue_get(struct os_mqueue *); * * @return 0 on success, non-zero on failure. */ -int os_mqueue_put(struct os_mqueue *, struct os_eventq *, struct os_mbuf *); +int os_mqueue_put(struct os_mqueue *mq, struct os_eventq *evq, struct os_mbuf *om); /** * MSYS is a system level mbuf registry. Allows the system to share @@ -302,7 +302,7 @@ int os_mqueue_put(struct os_mqueue *, struct os_eventq *, struct os_mbuf *); * * @return 0 on success, non-zero on failure */ -int os_msys_register(struct os_mbuf_pool *); +int os_msys_register(struct os_mbuf_pool *new_pool); /** * Allocate a mbuf from msys. Based upon the data size requested, @@ -355,9 +355,8 @@ int os_msys_num_free(void); * * @return 0 on success, error code on failure. */ -int os_mbuf_pool_init(struct os_mbuf_pool *, struct os_mempool *mp, - uint16_t, uint16_t); - +int os_mbuf_pool_init(struct os_mbuf_pool *omp, struct os_mempool *mp, + uint16_t buf_len, uint16_t nbufs); /** * Get an mbuf from the mbuf pool. The mbuf is allocated, and initialized * prior to being returned. @@ -368,7 +367,7 @@ int os_mbuf_pool_init(struct os_mbuf_pool *, struct os_mempool *mp, * * @return An initialized mbuf on success, and NULL on failure. */ -struct os_mbuf *os_mbuf_get(struct os_mbuf_pool *omp, uint16_t); +struct os_mbuf *os_mbuf_get(struct os_mbuf_pool *omp, uint16_t leadingspace); /** * Allocate a new packet header mbuf out of the os_mbuf_pool. @@ -379,7 +378,7 @@ struct os_mbuf *os_mbuf_get(struct os_mbuf_pool *omp, uint16_t); * @return A freshly allocated mbuf on success, NULL on failure. */ struct os_mbuf *os_mbuf_get_pkthdr(struct os_mbuf_pool *omp, - uint8_t pkthdr_len); + uint8_t user_pkthdr_len); /** * Duplicate a chain of mbufs. Return the start of the duplicated chain. @@ -388,7 +387,7 @@ struct os_mbuf *os_mbuf_get_pkthdr(struct os_mbuf_pool *omp, * * @return A pointer to the new chain of mbufs */ -struct os_mbuf *os_mbuf_dup(struct os_mbuf *m); +struct os_mbuf *os_mbuf_dup(struct os_mbuf *om); /** * Locates the specified absolute offset within an mbuf chain. The offset @@ -419,7 +418,7 @@ struct os_mbuf *os_mbuf_off(const struct os_mbuf *om, int off, * @return 0 on success; * -1 if the mbuf does not contain enough data. */ -int os_mbuf_copydata(const struct os_mbuf *m, int off, int len, void *dst); +int os_mbuf_copydata(const struct os_mbuf *om, int off, int len, void *dst); /** * @brief Calculates the length of an mbuf chain. @@ -444,7 +443,7 @@ uint16_t os_mbuf_len(const struct os_mbuf *om); * * @return 0 on success, and an error code on failure */ -int os_mbuf_append(struct os_mbuf *m, const void *, uint16_t); +int os_mbuf_append(struct os_mbuf *om, const void *data, uint16_t len); /** * Reads data from one mbuf and appends it to another. On error, the specified @@ -471,7 +470,7 @@ int os_mbuf_appendfrom(struct os_mbuf *dst, const struct os_mbuf *src, * * @return 0 on success, -1 on failure */ -int os_mbuf_free(struct os_mbuf *mb); +int os_mbuf_free(struct os_mbuf *om); /** * Free a chain of mbufs @@ -486,12 +485,12 @@ int os_mbuf_free_chain(struct os_mbuf *om); * Adjust the length of a mbuf, trimming either from the head or the tail * of the mbuf. * - * @param mp The mbuf chain to adjust + * @param om The mbuf chain to adjust * @param req_len The length to trim from the mbuf. If positive, trims * from the head of the mbuf, if negative, trims from the * tail of the mbuf. */ -void os_mbuf_adj(struct os_mbuf *mp, int req_len); +void os_mbuf_adj(struct os_mbuf *om, int req_len); /** diff --git a/kernel/os/src/os_mbuf.c b/kernel/os/src/os_mbuf.c index 1a1962aa6..d5ed8353d 100644 --- a/kernel/os/src/os_mbuf.c +++ b/kernel/os/src/os_mbuf.c @@ -81,19 +81,19 @@ os_mqueue_get(struct os_mqueue *mq) } int -os_mqueue_put(struct os_mqueue *mq, struct os_eventq *evq, struct os_mbuf *m) +os_mqueue_put(struct os_mqueue *mq, struct os_eventq *evq, struct os_mbuf *om) { struct os_mbuf_pkthdr *mp; os_sr_t sr; int rc; /* Can only place the head of a chained mbuf on the queue. */ - if (!OS_MBUF_IS_PKTHDR(m)) { + if (!OS_MBUF_IS_PKTHDR(om)) { rc = OS_EINVAL; goto err; } - mp = OS_MBUF_PKTHDR(m); + mp = OS_MBUF_PKTHDR(om); OS_ENTER_CRITICAL(sr); STAILQ_INSERT_TAIL(&mq->mq_head, mp, omp_next); @@ -437,7 +437,7 @@ os_mbuf_off(const struct os_mbuf *om, int off, uint16_t *out_off) } int -os_mbuf_copydata(const struct os_mbuf *m, int off, int len, void *dst) +os_mbuf_copydata(const struct os_mbuf *om, int off, int len, void *dst) { unsigned int count; uint8_t *udst; @@ -449,36 +449,38 @@ os_mbuf_copydata(const struct os_mbuf *m, int off, int len, void *dst) udst = dst; while (off > 0) { - if (!m) { + if (!om) { return (-1); } - if (off < m->om_len) + if (off < om->om_len) { break; - off -= m->om_len; - m = SLIST_NEXT(m, om_next); + } + off -= om->om_len; + om = SLIST_NEXT(om, om_next); } - while (len > 0 && m != NULL) { - count = min(m->om_len - off, len); - memcpy(udst, m->om_data + off, count); + while (len > 0 && om != NULL) { + count = min(om->om_len - off, len); + memcpy(udst, om->om_data + off, count); len -= count; udst += count; off = 0; - m = SLIST_NEXT(m, om_next); + om = SLIST_NEXT(om, om_next); } return (len > 0 ? -1 : 0); } void -os_mbuf_adj(struct os_mbuf *mp, int req_len) +os_mbuf_adj(struct os_mbuf *om, int req_len) { int len = req_len; struct os_mbuf *m; int count; - if ((m = mp) == NULL) + if ((m = om) == NULL) { return; + } if (len >= 0) { /* * Trim from head. @@ -494,8 +496,9 @@ os_mbuf_adj(struct os_mbuf *mp, int req_len) len = 0; } } - if (OS_MBUF_IS_PKTHDR(mp)) - OS_MBUF_PKTHDR(mp)->omp_len -= (req_len - len); + if (OS_MBUF_IS_PKTHDR(om)) { + OS_MBUF_PKTHDR(om)->omp_len -= (req_len - len); + } } else { /* * Trim from tail. Scan the mbuf chain, @@ -514,8 +517,9 @@ os_mbuf_adj(struct os_mbuf *mp, int req_len) } if (m->om_len >= len) { m->om_len -= len; - if (OS_MBUF_IS_PKTHDR(mp)) - OS_MBUF_PKTHDR(mp)->omp_len -= len; + if (OS_MBUF_IS_PKTHDR(om)) { + OS_MBUF_PKTHDR(om)->omp_len -= len; + } return; } count -= len; @@ -526,7 +530,7 @@ os_mbuf_adj(struct os_mbuf *mp, int req_len) * Find the mbuf with last data, adjust its length, * and toss data from remaining mbufs on chain. */ - m = mp; + m = om; if (OS_MBUF_IS_PKTHDR(m)) OS_MBUF_PKTHDR(m)->omp_len = count; for (; m; m = SLIST_NEXT(m, om_next)) {
