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

Message ID 20230302075012.32423-2-fengchengwen@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
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:50 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(-)
  

Comments

Olivier Matz March 9, 2023, 1:12 p.m. UTC | #1
Hi Chengwen,

The patch looks good to me.
Please find below few minor style comments.

On Thu, Mar 02, 2023 at 07:50:04AM +0000, Chengwen Feng wrote:
> [PATCH 1/9] kvargs: detailed definition of callback prototype

kvargs: add API documentation for process callback

>
> The rte_kvargs_process() was used to parse KV pairs, it also supports

was -> is

> 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'.

parsed -> parsing

> 
> But where there is no detailed definition of 'value' maybe NULL, so

-where

maybe -> may be

> this patch adds it.
> 
> Cc: stable@dpdk.org
> 
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>

With this:
Acked-by: Olivier Matz <zer0@droids-corp.org>

Thanks!

> ---
>  lib/kvargs/rte_kvargs.h | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> 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 */
> -- 
> 2.17.1
>
  

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 */