[PATCH 28/62] net/cpfl: use kvargs numeric helpers
Stephen Hemminger
stephen at networkplumber.org
Mon Sep 14 07:46:59 CEST 2026
parse_bool() only tested errno for ERANGE and ignored the end pointer, so
"1junk" was accepted.
It also stored through an int pointer, but both device arguments are bool
fields, so parsing either wrote four bytes into a one byte object.
The handler did nothing beyond a range checked store of a boolean, so
drop it and pass rte_kvargs_handle_bool() directly, which stores a bool
and also accepts the usual spellings such as "on" and "true".
The booleans use rte_kvargs_process_opt(), so that a bare key with no
value enables the option.
Bugzilla ID: 2042
Fixes: 2d823ecd671c ("net/cpfl: support device initialization")
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
drivers/net/intel/cpfl/cpfl_ethdev.c | 26 +++-----------------------
1 file changed, 3 insertions(+), 23 deletions(-)
diff --git a/drivers/net/intel/cpfl/cpfl_ethdev.c b/drivers/net/intel/cpfl/cpfl_ethdev.c
index 4315adb68c..6e6401a9ce 100644
--- a/drivers/net/intel/cpfl/cpfl_ethdev.c
+++ b/drivers/net/intel/cpfl/cpfl_ethdev.c
@@ -3,6 +3,7 @@
*/
#include <rte_atomic.h>
+#include <rte_kvargs.h>
#include <rte_eal.h>
#include <rte_ether.h>
#include <rte_malloc.h>
@@ -1445,27 +1446,6 @@ parse_vport(const char *key, const char *value, void *args)
return 0;
}
-static int
-parse_bool(const char *key, const char *value, void *args)
-{
- int *i = args;
- char *end;
- int num;
-
- errno = 0;
-
- num = strtoul(value, &end, 10);
-
- if (errno == ERANGE || (num != 0 && num != 1)) {
- PMD_INIT_LOG(ERR, "invalid value:\"%s\" for key:\"%s\", value must be 0 or 1",
- value, key);
- return -EINVAL;
- }
-
- *i = num;
- return 0;
-}
-
static int
enlist(uint16_t *list, uint16_t *len_list, const uint16_t max_list, uint16_t val)
{
@@ -1643,12 +1623,12 @@ cpfl_parse_devargs(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adap
if (ret != 0)
goto fail;
- ret = rte_kvargs_process(kvlist, CPFL_TX_SINGLE_Q, &parse_bool,
+ ret = rte_kvargs_process_opt(kvlist, CPFL_TX_SINGLE_Q, rte_kvargs_handle_bool,
&adapter->base.is_tx_singleq);
if (ret != 0)
goto fail;
- ret = rte_kvargs_process(kvlist, CPFL_RX_SINGLE_Q, &parse_bool,
+ ret = rte_kvargs_process_opt(kvlist, CPFL_RX_SINGLE_Q, rte_kvargs_handle_bool,
&adapter->base.is_rx_singleq);
if (ret != 0)
goto fail;
--
2.53.0
More information about the dev
mailing list