[2/4] argparse: remove dead code

Message ID 20240220131502.47510-3-fengchengwen@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series refine argparse library |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chengwen Feng Feb. 20, 2024, 1:15 p.m. UTC
  The judgement "obj->callback == NULL" is dead code which can't be
reached, because verify_arg_saver() already make sure obj->callback
must not be NULL when arg->val_saver is NULL.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test/test_argparse.c    | 7 -------
 lib/argparse/rte_argparse.c | 6 ------
 2 files changed, 13 deletions(-)
  

Patch

diff --git a/app/test/test_argparse.c b/app/test/test_argparse.c
index df11a129ba..c98bcee56d 100644
--- a/app/test/test_argparse.c
+++ b/app/test/test_argparse.c
@@ -288,13 +288,6 @@  test_argparse_invalid_arg_flags(void)
 	ret = rte_argparse_parse(obj, default_argc, default_argv);
 	TEST_ASSERT(ret == -EINVAL, "Argparse parse expect failed!");
 
-	obj = test_argparse_init_obj();
-	obj->args[0].val_saver = NULL;
-	obj->args[0].flags = RTE_ARGPARSE_ARG_REQUIRED_VALUE | RTE_ARGPARSE_ARG_SUPPORT_MULTI;
-	obj->callback = NULL;
-	ret = rte_argparse_parse(obj, default_argc, default_argv);
-	TEST_ASSERT(ret == -EINVAL, "Argparse parse expect failed!");
-
 	return 0;
 }
 
diff --git a/lib/argparse/rte_argparse.c b/lib/argparse/rte_argparse.c
index 48738cd07b..6e890cdc0d 100644
--- a/lib/argparse/rte_argparse.c
+++ b/lib/argparse/rte_argparse.c
@@ -195,12 +195,6 @@  verify_arg_flags(const struct rte_argparse *obj, uint32_t index)
 		return -EINVAL;
 	}
 
-	if (obj->callback == NULL) {
-		ARGPARSE_LOG(ERR, "argument %s should use callback to parse, but callback is NULL!",
-			     arg->name_long);
-		return -EINVAL;
-	}
-
 	return 0;
 }