[LTP] [PATCH 4/5] Add pidfd_getfd01 test
Petr Vorel
pvorel@suse.cz
Mon Feb 21 13:42:57 CET 2022
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).
> 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
More information about the ltp
mailing list