Skip to content

Commit 3d9731f

Browse files
author
Martin Vogel
committed
Zero-initialize LangFile fixture arrays (GCC -Werror=maybe-uninitialized)
GCC at -O1 flags the partially-filled LangFile arrays in contract_all_grammars_in_graph and index_parallel_fixture as maybe-used-uninitialized when passed to lang_index_files (clang does not), failing the -Werror Linux test build. Zero-initialize both; only files[0..nfiles-1] are ever read, so behavior is unchanged.
1 parent 0600bc7 commit 3d9731f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

tests/test_lang_contract.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ TEST(contract_all_grammars_in_graph) {
522522
n = GRAMMAR_BREADTH_MAX;
523523
}
524524
static char names[GRAMMAR_BREADTH_MAX][GRAMMAR_PATH_BUF];
525-
LangFile files[GRAMMAR_BREADTH_MAX];
525+
LangFile files[GRAMMAR_BREADTH_MAX] = {0}; /* zero-init: GCC -Werror=maybe-uninitialized */
526526
for (int i = 0; i < n; i++) {
527527
snprintf(names[i], sizeof(names[i]), "g%03d/%s", i, CBM_GRAMMAR_CASES[i].path);
528528
files[i].name = names[i];
@@ -1067,7 +1067,7 @@ enum { PARALLEL_PAD_FILES = 52 };
10671067
static cbm_store_t *index_parallel_fixture(LangProj *lp, const LangFile *meaningful, int n_mean) {
10681068
static char pad_name[PARALLEL_PAD_FILES][40];
10691069
static char pad_body[PARALLEL_PAD_FILES][64];
1070-
LangFile files[PARALLEL_PAD_FILES + 16];
1070+
LangFile files[PARALLEL_PAD_FILES + 16] = {0}; /* zero-init: GCC -Werror=maybe-uninitialized */
10711071
int n = 0;
10721072
for (int i = 0; i < n_mean; i++) {
10731073
files[n++] = meaningful[i];

0 commit comments

Comments
 (0)