diff options
author | René Scharfe <l.s.r@web.de> | 2021-03-06 12:26:19 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-03-08 09:45:04 -0800 |
commit | 241b5d3ebeea21b70a74fdc8c74e73f7ed829cb1 (patch) | |
tree | 2912c1f5896fb1356a4ba09fa48129e1a5dd310f /add-interactive.c | |
parent | Merge branch 'tb/ci-run-cocci-with-18.04' into maint (diff) | |
download | tgif-241b5d3ebeea21b70a74fdc8c74e73f7ed829cb1.tar.xz |
fix xcalloc() argument order
Pass the number of elements first and ther size second, as expected
by xcalloc(). Provide a semantic patch, which was actually used to
generate the rest of this patch.
The semantic patch would generate flip-flop diffs if both arguments
are sizeofs. We don't have such a case, and it's hard to imagine
the usefulness of such an allocation. If it ever occurs then we
could deal with it by duplicating the rule in the semantic patch to
make it cancel itself out, or we could change the code to use
CALLOC_ARRAY.
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'add-interactive.c')
-rw-r--r-- | add-interactive.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/add-interactive.c b/add-interactive.c index 9b8cdb4a31..09faee0e8f 100644 --- a/add-interactive.c +++ b/add-interactive.c @@ -413,7 +413,7 @@ struct file_item { static void add_file_item(struct string_list *files, const char *name) { - struct file_item *item = xcalloc(sizeof(*item), 1); + struct file_item *item = xcalloc(1, sizeof(*item)); string_list_append(files, name)->util = item; } @@ -476,7 +476,7 @@ static void collect_changes_cb(struct diff_queue_struct *q, add_file_item(s->files, name); - entry = xcalloc(sizeof(*entry), 1); + entry = xcalloc(1, sizeof(*entry)); hashmap_entry_init(&entry->ent, hash); entry->name = s->files->items[s->files->nr - 1].string; entry->item = s->files->items[s->files->nr - 1].util; @@ -1120,7 +1120,7 @@ int run_add_i(struct repository *r, const struct pathspec *ps) int res = 0; for (i = 0; i < ARRAY_SIZE(command_list); i++) { - struct command_item *util = xcalloc(sizeof(*util), 1); + struct command_item *util = xcalloc(1, sizeof(*util)); util->command = command_list[i].command; string_list_append(&commands.items, command_list[i].string) ->util = util; |