[v4] lib: document existing free functions
Checks
Commit Message
Make sure all functions which use the convention that XXX_free(NULL)
is a nop are all documented.
The wording is chosen to match the documentation of free(3).
"If ptr is NULL, no operation is performed."
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/bitratestats/rte_bitrate.h | 1 +
lib/compressdev/rte_comp.h | 3 ++-
lib/cryptodev/rte_crypto.h | 4 +++-
lib/eal/include/rte_interrupts.h | 3 ++-
lib/efd/rte_efd.h | 3 ++-
lib/eventdev/rte_event_ring.h | 3 ++-
lib/fib/rte_fib.h | 3 ++-
lib/fib/rte_fib6.h | 3 ++-
lib/member/rte_member.h | 1 +
lib/reorder/rte_reorder.h | 3 ++-
lib/rib/rte_rib.h | 3 ++-
lib/rib/rte_rib6.h | 3 ++-
lib/sched/rte_sched.h | 3 ++-
lib/stack/rte_stack.h | 3 ++-
lib/telemetry/rte_telemetry.h | 2 +-
15 files changed, 28 insertions(+), 13 deletions(-)
Comments
On 2022/6/23 4:52, Stephen Hemminger wrote:
> Make sure all functions which use the convention that XXX_free(NULL)
> is a nop are all documented.
>
> The wording is chosen to match the documentation of free(3).
> "If ptr is NULL, no operation is performed."
It's a good idea to add such explicit description.
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> lib/bitratestats/rte_bitrate.h | 1 +
> lib/compressdev/rte_comp.h | 3 ++-
> lib/cryptodev/rte_crypto.h | 4 +++-
> lib/eal/include/rte_interrupts.h | 3 ++-
> lib/efd/rte_efd.h | 3 ++-
> lib/eventdev/rte_event_ring.h | 3 ++-
> lib/fib/rte_fib.h | 3 ++-
> lib/fib/rte_fib6.h | 3 ++-
> lib/member/rte_member.h | 1 +
> lib/reorder/rte_reorder.h | 3 ++-
> lib/rib/rte_rib.h | 3 ++-
> lib/rib/rte_rib6.h | 3 ++-
> lib/sched/rte_sched.h | 3 ++-
> lib/stack/rte_stack.h | 3 ++-
> lib/telemetry/rte_telemetry.h | 2 +-
> 15 files changed, 28 insertions(+), 13 deletions(-)
>
...
On Wed, Jun 22, 2022 at 10:53 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> Make sure all functions which use the convention that XXX_free(NULL)
> is a nop are all documented.
>
> The wording is chosen to match the documentation of free(3).
> "If ptr is NULL, no operation is performed."
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Squashed similar updates for acl, lpm and pipeline API that were in
https://patchwork.dpdk.org/project/dpdk/list/?series=21752&state=*
series, and applied.
Thanks.
@@ -32,6 +32,7 @@ struct rte_stats_bitrates *rte_stats_bitrate_create(void);
*
* @param bitrate_data
* Pointer allocated by rte_stats_bitrate_create()
+ * If pointer is NULL, no operation is performed.
*/
void rte_stats_bitrate_free(struct rte_stats_bitrates *bitrate_data);
@@ -469,7 +469,8 @@ rte_comp_op_bulk_alloc(struct rte_mempool *mempool,
* be returned to the mempool.
*
* @param op
- * Compress operation
+ * Compress operation pointer allocated from rte_comp_op_alloc()
+ * If pointer is NULL, no operation is performed.
*/
__rte_experimental
void
@@ -347,7 +347,9 @@ __rte_crypto_op_get_priv_data(struct rte_crypto_op *op, uint32_t size)
* If operation has been allocate from a rte_mempool, then the operation will
* be returned to the mempool.
*
- * @param op symmetric crypto operation
+ * @param op
+ * Pointer to symmetric crypto operation allocated with rte_crypto_op_alloc()
+ * If pointer is NULL, no operation is performed.
*/
static inline void
rte_crypto_op_free(struct rte_crypto_op *op)
@@ -242,7 +242,8 @@ rte_intr_instance_alloc(uint32_t flags);
* Free the memory allocated for interrupt handle resources.
*
* @param intr_handle
- * Interrupt handle address.
+ * Interrupt handle allocated with rte_intr_instance_alloc().
+ * If handle is NULL, no operation is performed.
*
*/
__rte_experimental
@@ -145,7 +145,8 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
* Releases the resources from an EFD table
*
* @param table
- * Table to free
+ * Pointer to table allocated with rte_efd_create().
+ * If pointer is NULL, no operation is performed.
*/
void
rte_efd_free(struct rte_efd_table *table);
@@ -234,7 +234,8 @@ rte_event_ring_lookup(const char *name);
* De-allocate all memory used by the ring.
*
* @param r
- * Ring to free
+ * Pointer to ring to created with rte_event_ring_create().
+ * If pointer is NULL, no operation is performed.
*/
void
rte_event_ring_free(struct rte_event_ring *r);
@@ -122,7 +122,8 @@ rte_fib_find_existing(const char *name);
* Free an FIB object.
*
* @param fib
- * FIB object handle
+ * FIB object handle created by rte_fib_create().
+ * If handle is NULL, no operation is performed.
* @return
* None
*/
@@ -113,7 +113,8 @@ rte_fib6_find_existing(const char *name);
* Free an FIB object.
*
* @param fib
- * FIB object handle
+ * FIB object handle created by rte_fib6_create().
+ * If handle is NULL, no operation is performed.
* @return
* None
*/
@@ -443,6 +443,7 @@ rte_member_add(const struct rte_member_setsum *setsum, const void *key,
*
* @param setsum
* Pointer to the set summary.
+ * If pointer is NULL, no operation is performed.
*/
void
rte_member_free(struct rte_member_setsum *setsum);
@@ -114,7 +114,8 @@ rte_reorder_reset(struct rte_reorder_buffer *b);
* Free reorder buffer instance.
*
* @param b
- * reorder buffer instance
+ * Pointer to reorder buffer instance.
+ * If pointer is NULL, no operation is performed.
* @return
* None
*/
@@ -263,7 +263,8 @@ rte_rib_find_existing(const char *name);
* Free an RIB object.
*
* @param rib
- * RIB object handle
+ * RIB object handle created with rte_rib_create().
+ * If handle is NULL, no operation is performed.
* @return
* None
*/
@@ -318,7 +318,8 @@ rte_rib6_find_existing(const char *name);
* Free an RIB object.
*
* @param rib
- * RIB object handle
+ * RIB object handle created with rte_rib6_create().
+ * If handle is NULL, no operation is performed.
* @return
* None
*/
@@ -328,7 +328,8 @@ rte_sched_port_config(struct rte_sched_port_params *params);
* Hierarchical scheduler port free
*
* @param port
- * Handle to port scheduler instance
+ * Handle to port scheduler instance.
+ * If handle is NULL, no operation is performed.
*/
void
rte_sched_port_free(struct rte_sched_port *port);
@@ -213,7 +213,8 @@ rte_stack_create(const char *name, unsigned int count, int socket_id,
* Free all memory used by the stack.
*
* @param s
- * Stack to free
+ * Pointer to stack created with rte_stack_create().
+ * If pointer is NULL, no operation is performed.
*/
void
rte_stack_free(struct rte_stack *s);
@@ -293,7 +293,7 @@ rte_tel_data_alloc(void);
*
* @param data
* Pointer to container.
- *.
+ * If pointer is NULL, no operation is performed.
*/
void
rte_tel_data_free(struct rte_tel_data *data);