[v4,2/6] argparse: remove dead code
Checks
Commit Message
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(-)
@@ -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;
}
@@ -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;
}