From 448e01f1b5848b20cb0300d339100dd82f4459e9 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 22 Jun 2022 13:52:57 -0700 Subject: [PATCH] lib: document free functions 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 Acked-by: Chengwen Feng [David: squashed with other series updates, unified wording] --- lib/acl/rte_acl.h | 1 + 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/lpm/rte_lpm.h | 1 + lib/lpm/rte_lpm6.h | 1 + lib/member/rte_member.h | 1 + lib/pipeline/rte_port_in_action.h | 6 ++++-- lib/pipeline/rte_swx_ctl.h | 1 + lib/pipeline/rte_swx_pipeline.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 +- 21 files changed, 37 insertions(+), 15 deletions(-) diff --git a/lib/acl/rte_acl.h b/lib/acl/rte_acl.h index f7f5f08701..ca75a6f220 100644 --- a/lib/acl/rte_acl.h +++ b/lib/acl/rte_acl.h @@ -165,6 +165,7 @@ rte_acl_find_existing(const char *name); * * @param ctx * ACL context to free + * If ctx is NULL, no operation is performed. */ void rte_acl_free(struct rte_acl_ctx *ctx); diff --git a/lib/bitratestats/rte_bitrate.h b/lib/bitratestats/rte_bitrate.h index e494389b95..979a712837 100644 --- a/lib/bitratestats/rte_bitrate.h +++ b/lib/bitratestats/rte_bitrate.h @@ -32,6 +32,7 @@ struct rte_stats_bitrates *rte_stats_bitrate_create(void); * * @param bitrate_data * Pointer allocated by rte_stats_bitrate_create() + * If bitrate_data is NULL, no operation is performed. */ void rte_stats_bitrate_free(struct rte_stats_bitrates *bitrate_data); diff --git a/lib/compressdev/rte_comp.h b/lib/compressdev/rte_comp.h index cdb55e5887..99a48711e4 100644 --- a/lib/compressdev/rte_comp.h +++ b/lib/compressdev/rte_comp.h @@ -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 op is NULL, no operation is performed. */ __rte_experimental void diff --git a/lib/cryptodev/rte_crypto.h b/lib/cryptodev/rte_crypto.h index aeb3bf6e38..6dfca2c169 100644 --- a/lib/cryptodev/rte_crypto.h +++ b/lib/cryptodev/rte_crypto.h @@ -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 op is NULL, no operation is performed. */ static inline void rte_crypto_op_free(struct rte_crypto_op *op) diff --git a/lib/eal/include/rte_interrupts.h b/lib/eal/include/rte_interrupts.h index 68ad19c3e7..9d1d53f46c 100644 --- a/lib/eal/include/rte_interrupts.h +++ b/lib/eal/include/rte_interrupts.h @@ -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 intr_handle is NULL, no operation is performed. * */ __rte_experimental diff --git a/lib/efd/rte_efd.h b/lib/efd/rte_efd.h index d3d7befd0c..89cb4a2483 100644 --- a/lib/efd/rte_efd.h +++ b/lib/efd/rte_efd.h @@ -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 table is NULL, no operation is performed. */ void rte_efd_free(struct rte_efd_table *table); diff --git a/lib/eventdev/rte_event_ring.h b/lib/eventdev/rte_event_ring.h index 0101cc0aa2..7efa64444b 100644 --- a/lib/eventdev/rte_event_ring.h +++ b/lib/eventdev/rte_event_ring.h @@ -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 r is NULL, no operation is performed. */ void rte_event_ring_free(struct rte_event_ring *r); diff --git a/lib/fib/rte_fib.h b/lib/fib/rte_fib.h index 90f28b7e11..baa206093c 100644 --- a/lib/fib/rte_fib.h +++ b/lib/fib/rte_fib.h @@ -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 fib is NULL, no operation is performed. * @return * None */ diff --git a/lib/fib/rte_fib6.h b/lib/fib/rte_fib6.h index 62a425d9af..6fc915b1f3 100644 --- a/lib/fib/rte_fib6.h +++ b/lib/fib/rte_fib6.h @@ -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 fib is NULL, no operation is performed. * @return * None */ diff --git a/lib/lpm/rte_lpm.h b/lib/lpm/rte_lpm.h index 4f38864fde..c8295905e4 100644 --- a/lib/lpm/rte_lpm.h +++ b/lib/lpm/rte_lpm.h @@ -179,6 +179,7 @@ rte_lpm_find_existing(const char *name); * * @param lpm * LPM object handle + * If lpm is NULL, no operation is performed. * @return * None */ diff --git a/lib/lpm/rte_lpm6.h b/lib/lpm/rte_lpm6.h index 9b07260d5a..cd9ce17989 100644 --- a/lib/lpm/rte_lpm6.h +++ b/lib/lpm/rte_lpm6.h @@ -72,6 +72,7 @@ rte_lpm6_find_existing(const char *name); * * @param lpm * LPM object handle + * If lpm is NULL, no operation is performed. * @return * None */ diff --git a/lib/member/rte_member.h b/lib/member/rte_member.h index 567ee0c84b..2611015771 100644 --- a/lib/member/rte_member.h +++ b/lib/member/rte_member.h @@ -443,6 +443,7 @@ rte_member_add(const struct rte_member_setsum *setsum, const void *key, * * @param setsum * Pointer to the set summary. + * If setsum is NULL, no operation is performed. */ void rte_member_free(struct rte_member_setsum *setsum); diff --git a/lib/pipeline/rte_port_in_action.h b/lib/pipeline/rte_port_in_action.h index d6b063cf58..ec2994599f 100644 --- a/lib/pipeline/rte_port_in_action.h +++ b/lib/pipeline/rte_port_in_action.h @@ -181,8 +181,9 @@ rte_port_in_action_profile_create(uint32_t socket_id); * * @param[in] profile * Input port action profile handle (needs to be valid). + * If profile is NULL, no operation is performed. * @return - * Zero on success, non-zero error code otherwise. + * Always zero. */ __rte_experimental int @@ -259,8 +260,9 @@ rte_port_in_action_create(struct rte_port_in_action_profile *profile, * * @param[in] action * Handle to input port action object (needs to be valid). + * If action is NULL, no operation is performed. * @return - * Zero on success, non-zero error code otherwise. + * Always zero. */ __rte_experimental int diff --git a/lib/pipeline/rte_swx_ctl.h b/lib/pipeline/rte_swx_ctl.h index 689f45e3e7..d771389d26 100644 --- a/lib/pipeline/rte_swx_ctl.h +++ b/lib/pipeline/rte_swx_ctl.h @@ -1375,6 +1375,7 @@ rte_swx_ctl_meter_stats_read(struct rte_swx_pipeline *p, * * @param[in] ctl * Pipeline control handle. + * If ctl is NULL, no operation is performed. */ __rte_experimental void diff --git a/lib/pipeline/rte_swx_pipeline.h b/lib/pipeline/rte_swx_pipeline.h index 9299f27094..c41ca5cb15 100644 --- a/lib/pipeline/rte_swx_pipeline.h +++ b/lib/pipeline/rte_swx_pipeline.h @@ -987,6 +987,7 @@ rte_swx_pipeline_run(struct rte_swx_pipeline *p, * * @param[in] p * Pipeline handle. + * If p is NULL, no operation is performed. */ __rte_experimental void diff --git a/lib/reorder/rte_reorder.h b/lib/reorder/rte_reorder.h index 9de0240374..f72f07e645 100644 --- a/lib/reorder/rte_reorder.h +++ b/lib/reorder/rte_reorder.h @@ -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 b is NULL, no operation is performed. * @return * None */ diff --git a/lib/rib/rte_rib.h b/lib/rib/rte_rib.h index c18c4ca594..f41774afe7 100644 --- a/lib/rib/rte_rib.h +++ b/lib/rib/rte_rib.h @@ -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 rib is NULL, no operation is performed. * @return * None */ diff --git a/lib/rib/rte_rib6.h b/lib/rib/rte_rib6.h index fa8e9bf732..8bd99c4ab5 100644 --- a/lib/rib/rte_rib6.h +++ b/lib/rib/rte_rib6.h @@ -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 rib is NULL, no operation is performed. * @return * None */ diff --git a/lib/sched/rte_sched.h b/lib/sched/rte_sched.h index 0bd5b72a4a..a33292b066 100644 --- a/lib/sched/rte_sched.h +++ b/lib/sched/rte_sched.h @@ -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 port is NULL, no operation is performed. */ void rte_sched_port_free(struct rte_sched_port *port); diff --git a/lib/stack/rte_stack.h b/lib/stack/rte_stack.h index 91fc570767..278a5bd0b0 100644 --- a/lib/stack/rte_stack.h +++ b/lib/stack/rte_stack.h @@ -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 s is NULL, no operation is performed. */ void rte_stack_free(struct rte_stack *s); diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h index 3372b32f38..d586dd0fc1 100644 --- a/lib/telemetry/rte_telemetry.h +++ b/lib/telemetry/rte_telemetry.h @@ -293,7 +293,7 @@ rte_tel_data_alloc(void); * * @param data * Pointer to container. - *. + * If data is NULL, no operation is performed. */ void rte_tel_data_free(struct rte_tel_data *data); -- 2.39.5