Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2021-03-06 14:26:19 +0300
committerJunio C Hamano <gitster@pobox.com>2021-03-08 20:45:04 +0300
commit241b5d3ebeea21b70a74fdc8c74e73f7ed829cb1 (patch)
tree2912c1f5896fb1356a4ba09fa48129e1a5dd310f /trailer.c
parent59ec22464f6c2b170b05f287e00740ea2288fe5c (diff)
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 'trailer.c')
-rw-r--r--trailer.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/trailer.c b/trailer.c
index 3f7391d793..61ffbf6066 100644
--- a/trailer.c
+++ b/trailer.c
@@ -174,7 +174,7 @@ static void print_all(FILE *outfile, struct list_head *head,
static struct trailer_item *trailer_from_arg(struct arg_item *arg_tok)
{
- struct trailer_item *new_item = xcalloc(sizeof(*new_item), 1);
+ struct trailer_item *new_item = xcalloc(1, sizeof(*new_item));
new_item->token = arg_tok->token;
new_item->value = arg_tok->value;
arg_tok->token = arg_tok->value = NULL;
@@ -445,7 +445,7 @@ static struct arg_item *get_conf_item(const char *name)
}
/* Item does not already exists, create it */
- item = xcalloc(sizeof(*item), 1);
+ item = xcalloc(1, sizeof(*item));
duplicate_conf(&item->conf, &default_conf_info);
item->conf.name = xstrdup(name);
@@ -664,7 +664,7 @@ static void parse_trailer(struct strbuf *tok, struct strbuf *val,
static struct trailer_item *add_trailer_item(struct list_head *head, char *tok,
char *val)
{
- struct trailer_item *new_item = xcalloc(sizeof(*new_item), 1);
+ struct trailer_item *new_item = xcalloc(1, sizeof(*new_item));
new_item->token = tok;
new_item->value = val;
list_add_tail(&new_item->list, head);
@@ -675,7 +675,7 @@ static void add_arg_item(struct list_head *arg_head, char *tok, char *val,
const struct conf_info *conf,
const struct new_trailer_item *new_trailer_item)
{
- struct arg_item *new_item = xcalloc(sizeof(*new_item), 1);
+ struct arg_item *new_item = xcalloc(1, sizeof(*new_item));
new_item->token = tok;
new_item->value = val;
duplicate_conf(&new_item->conf, conf);