[LTP] [PATCH v2 1/2] lib: tst_rtctime: close RTC fd on the ioctl() error path
Andrea Cervesato
andrea.cervesato@suse.com
Tue Jul 21 15:02:22 CEST 2026
Hi Kuba,
> ret = ioctl(rtc_fd, request, rtc_tm);
>
> - if (ret != 0)
> - return -1;
> + if (ret != 0) {
> + int saved_errno = errno;
>
> - if (rtc_fd > 0)
> SAFE_CLOSE(rtc_fd);
> + errno = saved_errno;
> + return -1;
> + }
> +
> + SAFE_CLOSE(rtc_fd);
>
> return 0;
> }
Why do we need to store the errno? Simply call SAFE_CLOSE() before
returning -1. If SAFE_CLOSE() fails, test will break anyway..
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
More information about the ltp
mailing list