diff options
author | Lennart Poettering <lennart@poettering.net> | 2024-08-28 14:13:42 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2024-09-05 17:19:14 +0200 |
commit | 9640db13f0ef681e75f8697d0c6a24a6bfe67fce (patch) | |
tree | 8c949aac8ea2cc56242fb663e14a18c6520d0943 | |
parent | Merge pull request #34256 from YHNdnzj/pid1-followup (diff) | |
download | systemd-9640db13f0ef681e75f8697d0c6a24a6bfe67fce.tar.xz systemd-9640db13f0ef681e75f8697d0c6a24a6bfe67fce.zip |
hwclock-util: the struct tm parameter is not a pure return parameter, it's also an input parameter
-rw-r--r-- | src/timedate/hwclock-util.c | 11 | ||||
-rw-r--r-- | src/timedate/hwclock-util.h | 2 |
2 files changed, 6 insertions, 7 deletions
diff --git a/src/timedate/hwclock-util.c b/src/timedate/hwclock-util.c index e924f94872..76a10f40b2 100644 --- a/src/timedate/hwclock-util.c +++ b/src/timedate/hwclock-util.c @@ -9,24 +9,23 @@ #include "fd-util.h" #include "hwclock-util.h" -int hwclock_get(struct tm *ret) { +int hwclock_get(struct tm *tm /* input + output! */) { _cleanup_close_ int fd = -EBADF; - assert(ret); + assert(tm); fd = open("/dev/rtc", O_RDONLY|O_CLOEXEC); if (fd < 0) return -errno; /* This leaves the timezone fields of struct ret uninitialized! */ - if (ioctl(fd, RTC_RD_TIME, ret) < 0) + if (ioctl(fd, RTC_RD_TIME, tm) < 0) /* Some drivers return -EINVAL in case the time could not be kept, i.e. power loss * happened. Let's turn that into a clearly recognizable error */ return errno == EINVAL ? -ENODATA : -errno; - /* We don't know daylight saving, so we reset this in order not - * to confuse mktime(). */ - ret->tm_isdst = -1; + /* We don't know daylight saving, so we reset this in order not to confuse mktime(). */ + tm->tm_isdst = -1; return 0; } diff --git a/src/timedate/hwclock-util.h b/src/timedate/hwclock-util.h index 8663c02682..1503b5cf1f 100644 --- a/src/timedate/hwclock-util.h +++ b/src/timedate/hwclock-util.h @@ -3,5 +3,5 @@ #include <time.h> -int hwclock_get(struct tm *ret); +int hwclock_get(struct tm *tm); int hwclock_set(const struct tm *tm); |