[LTP] close02: add test for double close EBADF
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Tue May 12 19:15:36 CEST 2026
Hi Jinseok,
On 2026-05-13, Jinseok Kim wrote:
> close02: add test for double close EBADF
> +static void setup(void)
> +{
> + fd_closed = SAFE_OPEN("close02", O_CREAT | O_RDWR, 0600);
> + if (close(fd_closed) == -1)
> + tst_brk(TBROK | TERRNO, "close(%d) failed", fd_closed);
> +}
Use SAFE_CLOSE instead of a raw close(). Since SAFE_CLOSE sets the variable
to -1, save the fd value first:
int tmp_fd;
fd_closed = SAFE_OPEN("close02", O_CREAT | O_RDWR, 0600);
tmp_fd = fd_closed;
SAFE_CLOSE(tmp_fd);
---
Note:
Our agent completed the review of the patch. The full review can be
found at: https://github.com/linux-test-project/ltp-agent/actions/runs/25750070063
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
More information about the ltp
mailing list