gcc 14 introduced a new silly warning flag -Wcalloc-transposed-args
that is enabled by default.
Fix by swapping all the arguments to calloc causing trouble by this
new warning.
Signed-off-by: Nico Sonack <nsonack@herrhotzenplotz.de>
---
src/cmd/cmdconfig.c | 8 ++++----
src/cmd/gcli.c | 2 +-
src/cmd/pull_reviews.c | 2 +-
src/cmd/table.c | 8 ++++----
src/diffutil.c | 8 ++++----
src/gcli.c | 2 +-
6 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/cmd/cmdconfig.c b/src/cmd/cmdconfig.c
index a48ec08..12cb2a5 100644
--- a/src/cmd/cmdconfig.c
+++ b/src/cmd/cmdconfig.c
@@ -236,7 +236,7 @@ init_local_config(struct gcli_ctx *ctx)
sn_sv value = sn_sv_trim(line);
- struct gcli_config_entry *entry = calloc(sizeof(*entry), 1);
+ struct gcli_config_entry *entry = calloc(1, sizeof(*entry));
TAILQ_INSERT_TAIL(&dgcli->entries, entry, next);
entry->key = key;
@@ -289,7 +289,7 @@ static void
parse_section_entry(struct config_parser *input,
struct gcli_config_section *section)
{
- struct gcli_config_entry *entry = calloc(sizeof(*entry), 1);
+ struct gcli_config_entry *entry = calloc(1, sizeof(*entry));
TAILQ_INSERT_TAIL(§ion->entries, entry, next);
sn_sv key = sn_sv_chop_until(&input->buffer, '=');
@@ -343,7 +343,7 @@ parse_config_section(struct gcli_config *cfg,
{
struct gcli_config_section *section = NULL;
- section = calloc(sizeof(*section), 1);
+ section = calloc(1, sizeof(*section));
TAILQ_INSERT_TAIL(&cfg->sections, section, next);
section->title = parse_section_title(input);
@@ -486,7 +486,7 @@ readenv(struct gcli_config *cfg)
int
gcli_config_init_ctx(struct gcli_ctx *ctx)
{
- struct cmd_ctx *cctx = calloc(sizeof(*cctx), 1);
+ struct cmd_ctx *cctx = calloc(1, sizeof(*cctx));
gcli_set_userdata(ctx, cctx);
cctx->config.sections =
diff --git a/src/cmd/gcli.c b/src/cmd/gcli.c
index 8942217..2411b13 100644
--- a/src/cmd/gcli.c
+++ b/src/cmd/gcli.c
@@ -325,7 +325,7 @@ install_aliases(void)
static void
setup_subcommand_table(void)
{
- subcommands = calloc(sizeof(*subcommands), ARRAY_SIZE(default_subcommands));
+ subcommands = calloc(ARRAY_SIZE(default_subcommands), sizeof(*subcommands));
memcpy(subcommands, default_subcommands, sizeof(default_subcommands));
subcommands_size = ARRAY_SIZE(default_subcommands);
}
diff --git a/src/cmd/pull_reviews.c b/src/cmd/pull_reviews.c
index d4bd0af..49dbe72 100644
--- a/src/cmd/pull_reviews.c
+++ b/src/cmd/pull_reviews.c
@@ -145,7 +145,7 @@ process_series_prelude(char *prelude, struct gcli_pull_create_review_details *de
char *meta = calloc(line_len - gcli_pref_len + 1, 1);
memcpy(meta, bol + gcli_pref_len, line_len - gcli_pref_len);
- ml = calloc(sizeof(*ml), 1);
+ ml = calloc(1, sizeof(*ml));
ml->entry = meta;
TAILQ_INSERT_TAIL(&details->meta_lines, ml, next);
diff --git a/src/cmd/table.c b/src/cmd/table.c
index 4227a37..0701e78 100644
--- a/src/cmd/table.c
+++ b/src/cmd/table.c
@@ -81,12 +81,12 @@ gcli_tbl_begin(struct gcli_tblcoldef const *const cols, size_t const cols_size)
struct gcli_tbl *tbl;
/* Allocate the structure and fill in the handle */
- tbl = calloc(sizeof(*tbl), 1);
+ tbl = calloc(1, sizeof(*tbl));
if (!tbl)
return NULL;
/* Reserve memory for the column sizes */
- tbl->col_widths = calloc(sizeof(*tbl->col_widths), cols_size);
+ tbl->col_widths = calloc(cols_size, sizeof(*tbl->col_widths));
if (!tbl->col_widths) {
free(tbl);
return NULL;
@@ -194,7 +194,7 @@ gcli_tbl_add_row(gcli_tbl _table, ...)
struct gcli_tbl *table = (struct gcli_tbl *)(_table);
/* reserve array of cells */
- row.cells = calloc(sizeof(*row.cells), table->cols_size);
+ row.cells = calloc(table->cols_size, sizeof(*row.cells));
if (!row.cells)
return -1;
@@ -357,7 +357,7 @@ struct gcli_dict {
gcli_dict
gcli_dict_begin(void)
{
- return calloc(sizeof(struct gcli_dict), 1);
+ return calloc(1, sizeof(struct gcli_dict));
}
static int
diff --git a/src/diffutil.c b/src/diffutil.c
index e9b7b1b..96c10b7 100644
--- a/src/diffutil.c
+++ b/src/diffutil.c
@@ -127,7 +127,7 @@ gcli_parse_patch(struct gcli_diff_parser *parser, struct gcli_patch *out)
/* TODO cleanup */
while (parser->hd[0] == 'd') {
- struct gcli_diff *d = calloc(sizeof(*d), 1);
+ struct gcli_diff *d = calloc(1, sizeof(*d));
if (gcli_parse_diff(parser, d) < 0)
return -1;
@@ -620,7 +620,7 @@ gcli_parse_diff(struct gcli_diff_parser *parser, struct gcli_diff *out)
parser->diff_line_offset = 0;
TAILQ_INIT(&out->hunks);
while (parser->hd[0] == '@') {
- struct gcli_diff_hunk *hunk = calloc(sizeof(*hunk), 1);
+ struct gcli_diff_hunk *hunk = calloc(1, sizeof(*hunk));
if (parse_hunk_range_info(parser, hunk) < 0) {
free(hunk);
@@ -674,7 +674,7 @@ gcli_parse_patch_series(struct gcli_diff_parser *parser,
return -1;
while (parser->hd[0] != '\0') {
- struct gcli_patch *p = calloc(sizeof(*p), 1);
+ struct gcli_patch *p = calloc(1, sizeof(*p));
TAILQ_INSERT_TAIL(&series->patches, p, next);
if (gcli_parse_patch(parser, p) < 0)
@@ -777,7 +777,7 @@ static struct gcli_diff_comment *
make_comment(struct comment_read_ctx *ctx, char *text,
struct hunk_line_info const *line_info, int diff_line_offset)
{
- struct gcli_diff_comment *comment = calloc(sizeof(*comment), 1);
+ struct gcli_diff_comment *comment = calloc(1, sizeof(*comment));
comment->after.filename = strdup(ctx->diff->file_b);
comment->after.start_row = line_info->patched_line;
comment->after.end_row = line_info->patched_line;
diff --git a/src/gcli.c b/src/gcli.c
index c956c05..8036860 100644
--- a/src/gcli.c
+++ b/src/gcli.c
@@ -39,7 +39,7 @@ gcli_init(struct gcli_ctx **ctx,
char *(*get_token)(struct gcli_ctx *),
char *(*get_apibase)(struct gcli_ctx *))
{
- *ctx = calloc(sizeof (struct gcli_ctx), 1);
+ *ctx = calloc(1, sizeof (struct gcli_ctx));
if (!(*ctx))
return strerror(errno);
--
2.45.2