[LTP] [PATCH 1/3] perf_event_open02: migrate to newlib
Cyril Hrubis
chrubis@suse.cz
Wed Nov 20 13:29:10 CET 2019
Hi!
> @@ -312,15 +238,13 @@ static void cleanup(void)
> {
> int i;
>
> - for (i = 0; i < n; i++) {
> - if (hwfd[i] > 0 && close(hwfd[i]) == -1)
> - tst_resm(TWARN | TERRNO, "close(%d) failed", hwfd[i]);
> - if (tskfd[i] > 0 && close(tskfd[i]) == -1)
> - tst_resm(TWARN | TERRNO, "close(%d) failed", tskfd[i]);
> + for (i = 0; i < ntotal; i++) {
> + SAFE_CLOSE(hwfd[i]);
> + SAFE_CLOSE(tskfd[i]);
Shouldn't we check that the hwfd[i] and tskfd[i] are > 0?
I guess that we may do SAFE_CLOSE(0) repeatedly here in a case that
perf_event_open() failed somewhere in the middle of the setup().
Otherwise this is a nice cleanup, acked.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list