]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/unit-tests/clar: fix -Wmaybe-uninitialized with -Og
authorDenton Liu <liu.denton@gmail.com>
Tue, 5 Aug 2025 05:31:16 +0000 (22:31 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 5 Aug 2025 15:22:53 +0000 (08:22 -0700)
When building with -Og on gcc 15.1.1, the build produces a warning. In
practice, though, this cannot be hit because `exact` acts as a guard and
that variable can only be set after `matchlen` is already initialized

Assign a default value to `matchlen` so that the warning is silenced.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/unit-tests/clar/clar.c

index d54e4553674908a0a8a0cd60d34f96d3f408df8c..03a3aa8e873bfcb1d15f19b5f168edc323ca2785 100644 (file)
@@ -350,7 +350,7 @@ static void
 clar_run_suite(const struct clar_suite *suite, const char *filter)
 {
        const struct clar_func *test = suite->tests;
-       size_t i, matchlen;
+       size_t i, matchlen = 0;
        struct clar_report *report;
        int exact = 0;