parse_bool() only tested errno for ERANGE and ignored the end pointer, so "1junk" was accepted.
The handler did nothing else beyond a range checked store of a boolean, so drop it and pass rte_kvargs_handle_bool() directly, which 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. Signed-off-by: Stephen Hemminger <[email protected]> --- drivers/net/intel/idpf/idpf_ethdev.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/drivers/net/intel/idpf/idpf_ethdev.c b/drivers/net/intel/idpf/idpf_ethdev.c index 6a874bfa08..ebc986a04c 100644 --- a/drivers/net/intel/idpf/idpf_ethdev.c +++ b/drivers/net/intel/idpf/idpf_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> @@ -1240,27 +1241,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) -{ - bool *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 == 1); - return 0; -} - static int idpf_parse_devargs(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adapter, struct idpf_devargs *idpf_args) @@ -1303,12 +1283,12 @@ idpf_parse_devargs(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adap if (ret != 0) goto bail; - ret = rte_kvargs_process(kvlist, IDPF_TX_SINGLE_Q, &parse_bool, + ret = rte_kvargs_process_opt(kvlist, IDPF_TX_SINGLE_Q, rte_kvargs_handle_bool, &adapter->base.is_tx_singleq); if (ret != 0) goto bail; - ret = rte_kvargs_process(kvlist, IDPF_RX_SINGLE_Q, &parse_bool, + ret = rte_kvargs_process_opt(kvlist, IDPF_RX_SINGLE_Q, rte_kvargs_handle_bool, &adapter->base.is_rx_singleq); if (ret != 0) goto bail; -- 2.53.0

