b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | --- a/libcli.c |
| 2 | +++ b/libcli.c |
| 3 | @@ -427,7 +427,7 @@ struct cli_command *cli_register_command |
| 4 | struct cli_command *c; |
| 5 | |
| 6 | if (!command) return NULL; |
| 7 | - if (!(c = calloc(sizeof(struct cli_command), 1))) return NULL; |
| 8 | + if (!(c = calloc(1, sizeof(struct cli_command)))) return NULL; |
| 9 | c->command_type = CLI_REGULAR_COMMAND; |
| 10 | c->callback = callback; |
| 11 | c->next = NULL; |
| 12 | @@ -597,10 +597,10 @@ struct cli_def *cli_init() { |
| 13 | struct cli_def *cli; |
| 14 | struct cli_command *c; |
| 15 | |
| 16 | - if (!(cli = calloc(sizeof(struct cli_def), 1))) return 0; |
| 17 | + if (!(cli = calloc(1, sizeof(struct cli_def)))) return 0; |
| 18 | |
| 19 | cli->buf_size = 1024; |
| 20 | - if (!(cli->buffer = calloc(cli->buf_size, 1))) { |
| 21 | + if (!(cli->buffer = calloc(1, cli->buf_size))) { |
| 22 | cli_done(cli); |
| 23 | return 0; |
| 24 | } |
| 25 | @@ -778,7 +778,7 @@ static char *cli_int_return_newword(cons |
| 26 | |
| 27 | // allocate space (including terminal NULL, then go through and deal with escaping characters as we copy them |
| 28 | |
| 29 | - if (!(newword = calloc(len + 1, 1))) return 0; |
| 30 | + if (!(newword = calloc(1, len + 1))) return 0; |
| 31 | to = newword; |
| 32 | while (start != end) { |
| 33 | if (*start == '\\') |
| 34 | @@ -1940,7 +1940,7 @@ int cli_match_filter_init(struct cli_def |
| 35 | char *search_flags = cli_get_optarg_value(cli, "search_flags", NULL); |
| 36 | |
| 37 | filt->filter = cli_match_filter; |
| 38 | - filt->data = state = calloc(sizeof(struct cli_match_filter_state), 1); |
| 39 | + filt->data = state = calloc(1, sizeof(struct cli_match_filter_state)); |
| 40 | if (!state) return CLI_ERROR; |
| 41 | |
| 42 | if (!strcmp(cli->pipeline->current_stage->words[0], "include")) { |
| 43 | @@ -2033,7 +2033,7 @@ int cli_range_filter_init(struct cli_def |
| 44 | // from the command line processing and continue |
| 45 | |
| 46 | filt->filter = cli_range_filter; |
| 47 | - filt->data = state = calloc(sizeof(struct cli_range_filter_state), 1); |
| 48 | + filt->data = state = calloc(1, sizeof(struct cli_range_filter_state)); |
| 49 | if (state) { |
| 50 | state->from = from; |
| 51 | state->to = to; |
| 52 | @@ -2070,7 +2070,7 @@ int cli_count_filter_init(struct cli_def |
| 53 | } |
| 54 | |
| 55 | filt->filter = cli_count_filter; |
| 56 | - if (!(filt->data = calloc(sizeof(int), 1))) return CLI_ERROR; |
| 57 | + if (!(filt->data = calloc(1, sizeof(int)))) return CLI_ERROR; |
| 58 | |
| 59 | return CLI_OK; |
| 60 | } |
| 61 | @@ -2127,7 +2127,7 @@ struct cli_command *cli_register_filter( |
| 62 | struct cli_command *c; |
| 63 | |
| 64 | if (!command) return NULL; |
| 65 | - if (!(c = calloc(sizeof(struct cli_command), 1))) return NULL; |
| 66 | + if (!(c = calloc(1, sizeof(struct cli_command)))) return NULL; |
| 67 | |
| 68 | c->command_type = CLI_FILTER_COMMAND; |
| 69 | c->init = init; |
| 70 | @@ -2239,7 +2239,7 @@ struct cli_optarg *cli_register_optarg(s |
| 71 | goto CLEANUP; |
| 72 | } |
| 73 | } |
| 74 | - if (!(optarg = calloc(sizeof(struct cli_optarg), 1))) goto CLEANUP; |
| 75 | + if (!(optarg = calloc(1, sizeof(struct cli_optarg)))) goto CLEANUP; |
| 76 | if (!(optarg->name = strdup(name))) goto CLEANUP; |
| 77 | if (help && !(optarg->help = strdup(help))) goto CLEANUP; |
| 78 | |
| 79 | @@ -2505,7 +2505,7 @@ struct cli_command *cli_int_register_bui |
| 80 | struct cli_command *c; |
| 81 | |
| 82 | if (!command) return NULL; |
| 83 | - if (!(c = calloc(sizeof(struct cli_command), 1))) return NULL; |
| 84 | + if (!(c = calloc(1, sizeof(struct cli_command)))) return NULL; |
| 85 | |
| 86 | c->flags = flags; |
| 87 | c->callback = callback; |
| 88 | @@ -3068,7 +3068,7 @@ int cli_int_execute_pipeline(struct cli_ |
| 89 | struct cli_pipeline_stage *stage = &pipeline->stage[stage_num]; |
| 90 | pipeline->current_stage = stage; |
| 91 | cli->found_optargs = stage->found_optargs; |
| 92 | - *filt = calloc(sizeof(struct cli_filter), 1); |
| 93 | + *filt = calloc(1, sizeof(struct cli_filter)); |
| 94 | if (*filt) { |
| 95 | if ((rc = stage->command->init(cli, stage->num_words, stage->words, *filt) != CLI_OK)) { |
| 96 | break; |