projects/aports·blob master · refs

96 lines · 3.8 KiB

1Patch-Source: https://github.com/dparrish/libcli/pull/93
2--
3From 42e798e3f8b4a092be26bc91c9f87e5593f0d302 Mon Sep 17 00:00:00 2001
4From: Gwyn Ciesla <[email protected]>
5Date: Wed, 31 Jan 2024 14:40:42 -0600
6Subject: [PATCH] Swap calloc parameters for -Wcalloc-transposed-args
7
8---
9 libcli.c | 18 +++++++++---------
10 1 file changed, 9 insertions(+), 9 deletions(-)
11
12diff --git a/libcli.c b/libcli.c
13index 88c23d8..32ceeae 100644
14--- a/libcli.c
15+++ b/libcli.c
16@@ -427,7 +427,7 @@ struct cli_command *cli_register_command(struct cli_def *cli, struct cli_command
17 struct cli_command *c;
18
19 if (!command) return NULL;
20- if (!(c = calloc(sizeof(struct cli_command), 1))) return NULL;
21+ if (!(c = calloc(1, sizeof(struct cli_command)))) return NULL;
22 c->command_type = CLI_REGULAR_COMMAND;
23 c->callback = callback;
24 c->next = NULL;
25@@ -597,7 +597,7 @@ struct cli_def *cli_init() {
26 struct cli_def *cli;
27 struct cli_command *c;
28
29- if (!(cli = calloc(sizeof(struct cli_def), 1))) return 0;
30+ if (!(cli = calloc(1, sizeof(struct cli_def)))) return 0;
31
32 cli->buf_size = 1024;
33 if (!(cli->buffer = calloc(cli->buf_size, 1))) {
34@@ -1957,7 +1957,7 @@ int cli_match_filter_init(struct cli_def *cli, int argc, char **argv, struct cli
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@@ -2050,7 +2050,7 @@ int cli_range_filter_init(struct cli_def *cli, int argc, char **argv, struct cli
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@@ -2087,7 +2087,7 @@ int cli_count_filter_init(struct cli_def *cli, int argc, UNUSED(char **argv), st
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@@ -2144,7 +2144,7 @@ struct cli_command *cli_register_filter(struct cli_def *cli, const char *command
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@@ -2256,7 +2256,7 @@ struct cli_optarg *cli_register_optarg(struct cli_command *cmd, const char *name
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@@ -2532,7 +2532,7 @@ struct cli_command *cli_int_register_buildmode_command(struct cli_def *cli, stru
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@@ -3095,7 +3095,7 @@ int cli_int_execute_pipeline(struct cli_def *cli, struct cli_pipeline *pipeline)
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;