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

Richard Palethorpe rpalethorpe@suse.de
Mon Feb 21 14:49:04 CET 2022


Hello Petr,

Petr Vorel <pvorel@suse.cz> writes:

> Hi Richie,
>
>> 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.
> I remember few years ago (2017) metan did big cleanup with Coccinelle.
> If much simpler, we might want to introduce some basic scripts (without
> vendoring Coccinelle, it'd have to be installed).

Indeed, we already have some in scripts/coccinelle. These are mainly
useful for refactoring.

>
>> Hopefully the IR produced by these code patterns is fairly stable. In
>> that case we can do some simple pattern matching.
> Frankly speaking, if ever implemented it's probably you who is going to
> implement it, thus your choice what you use :).
>
> Kind regards,
> Petr

Yeah, although it still needs reviewing :-p

-- 
Thank you,
Richard.


More information about the ltp mailing list