[LTP] [PATCH 4/5] Add pidfd_getfd01 test

Richard Palethorpe rpalethorpe@suse.de
Mon Feb 21 11:03:57 CET 2022


Hello Petr,

Petr Vorel <pvorel@suse.cz> writes:

> Hi Richie, Xu,
>
>> Hi Petr
>> > Hi Xu,
>
>> > ...
>> >> +++ b/testcases/kernel/syscalls/pidfd_getfd/pidfd_getfd01.c
>> > ...
>> >> +	remotefd = TST_RET;
>> >> +	flag = fcntl(remotefd, F_GETFD);
>> >> +	if (flag == -1)
>> >> +		tst_brk(TFAIL | TERRNO, "fcntl(F_GETFD) failed");
>> > Just:
>> > flag = SAFE_FCNTL(remotefd, F_GETFD);
>> Yes, I almost forgot we have this macro.
> @Richie: It'd be useful if sparse checks would suggest to use SAFE_*()
> functions, but not sure if easily detectable. Something like setup() and
> cleanup() function and syscall followed by if (foo == -1) followed by tst_brk().
>
> Kind regards,
> Petr

Yeah, this would be relatively simple in Coccinelle. In Sparse I'm not
sure, but it is one of the main use cases IMO.

Hopefully the IR produced by these code patterns is fairly stable. In
that case we can do some simple pattern matching.

-- 
Thank you,
Richard.


More information about the ltp mailing list