Skip to content

Commit dbad177

Browse files
Denton-Lgitster
authored andcommitted
fix -Wmaybe-uninitialized with -Og
When building with -Og on gcc 15.1.1, the build produces two warnings. Even though in practice, these codepaths can't actually be hit while the variables are uninitialized, satisfy the compiler by initializing the variables. This also acts as defensive programming since these codepaths are a little bit spaghetti. If someone in the future makes a mistake and causes the branch with the uninitialized variable to be hit, at least we won't experience undefined behaviour. Signed-off-by: Denton Liu <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f368df4 commit dbad177

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

builtin/remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,7 @@ static int set_head(int argc, const char **argv, const char *prefix,
14461446
b_local_head = STRBUF_INIT;
14471447
char *head_name = NULL;
14481448
struct ref_store *refs = get_main_ref_store(the_repository);
1449-
struct remote *remote;
1449+
struct remote *remote = NULL;
14501450

14511451
struct option options[] = {
14521452
OPT_BOOL('a', "auto", &opt_a,

t/unit-tests/clar/clar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ static void
350350
clar_run_suite(const struct clar_suite *suite, const char *filter)
351351
{
352352
const struct clar_func *test = suite->tests;
353-
size_t i, matchlen;
353+
size_t i, matchlen = 0;
354354
struct clar_report *report;
355355
int exact = 0;
356356

0 commit comments

Comments
 (0)