[PATCH 11/22] string: initialize string array in string selftest

Ahmad Fatoum a.fatoum at pengutronix.de
Thu Mar 13 00:34:34 PDT 2025


The array members in tokens are passed to strverscmp, which doesn't do a
NULL-check, which is prone to happen with malformed test input.

Static analysis warns about this, so initialize it to empty strings.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 test/self/string.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/self/string.c b/test/self/string.c
index d33e2d7918ca..542277a09797 100644
--- a/test/self/string.c
+++ b/test/self/string.c
@@ -37,7 +37,7 @@ static int strverscmp_assert_one(const char *lhs, const char *rhs, int expect)
 
 static int __strverscmp_assert(char *expr)
 {
-	const char *token, *tokens[3];
+	const char *token, *tokens[3] = { "", "", "" };
 	int expect = -42;
 	int i = 0;
 
-- 
2.39.5




More information about the barebox mailing list