hwclock: modernizations
This commit is contained in:
parent
d3cfcae9db
commit
8e64fd110d
|
@ -44,8 +44,7 @@
|
||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
|
|
||||||
int hwclock_get_time(struct tm *tm) {
|
int hwclock_get_time(struct tm *tm) {
|
||||||
int fd;
|
_cleanup_close_ int fd = -1;
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
assert(tm);
|
assert(tm);
|
||||||
|
|
||||||
|
@ -56,20 +55,17 @@ int hwclock_get_time(struct tm *tm) {
|
||||||
/* This leaves the timezone fields of struct tm
|
/* This leaves the timezone fields of struct tm
|
||||||
* uninitialized! */
|
* uninitialized! */
|
||||||
if (ioctl(fd, RTC_RD_TIME, tm) < 0)
|
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
|
/* We don't know daylight saving, so we reset this in order not
|
||||||
* to confuse mktime(). */
|
* to confuse mktime(). */
|
||||||
tm->tm_isdst = -1;
|
tm->tm_isdst = -1;
|
||||||
|
|
||||||
close_nointr_nofail(fd);
|
return 0;
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int hwclock_set_time(const struct tm *tm) {
|
int hwclock_set_time(const struct tm *tm) {
|
||||||
int fd;
|
_cleanup_close_ int fd = -1;
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
assert(tm);
|
assert(tm);
|
||||||
|
|
||||||
|
@ -78,11 +74,9 @@ int hwclock_set_time(const struct tm *tm) {
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
if (ioctl(fd, RTC_SET_TIME, tm) < 0)
|
if (ioctl(fd, RTC_SET_TIME, tm) < 0)
|
||||||
err = -errno;
|
return -errno;
|
||||||
|
|
||||||
close_nointr_nofail(fd);
|
return 0;
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int hwclock_is_localtime(void) {
|
int hwclock_is_localtime(void) {
|
||||||
|
|
Loading…
Reference in a new issue