chiark / gitweb /
hwclock: modernizations
authorLennart Poettering <lennart@poettering.net>
Tue, 19 Nov 2013 00:12:03 +0000 (01:12 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 20 Nov 2013 18:36:14 +0000 (19:36 +0100)
src/shared/hwclock.c

index 60292a01537c7ae68caeb0a20a07309ee10bbab2..7059d9c75b8367a0cb1d3b39983d74087cc54f6d 100644 (file)
@@ -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) {