Re: [PATCH v2 12/13] selftests/fs/mount-notify-ns: Fix build warning

Amir Goldstein <[email protected]> Fri, 5 Dec 2025 18:31:33 +0100
Newsgroups gmane.linux.kernel,gmane.comp.emulators.wine.devel,gmane.linux.network,gmane.linux.kernel.bpf
Message-ID <CAOQ4uxiqK6Hj2ggtcD-c7BAtuBcm+LrKVkQOxi93OXhwSE98Dw@mail.gmail.com>
On Fri, Dec 5, 2025 at 6:12=E2=80=AFPM Guenter Roeck <[email protected]> w=
rote:
>
> Fix
>
> mount-notify_test_ns.c: In function =E2=80=98fanotify_rmdir=E2=80=99:
> mount-notify_test_ns.c:494:17: warning:
>         ignoring return value of =E2=80=98chdir=E2=80=99 declared with at=
tribute =E2=80=98warn_unused_result=E2=80=99
>
> by checking the return value of chdir() and displaying an error message
> if it returns an error.
>
> Fixes: 781091f3f5945 ("selftests/fs/mount-notify: add a test variant runn=
ing inside userns")
> Cc: Amir Goldstein <[email protected]>
> Signed-off-by: Guenter Roeck <[email protected]>
> ---
> v2: Update subject and description to reflect that the patch fixes a buil=
d
>     warning.
>     Use perror() to display an error message if chdir() returns an error.
>
>  .../selftests/filesystems/mount-notify/mount-notify_test_ns.c  | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/filesystems/mount-notify/mount-notif=
y_test_ns.c b/tools/testing/selftests/filesystems/mount-notify/mount-notify=
_test_ns.c
> index 9f57ca46e3af..90bec6faf64e 100644
> --- a/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_=
ns.c
> +++ b/tools/testing/selftests/filesystems/mount-notify/mount-notify_test_=
ns.c
> @@ -491,7 +491,8 @@ TEST_F(fanotify, rmdir)
>         ASSERT_GE(ret, 0);
>
>         if (ret =3D=3D 0) {
> -               chdir("/");
> +               if (chdir("/"))
> +                       perror("chdir()");

ASSERT_EQ(0, chdir("/"));

and there is another one like this in mount-notify_test.c

Thanks,
Amir.