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 18:45:04 +0100 |
commit | 241b5d3ebeea21b70a74fdc8c74e73f7ed829cb1 (patch) | |
tree | 2912c1f5896fb1356a4ba09fa48129e1a5dd310f /ref-filter.c | |
parent | Merge branch 'tb/ci-run-cocci-with-18.04' into maint (diff) | |
download | git-241b5d3ebeea21b70a74fdc8c74e73f7ed829cb1.tar.xz git-241b5d3ebeea21b70a74fdc8c74e73f7ed829cb1.zip |
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 'ref-filter.c')
-rw-r--r-- | ref-filter.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ref-filter.c b/ref-filter.c index ee337df232..033cd4f9f2 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -768,7 +768,8 @@ static int if_atom_handler(struct atom_value *atomv, struct ref_formatting_state struct strbuf *unused_err) { struct ref_formatting_stack *new_stack; - struct if_then_else *if_then_else = xcalloc(sizeof(struct if_then_else), 1); + struct if_then_else *if_then_else = xcalloc(1, + sizeof(struct if_then_else)); if_then_else->str = atomv->atom->u.if_then_else.str; if_then_else->cmp_status = atomv->atom->u.if_then_else.cmp_status; @@ -2242,7 +2243,7 @@ static void reach_filter(struct ref_array *array, if (!check_reachable) return; - to_clear = xcalloc(sizeof(struct commit *), array->nr); + to_clear = xcalloc(array->nr, sizeof(struct commit *)); repo_init_revisions(the_repository, &revs, NULL); |