Skip to contentSkip to conversation

selftests/powerpc: Fix uninitialized variable warning

PATCH Applied Harish 2 participants 2 messages Dec 1, 2020 – Dec 10, 2020

Subsystems (2)
lore
Share & tools
lore

Harish

author
#0 lore raw

PATCH 1/1 selftests/powerpc: Fix uninitialized variable warning

Patch fixes uninitialized variable warning in bad_accesses test which causes the selftests build to fail in older distibutions

bad_accesses.c: In function ‘bad_access’:
bad_accesses.c:52:9: error: ‘x’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

   printf("Bad - no SEGV! (%c)\n", x);
         ^

cc1: all warnings being treated as errors

---
 tools/testing/selftests/powerpc/mm/bad_accesses.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/powerpc/mm/bad_accesses.c +1 -1
index fd747b2ffcfc..65d2148b05dc 100644
@@ -38,7 +38,7 @@ static void segv_handler(int n, siginfo_t *info, void *ctxt_v)
 
 int bad_access(char *p, bool write)
 {
-	char x;
+	char x = 0;
 
 	fault_code = 0;
 	fault_addr = 0;
Signature · 1 line
2.26.2
#1 lore raw
Quoted 8 lines · Harish

Patch fixes uninitialized variable warning in bad_accesses test which causes the selftests build to fail in older distibutions

bad_accesses.c: In function ‘bad_access’:
bad_accesses.c:52:9: error: ‘x’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

   printf("Bad - no SEGV! (%c)\n", x);
         ^

cc1: all warnings being treated as errors

Applied to powerpc/next.

[1/1] selftests/powerpc: Fix uninitialized variable warning

      https://git.kernel.org/powerpc/c/c9344769e2b46ba28b947bec7a8a8f0a091ecd57

cheers