[PATCH 42/62] net/nfp: use kvargs numeric helpers
Stephen Hemminger
stephen at networkplumber.org
Mon Sep 14 07:47:13 CEST 2026
nfp_devarg_handle_int() infers overflow from the result being ULONG_MAX
rather than checking errno, so the literal value 18446744073709551615 is
rejected while a genuine overflow of any other value is not detected.
Both users of it parse a boolean, so use rte_kvargs_handle_bool() and
drop the local handler along with the open coded 0/1 check. The
documented "=0" and "=1" forms still work, and the usual spellings such
as "on" and "true" are now accepted as well.
The boolean uses rte_kvargs_process_opt(), so that a bare key with no
value enables the option.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
drivers/net/nfp/nfp_ethdev.c | 36 ++----------------------------------
1 file changed, 2 insertions(+), 34 deletions(-)
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index d2da18013c..37005a3cea 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -48,28 +48,6 @@ struct nfp_net_init {
struct nfp_net_hw_priv *hw_priv;
};
-static int
-nfp_devarg_handle_int(const char *key,
- const char *value,
- void *extra_args)
-{
- char *end_ptr;
- uint64_t *num = extra_args;
-
- if (value == NULL)
- return -EPERM;
-
- *num = strtoul(value, &end_ptr, 10);
- if (*num == ULONG_MAX) {
- PMD_DRV_LOG(ERR, "%s: '%s' is not a valid param.", key, value);
- return -ERANGE;
- } else if (value == end_ptr) {
- return -EPERM;
- }
-
- return 0;
-}
-
static int
nfp_devarg_parse_bool_para(struct rte_kvargs *kvlist,
const char *key_match,
@@ -77,7 +55,6 @@ nfp_devarg_parse_bool_para(struct rte_kvargs *kvlist,
{
int ret;
uint32_t count;
- uint64_t value;
count = rte_kvargs_count(kvlist, key_match);
if (count == 0)
@@ -88,20 +65,11 @@ nfp_devarg_parse_bool_para(struct rte_kvargs *kvlist,
return -EINVAL;
}
- ret = rte_kvargs_process(kvlist, key_match, &nfp_devarg_handle_int, &value);
+ ret = rte_kvargs_process_opt(kvlist, key_match, rte_kvargs_handle_bool,
+ value_ret);
if (ret != 0)
return -EINVAL;
- if (value == 1) {
- *value_ret = true;
- } else if (value == 0) {
- *value_ret = false;
- } else {
- PMD_DRV_LOG(ERR, "The param does not work, the format is %s=0/1.",
- key_match);
- return -EINVAL;
- }
-
return 0;
}
--
2.53.0
More information about the dev
mailing list