]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hwclock-util: the struct tm parameter is not a pure return parameter, it's also an...
authorLennart Poettering <lennart@poettering.net>
Wed, 28 Aug 2024 12:13:42 +0000 (14:13 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 5 Sep 2024 15:19:14 +0000 (17:19 +0200)
src/timedate/hwclock-util.c
src/timedate/hwclock-util.h

index e924f94872b151f4e664bea972d7cb5bca766f86..76a10f40b25ff7af6d8520314830aa5a59fb1231 100644 (file)
@@ -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;
 }
index 8663c02682947f20d8156935a9697fc1ad4479a4..1503b5cf1fae4abc93f646a38c772ac0109be611 100644 (file)
@@ -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);