[LTP] [PATCH 1/2] syscalls/open01.c: Don't continue when open() failed

Cyril Hrubis chrubis@suse.cz
Tue Jan 5 14:15:39 CET 2021


Hi!
> Avoid calling fstat() with invalid fd:
> -------------------------------------------
> ./open01
> ...
> open01.c:53: TBROK: fstat(-1,0x7fff731410a0) failed: EBADF (9)
> -------------------------------------------
> 
> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
> ---
>  testcases/kernel/syscalls/open/open01.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/testcases/kernel/syscalls/open/open01.c b/testcases/kernel/syscalls/open/open01.c
> index 1172f832b..2f0ad550a 100644
> --- a/testcases/kernel/syscalls/open/open01.c
> +++ b/testcases/kernel/syscalls/open/open01.c
> @@ -47,6 +47,9 @@ static void verify_open(unsigned int n)
>  
>  	TST_EXP_FD(open(tc->filename, tc->flag, tc->mode),
>  	           "open() with %s", tc->desc);
> +	if (!TST_PASS)
> +		return;
> +

Doesn't this only happen if the open() that is supposed to return a
valid file descriptor fails unexpectedly? In that the test fails, right?

But I guess that it does not harm, so:

Acked-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list