From: Andrea Cervesato via ltp <ltp@lists.linux.it>
To: "Kuba Pawlak via ltp" <ltp@lists.linux.it>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 1/2] lib: tst_rtctime: close RTC fd on the ioctl() error path
Date: Tue, 21 Jul 2026 13:02:22 +0000 [thread overview]
Message-ID: <6a5f6ddf.af19844c.1da3fc.55a9@mx.google.com> (raw)
In-Reply-To: <20260717102000.1318116-1-kuba.pawlak@canonical.com>
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2026-07-21 13:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-17 10:19 [LTP] [PATCH v2 1/2] lib: tst_rtctime: close RTC fd on the ioctl() error path Kuba Pawlak via ltp
2026-07-17 10:20 ` [LTP] [PATCH v2 2/2] rtc02: skip (TCONF) on read-only RTCs that reject RTC_SET_TIME Kuba Pawlak via ltp
2026-07-21 13:14 ` Andrea Cervesato via ltp
2026-07-17 11:26 ` [LTP] lib: tst_rtctime: close RTC fd on the ioctl() error path linuxtestproject.agent
2026-07-20 14:44 ` [LTP] [PATCH v2 0/2] rtc02: handle RTCs that do not allow setting the time Kuba Pawlak via ltp
2026-07-21 13:02 ` Andrea Cervesato via ltp [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6a5f6ddf.af19844c.1da3fc.55a9@mx.google.com \
--to=ltp@lists.linux.it \
--cc=andrea.cervesato@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.