X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Fhwclock.c;h=7059d9c75b8367a0cb1d3b39983d74087cc54f6d;hp=cc11faa6c37042ad1dbcb414ccab348786a3e336;hb=fa041593fe04b12ffd7e81d8b3598a7a6f313fb3;hpb=67fb4482acb0ecccb8a30e7ca49e5de28ba49eaf diff --git a/src/shared/hwclock.c b/src/shared/hwclock.c index cc11faa6c..7059d9c75 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 confused mktime(). */ + * 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) { @@ -151,7 +145,7 @@ int hwclock_reset_timezone(void) { /* * The very first time we set the kernel's timezone, it will warp * the clock. Do a dummy call here, so the time warping is sealed - * and we set only the time zone with next call. + * and we set only the timezone with next call. */ if (settimeofday(tv_null, &tz) < 0) return -errno;