diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-11-19 01:12:03 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-11-20 19:36:14 +0100 |
commit | 8e64fd110d85de45929cefcbf83aa506d60f8795 (patch) | |
tree | ea951d3292705a364f800c7e1e8c409dd57e0912 /src/shared | |
parent | d3cfcae9db39b0cd01bd8c3db1dc57d6a04554a4 (diff) |
hwclock: modernizations
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/hwclock.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/shared/hwclock.c b/src/shared/hwclock.c index 60292a0153..7059d9c75b 100644 --- a/src/shared/hwclock.c +++ b/src/shared/hwclock.c @@ -44,8 +44,7 @@ #include "fileio.h" int hwclock_get_time(struct tm *tm) { - int fd; - int err = 0; + _cleanup_close_ int fd = -1; assert(tm); @@ -56,20 +55,17 @@ int hwclock_get_time(struct tm *tm) { /* This leaves the timezone fields of struct tm * uninitialized! */ if (ioctl(fd, RTC_RD_TIME, tm) < 0) - err = -errno; + return -errno; /* We don't know daylight saving, so we reset this in order not * to confuse mktime(). */ tm->tm_isdst = -1; - close_nointr_nofail(fd); - - return err; + return 0; } int hwclock_set_time(const struct tm *tm) { - int fd; - int err = 0; + _cleanup_close_ int fd = -1; assert(tm); @@ -78,11 +74,9 @@ int hwclock_set_time(const struct tm *tm) { return -errno; if (ioctl(fd, RTC_SET_TIME, tm) < 0) - err = -errno; - - close_nointr_nofail(fd); + return -errno; - return err; + return 0; } int hwclock_is_localtime(void) { |