parse_flag() uses atoi(), which cannot report an error, so a malformed
value is silently taken as zero. The result was only ever used as a
boolean, so use rte_kvargs_handle_bool() and drop the local handler.

This also accepts the usual spellings such as "on" and "true" in
addition to 0 and 1.

The boolean uses rte_kvargs_process_opt(), so that a bare key with no
value enables the option.

Signed-off-by: Stephen Hemminger <[email protected]>
---
 drivers/net/octeon_ep/otx_ep_ethdev.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/net/octeon_ep/otx_ep_ethdev.c 
b/drivers/net/octeon_ep/otx_ep_ethdev.c
index 876d2f9d7d..cec51dc706 100644
--- a/drivers/net/octeon_ep/otx_ep_ethdev.c
+++ b/drivers/net/octeon_ep/otx_ep_ethdev.c
@@ -29,21 +29,11 @@ static const struct rte_eth_desc_lim otx_ep_tx_desc_lim = {
        .nb_align       = OTX_EP_TXD_ALIGN,
 };
 
-static int
-parse_flag(const char *key, const char *value, void *extra_args)
-{
-       RTE_SET_USED(key);
-
-       *(uint8_t *)extra_args = atoi(value);
-
-       return 0;
-}
-
 static int
 otx_ethdev_parse_devargs(struct rte_devargs *devargs, struct otx_ep_device 
*otx_epvf)
 {
        struct rte_kvargs *kvlist;
-       uint8_t ism_enable = 0;
+       bool ism_enable = false;
 
        if (devargs == NULL)
                goto null_devargs;
@@ -52,11 +42,11 @@ otx_ethdev_parse_devargs(struct rte_devargs *devargs, 
struct otx_ep_device *otx_
        if (kvlist == NULL)
                goto exit;
 
-       rte_kvargs_process(kvlist, OTX_ISM_ENABLE, &parse_flag, &ism_enable);
+       rte_kvargs_process_opt(kvlist, OTX_ISM_ENABLE, rte_kvargs_handle_bool, 
&ism_enable);
        rte_kvargs_free(kvlist);
 
 null_devargs:
-       otx_epvf->ism_ena = !!ism_enable;
+       otx_epvf->ism_ena = ism_enable;
 
        return 0;
 
-- 
2.53.0

Reply via email to