diff mbox series

[03/11] kselftest/arm64: mte: ksm_options: Fix fscanf warning

Message ID 20210319165334.29213-4-andre.przywara@arm.com (mailing list archive)
State Accepted
Commit 31c88729a7ad2b9871e6a73e491ec7223880d633
Headers show
Series kselftest/arm64: mte: Fix feature detection and compilation | expand

Commit Message

Andre Przywara March 19, 2021, 4:53 p.m. UTC
Out of the box Ubuntu's 20.04 compiler warns about missing return value
checks for fscanf() calls.

Make GCC happy by checking whether we actually parsed one integer.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
 tools/testing/selftests/arm64/mte/check_ksm_options.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tools/testing/selftests/arm64/mte/check_ksm_options.c b/tools/testing/selftests/arm64/mte/check_ksm_options.c
index 3b23c4d61d38..88c74bc46d4f 100644
--- a/tools/testing/selftests/arm64/mte/check_ksm_options.c
+++ b/tools/testing/selftests/arm64/mte/check_ksm_options.c
@@ -33,7 +33,10 @@  static unsigned long read_sysfs(char *str)
 		ksft_print_msg("ERR: missing %s\n", str);
 		return 0;
 	}
-	fscanf(f, "%lu", &val);
+	if (fscanf(f, "%lu", &val) != 1) {
+		ksft_print_msg("ERR: parsing %s\n", str);
+		val = 0;
+	}
 	fclose(f);
 	return val;
 }