[LTP] close02: add test for double close EBADF

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Wed Apr 29 17:18:34 CEST 2026


Hi Jinseok,

On 2026-04-29, Jinseok Kim wrote:
> close02: add test for double close EBADF

> +static void setup(void)
> +{
> +	fd_closed = SAFE_OPEN("close02", O_CREAT | O_RDWR, 0600);
> +	SAFE_CLOSE(fd_closed);
> +}

SAFE_CLOSE(fd_closed) resets fd_closed to -1 (the macro does `fd = -1`
after the close), so both test cases end up calling close(-1). The second
case never exercises the double-close path. Use a local variable to
preserve the fd value:

    int fd = SAFE_OPEN("close02", O_CREAT | O_RDWR, 0600);
    fd_closed = fd;
    SAFE_CLOSE(fd);

---
Note:

Our agent completed the review of the patch.

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