Commit a679e568 authored by Bala-Vignesh-Reddy's avatar Bala-Vignesh-Reddy Committed by Will Deacon
Browse files

selftests: arm64: Check fread return value in exec_target



Fix -Wunused-result warning generated when compiled with gcc 13.3.0,
by checking fread's return value and handling errors, preventing
potential failures when reading from stdin.

Fixes compiler warning:
warning: ignoring return value of 'fread' declared with attribute
'warn_unused_result' [-Wunused-result]

Fixes: 806a15b2 ("kselftests/arm64: add PAuth test for whether exec() changes keys")

Signed-off-by: default avatarBala-Vignesh-Reddy <reddybalavignesh9979@gmail.com>
Reviewed-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarWill Deacon <will@kernel.org>
parent 8f5ae30d
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -13,7 +13,12 @@ int main(void)
	unsigned long hwcaps;
	size_t val;

	fread(&val, sizeof(size_t), 1, stdin);
	size_t size = fread(&val, sizeof(size_t), 1, stdin);

	if (size != 1) {
		fprintf(stderr, "Could not read input from stdin\n");
		return EXIT_FAILURE;
	}

	/* don't try to execute illegal (unimplemented) instructions) caller
	 * should have checked this and keep worker simple