mirror of
https://github.com/git/git.git
synced 2024-11-18 22:14:34 +01:00
Merge branch 'rs/xcalloc-takes-nelem-first'
Code cleanup. * rs/xcalloc-takes-nelem-first: fix xcalloc() argument order
This commit is contained in:
commit
bfcc6e2a68
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
|
10
contrib/coccinelle/xcalloc.cocci
Normal file
10
contrib/coccinelle/xcalloc.cocci
Normal file
@ -0,0 +1,10 @@
|
||||
@@
|
||||
type T;
|
||||
T *ptr;
|
||||
expression n;
|
||||
@@
|
||||
xcalloc(
|
||||
+ n,
|
||||
\( sizeof(T) \| sizeof(*ptr) \)
|
||||
- , n
|
||||
)
|
@ -772,7 +772,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;
|
||||
|
@ -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;
|
||||
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user