Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rz_cmd_desc_get_arg: Remove unused cmd param #4427

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions librz/core/cautocmpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ static size_t get_arg_number(TSNode arg) {
* command \p cd . This is based on the type of argument a command may accept.
*/
static void autocmplt_cmd_arg(RzCore *core, RzLineNSCompletionResult *res, const RzCmdDesc *cd, size_t i_arg, const char *s, size_t len) {
const RzCmdDescArg *arg = rz_cmd_desc_get_arg(core->rcmd, cd, i_arg);
const RzCmdDescArg *arg = rz_cmd_desc_get_arg(cd, i_arg);
if (!arg) {
return;
}
Expand Down Expand Up @@ -771,7 +771,7 @@ static bool fill_autocmplt_data_cmdarg(struct autocmplt_data_t *ad, ut32 start,

ad->i_arg = get_arg_number(node);

const RzCmdDescArg *arg = rz_cmd_desc_get_arg(core->rcmd, ad->cd, ad->i_arg);
const RzCmdDescArg *arg = rz_cmd_desc_get_arg(ad->cd, ad->i_arg);
if (!arg) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion librz/core/cmd/cmd_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -2204,7 +2204,7 @@ RZ_API bool rz_cmd_desc_remove(RzCmd *cmd, RzCmdDesc *cd) {
* \p RZ_CMD_ARG_FLAG_ARRAY, where even if there is just one RzCmdDescArg,
* everything is considered as part of the same RzCmdDescArg.
*/
RZ_API const RzCmdDescArg *rz_cmd_desc_get_arg(RzCmd *cmd, const RzCmdDesc *cd, size_t i) {
RZ_API const RzCmdDescArg *rz_cmd_desc_get_arg(const RzCmdDesc *cd, size_t i) {
const RzCmdDescArg *arg = cd->help->args;
size_t j = 0;
while (arg && arg->name) {
Expand Down
2 changes: 1 addition & 1 deletion librz/include/rz_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ RZ_API bool rz_cmd_desc_set_default_mode(RzCmdDesc *cd, RzOutputMode mode);
RZ_API bool rz_cmd_desc_has_handler(const RzCmdDesc *cd);
RZ_API bool rz_cmd_desc_remove(RzCmd *cmd, RzCmdDesc *cd);
RZ_API void rz_cmd_foreach_cmdname(RzCmd *cmd, RzCmdDesc *begin, RzCmdForeachNameCb cb, void *user);
RZ_API const RzCmdDescArg *rz_cmd_desc_get_arg(RzCmd *cmd, const RzCmdDesc *cd, size_t i);
RZ_API const RzCmdDescArg *rz_cmd_desc_get_arg(const RzCmdDesc *cd, size_t i);

#define rz_cmd_desc_children_foreach(root, it_cd) rz_pvector_foreach (&root->children, it_cd)

Expand Down
12 changes: 6 additions & 6 deletions test/unit/test_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -958,18 +958,18 @@ bool test_get_arg(void) {
RzCmdDesc *z_cd = rz_cmd_desc_argv_new(cmd, root, "z", z_last_handler, &z_help);
RzCmdDesc *x_cd = rz_cmd_desc_argv_new(cmd, root, "x", x_array_handler, &x_help);

const RzCmdDescArg *a1 = rz_cmd_desc_get_arg(cmd, z_cd, 0);
const RzCmdDescArg *a1 = rz_cmd_desc_get_arg(z_cd, 0);
mu_assert_streq(a1->name, "a1", "0th arg of z is a1");
const RzCmdDescArg *a2 = rz_cmd_desc_get_arg(cmd, z_cd, 1);
const RzCmdDescArg *a2 = rz_cmd_desc_get_arg(z_cd, 1);
mu_assert_streq(a2->name, "a2", "1th arg of z is a2");
const RzCmdDescArg *an = rz_cmd_desc_get_arg(cmd, z_cd, 10);
const RzCmdDescArg *an = rz_cmd_desc_get_arg(z_cd, 10);
mu_assert_streq(an->name, "a2", "10th arg of z is a2");

const RzCmdDescArg *b1 = rz_cmd_desc_get_arg(cmd, x_cd, 0);
const RzCmdDescArg *b1 = rz_cmd_desc_get_arg(x_cd, 0);
mu_assert_streq(b1->name, "b1", "0th arg of x is b1");
const RzCmdDescArg *b2 = rz_cmd_desc_get_arg(cmd, x_cd, 1);
const RzCmdDescArg *b2 = rz_cmd_desc_get_arg(x_cd, 1);
mu_assert_streq(b2->name, "b2", "1th arg of x is b2");
const RzCmdDescArg *bn = rz_cmd_desc_get_arg(cmd, x_cd, 10);
const RzCmdDescArg *bn = rz_cmd_desc_get_arg(x_cd, 10);
mu_assert_null(bn, "10th arg of x does not exist");

rz_cmd_free(cmd);
Expand Down
Loading