Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 806a15b2545e ("kselftests/arm64: add PAuth test for whether exec() changes keys")

Signed-off-by: Bala-Vignesh-Reddy <reddybalavignesh9979@gmail.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Bala-Vignesh-Reddy and committed by
Will Deacon
a679e568 8f5ae30d

+6 -1
+6 -1
tools/testing/selftests/arm64/pauth/exec_target.c
··· 13 13 unsigned long hwcaps; 14 14 size_t val; 15 15 16 - fread(&val, sizeof(size_t), 1, stdin); 16 + size_t size = fread(&val, sizeof(size_t), 1, stdin); 17 + 18 + if (size != 1) { 19 + fprintf(stderr, "Could not read input from stdin\n"); 20 + return EXIT_FAILURE; 21 + } 17 22 18 23 /* don't try to execute illegal (unimplemented) instructions) caller 19 24 * should have checked this and keep worker simple