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] [day] [month] [year] [list]
Message-ID: <CAC1kPDMW=htR_4EHCz6T=GVTOvfq6urqzUWDGev9MEfi26deWg@mail.gmail.com>
Date: Fri, 20 Jun 2025 10:06:34 +0800
From: Chen Linxuan <chenlinxuan@...ontech.com>
To: Shuah Khan <skhan@...uxfoundation.org>
Cc: John Hubbard <jhubbard@...dia.com>, Chen Linxuan <chenlinxuan@...ontech.com>, 
	Shuah Khan <shuah@...nel.org>, Christian Brauner <brauner@...nel.org>, 
	Amir Goldstein <amir73il@...il.com>, Miklos Szeredi <mszeredi@...hat.com>, Jan Kara <jack@...e.cz>, 
	zhanjun@...ontech.com, niecheng1@...ontech.com, 
	linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH RESEND] selftests: Suppress unused variable warning

On Fri, Jun 20, 2025 at 5:41 AM Shuah Khan <skhan@...uxfoundation.org> wrote:
>
> On 6/19/25 13:00, John Hubbard wrote:
> > On 6/19/25 10:00 AM, Shuah Khan wrote:
> >> On 6/19/25 01:46, Chen Linxuan wrote:
> >>> On Thu, Jun 19, 2025 at 5:23 AM Shuah Khan <skhan@...uxfoundation.org> wrote:
> >>>> On 6/9/25 20:07, Chen Linxuan wrote:
> > ...
> >>>>> 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("/");
> >
> > This is quite ugly. :)

I agree with you. :)

> >
> >>>>>> Why not fix the problem the right way by checking the return value.
> >>>> Suppressing the error isn't useful.
> >>>
> >>> The code is already handling cleanup in error cases,
> >>> and I don't think checking the result of chdir would be useful here.

I think I was mistaken earlier. Here we are in the child process after
a fork, not handling an error case.
I think simply calling exit(-1) here when chdir failed should be
enough to make the test fail in the parent process.
Maybe we should do the same for other similar calls as well. I will
send a v2 soon.

> >>
> >
> > Why not just fail with the appropriate test result, if chdir() fails
> > here, instead of making a bit of a mess with odd void casts to a
> > negated return value, and a reference to a compiler bug report?
> >
> > Really, Shuah is putting you on the right path here.
>
> Ha. I didn't ask to suppress the error with the cast. I asked
> to check the return and fail.
>
> >
> >> We check for chdir() in several tools in the kernel. Add a check for
> >> it instead of suppressing the [-Wunused-result] - suppressing doesn't
> >> do any good.
>
> This is what I said.
>
> thanks,
> -- Shuah
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ