[1/9] kvargs: detailed definition of callback prototype

Message ID 20230302074825.31947-2-fengchengwen@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series fix kvargs callback prototype not clearly defined |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

fengchengwen March 2, 2023, 7:48 a.m. UTC
  The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
(which prototype is arg_handler_t) parameter 'value' is NULL when
parsed 'only keys'.

But where there is no detailed definition of 'value' maybe NULL, so
this patch adds it.

Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 lib/kvargs/rte_kvargs.h | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
  

Patch

diff --git a/lib/kvargs/rte_kvargs.h b/lib/kvargs/rte_kvargs.h
index 359a9f5b09..4900b750bc 100644
--- a/lib/kvargs/rte_kvargs.h
+++ b/lib/kvargs/rte_kvargs.h
@@ -36,7 +36,19 @@  extern "C" {
 /** separator character used between key and value */
 #define RTE_KVARGS_KV_DELIM	"="
 
-/** Type of callback function used by rte_kvargs_process() */
+/**
+ * Callback prototype used by rte_kvargs_process().
+ *
+ * @param key
+ *   The key to consider, it will not be NULL.
+ * @param value
+ *   The value corresponding to the key, it may be NULL (e.g. only with key)
+ * @param opaque
+ *   An opaque pointer coming from the caller.
+ * @return
+ *   - >=0 handle key success.
+ *   - <0 on error.
+ */
 typedef int (*arg_handler_t)(const char *key, const char *value, void *opaque);
 
 /** A key/value association */