[v4,4/5] common/nfp: use new API to parse kvargs

Message ID 20231105054539.22303-5-fengchengwen@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series fix segment fault when parse args |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

fengchengwen Nov. 5, 2023, 5:45 a.m. UTC
  The nfp_parse_class_options() function could handle both key=value and
only-key, so it should use rte_kvargs_process_opt() instead of
rte_kvargs_process() to parse.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 drivers/common/nfp/nfp_common_pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Stephen Hemminger Nov. 6, 2023, 3:19 a.m. UTC | #1
On Sun, 5 Nov 2023 05:45:38 +0000
Chengwen Feng <fengchengwen@huawei.com> wrote:

>  	if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
> -		rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
> -				nfp_kvarg_dev_class_handler, &dev_class);
> +		rte_kvargs_process_opt(kvargs, RTE_DEVARGS_KEY_CLASS,
> +				       nfp_kvarg_dev_class_handler, &dev_class);
>  	}

Since kvargs_process() already does a scan, the kvargs_count() cause an extra pass.
  
fengchengwen Nov. 6, 2023, 7:22 a.m. UTC | #2
Hi Stephen,

On 2023/11/6 11:19, Stephen Hemminger wrote:
> On Sun, 5 Nov 2023 05:45:38 +0000
> Chengwen Feng <fengchengwen@huawei.com> wrote:
> 
>>  	if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
>> -		rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
>> -				nfp_kvarg_dev_class_handler, &dev_class);
>> +		rte_kvargs_process_opt(kvargs, RTE_DEVARGS_KEY_CLASS,
>> +				       nfp_kvarg_dev_class_handler, &dev_class);
>>  	}
> 
> Since kvargs_process() already does a scan, the kvargs_count() cause an extra pass.

will fix in v5

Thanks
Chengwen

> 
> .
>
  

Patch

diff --git a/drivers/common/nfp/nfp_common_pci.c b/drivers/common/nfp/nfp_common_pci.c
index 723035d0f7..ac0a363992 100644
--- a/drivers/common/nfp/nfp_common_pci.c
+++ b/drivers/common/nfp/nfp_common_pci.c
@@ -171,8 +171,8 @@  nfp_parse_class_options(const struct rte_devargs *devargs)
 		return dev_class;
 
 	if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
-		rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
-				nfp_kvarg_dev_class_handler, &dev_class);
+		rte_kvargs_process_opt(kvargs, RTE_DEVARGS_KEY_CLASS,
+				       nfp_kvarg_dev_class_handler, &dev_class);
 	}
 
 	rte_kvargs_free(kvargs);