[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a72e8741-a63a-487e-838e-daeed3458c0f@sirena.org.uk>
Date: Thu, 7 Aug 2025 20:23:01 +0100
From: Mark Brown <broonie@...nel.org>
To: Bala-Vignesh-Reddy <reddybalavignesh9979@...il.com>
Cc: catalin.marinas@....com, will@...nel.org, shuah@...nel.org,
linux-arm-kernel@...ts.infradead.org,
linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] selftests: arm64: Check fread return value in exec_target
On Thu, Aug 07, 2025 at 09:19:47PM +0530, Bala-Vignesh-Reddy wrote:
> 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]
> --- a/tools/testing/selftests/arm64/pauth/exec_target.c
> +++ b/tools/testing/selftests/arm64/pauth/exec_target.c
> @@ -13,7 +13,12 @@ int main(void)
> - 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 -1;
> + }
It doesn't really matter but it'd be nicer to return a standard value
from main(), EXIT_FAILURE is probably a good choice. Exit values are in
the range 0..255.
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists