lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6972404e-0237-47b9-8e3e-15551bea3440@linuxfoundation.org>
Date: Wed, 18 Jun 2025 15:23:29 -0600
From: Shuah Khan <skhan@...uxfoundation.org>
To: Chen Linxuan <chenlinxuan@...ontech.com>, Shuah Khan <shuah@...nel.org>,
 Christian Brauner <brauner@...nel.org>, Amir Goldstein <amir73il@...il.com>,
 John Hubbard <jhubbard@...dia.com>, Miklos Szeredi <mszeredi@...hat.com>,
 Jan Kara <jack@...e.cz>
Cc: zhanjun@...ontech.com, niecheng1@...ontech.com,
 linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
 Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: [PATCH RESEND] selftests: Suppress unused variable warning

On 6/9/25 20:07, Chen Linxuan wrote:
> When running `make kselftest`, the following compilation warning was encountered:
> 
> mount-notify_test.c: In function ‘fanotify_rmdir’:
> mount-notify_test.c:490:17: warning: ignoring return value of ‘chdir’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
>    490 |                 chdir("/");
>        |                 ^~~~~~~~~~
> 
> This patch addresses the warning by
> explicitly suppressing the unused result of the `chdir` function.
> 
> Signed-off-by: Chen Linxuan <chenlinxuan@...ontech.com>
> ---
>   .../selftests/filesystems/mount-notify/mount-notify_test.c    | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
> index 63ce708d93ed0..34afe27b7978f 100644
> --- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
> +++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
> @@ -465,7 +465,9 @@ TEST_F(fanotify, rmdir)
>   	ASSERT_GE(ret, 0);
>   
>   	if (ret == 0) {
> -		chdir("/");
> +		// Suppress -Wunused-result
> +		// Ref: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425#c34
> +		(void) !chdir("/");

Why not fix the problem the right way by checking the return value.
Suppressing the error isn't useful.


>   		unshare(CLONE_NEWNS);
>   		mount("", "/", NULL, MS_REC|MS_PRIVATE, NULL);
>   		umount2("/a", MNT_DETACH);

thanks,
-- Shuah

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ