Skip to content

Commit

Permalink
Fix build with GCC v14.1 (#4962)
Browse files Browse the repository at this point in the history
The GCC v14.1 upgrade broke the build of `git-artifacts`. Partially,
this has been fixed upstream already, but the i686 build requires a
separate fix.

This addresses #4953.
  • Loading branch information
dscho authored May 22, 2024
2 parents a3b4879 + 68af6e0 commit f3b93ac
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions compat/regex/regcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
if (table_size > pat_len)
break;

dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size);
dfa->state_table = calloc (table_size, sizeof (struct re_state_table_entry));
dfa->state_hash_mask = table_size - 1;

dfa->mb_cur_max = MB_CUR_MAX;
Expand Down Expand Up @@ -936,7 +936,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
{
int i, j, ch;

dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
dfa->sb_char = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
if (BE (dfa->sb_char == NULL, 0))
return REG_ESPACE;

Expand Down Expand Up @@ -3079,9 +3079,9 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
_NL_COLLATE_SYMB_EXTRAMB);
}
#endif
sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
sbcset = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
#ifdef RE_ENABLE_I18N
mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
mbcset = (re_charset_t *) calloc (1, sizeof (re_charset_t));
#endif /* RE_ENABLE_I18N */
#ifdef RE_ENABLE_I18N
if (BE (sbcset == NULL || mbcset == NULL, 0))
Expand Down Expand Up @@ -3626,9 +3626,9 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
re_token_t br_token;
bin_tree_t *tree;

sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
sbcset = (re_bitset_ptr_t) calloc (1, sizeof (bitset_t));
#ifdef RE_ENABLE_I18N
mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
mbcset = (re_charset_t *) calloc (1, sizeof (re_charset_t));
#endif /* RE_ENABLE_I18N */

#ifdef RE_ENABLE_I18N
Expand Down
4 changes: 2 additions & 2 deletions compat/regex/regex_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
reg_errcode_t err;
re_dfastate_t *newstate;

newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
newstate = (re_dfastate_t *) calloc (1, sizeof (re_dfastate_t));
if (BE (newstate == NULL, 0))
return NULL;
err = re_node_set_init_copy (&newstate->nodes, nodes);
Expand Down Expand Up @@ -1678,7 +1678,7 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
reg_errcode_t err;
re_dfastate_t *newstate;

newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
newstate = (re_dfastate_t *) calloc (1, sizeof (re_dfastate_t));
if (BE (newstate == NULL, 0))
return NULL;
err = re_node_set_init_copy (&newstate->nodes, nodes);
Expand Down
10 changes: 5 additions & 5 deletions compat/regex/regexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -2796,8 +2796,8 @@ get_subexp (re_match_context_t *mctx, int bkref_node, int bkref_str_idx)
continue; /* No. */
if (sub_top->path == NULL)
{
sub_top->path = calloc (sizeof (state_array_t),
sl_str - sub_top->str_idx + 1);
sub_top->path = calloc (sl_str - sub_top->str_idx + 1,
sizeof (state_array_t));
if (sub_top->path == NULL)
return REG_ESPACE;
}
Expand Down Expand Up @@ -3361,7 +3361,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
if (ndests == 0)
{
state->trtable = (re_dfastate_t **)
calloc (sizeof (re_dfastate_t *), SBC_MAX);
calloc (SBC_MAX, sizeof (re_dfastate_t *));
return 1;
}
return 0;
Expand Down Expand Up @@ -3457,7 +3457,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
discern by looking at the character code: allocate a
256-entry transition table. */
trtable = state->trtable =
(re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX);
(re_dfastate_t **) calloc (SBC_MAX, sizeof (re_dfastate_t *));
if (BE (trtable == NULL, 0))
goto out_free;

Expand Down Expand Up @@ -3488,7 +3488,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
transition tables, one starting at trtable[0] and one
starting at trtable[SBC_MAX]. */
trtable = state->word_trtable =
(re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX);
(re_dfastate_t **) calloc (2 * SBC_MAX, sizeof (re_dfastate_t *));
if (BE (trtable == NULL, 0))
goto out_free;

Expand Down
2 changes: 1 addition & 1 deletion git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ struct strbuf;
/* Approximation of the length of the decimal representation of this type. */
#define decimal_length(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1)

#ifdef __MINGW64__
#if defined(__MINGW32__) || defined(__MINGW64__)
#define _POSIX_C_SOURCE 1
#elif defined(__sun__)
/*
Expand Down

0 comments on commit f3b93ac

Please sign in to comment.