chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util: add hexmem() and strextend() calls
[elogind.git]
/
src
/
shared
/
hwclock.c
diff --git
a/src/shared/hwclock.c
b/src/shared/hwclock.c
index d9d5600ff34052db0bc03b5075a6e1ddcf24e71e..488c30e93f6c8ce04dfb2da451b4c60022b0c9c4 100644
(file)
--- a/
src/shared/hwclock.c
+++ b/
src/shared/hwclock.c
@@
-41,6
+41,7
@@
#include "log.h"
#include "strv.h"
#include "hwclock.h"
#include "log.h"
#include "strv.h"
#include "hwclock.h"
+#include "fileio.h"
static int rtc_open(int flags) {
int fd;
static int rtc_open(int flags) {
int fd;
@@
-61,10
+62,11
@@
static int rtc_open(int flags) {
for (;;) {
char *p, *v;
for (;;) {
char *p, *v;
- struct dirent buf, *de;
+ struct dirent *de;
+ union dirent_storage buf;
int r;
int r;
- r = readdir_r(d, &buf, &de);
+ r = readdir_r(d, &buf
.de
, &de);
if (r != 0)
goto fallback;
if (r != 0)
goto fallback;
@@
-93,6
+95,11
@@
static int rtc_open(int flags) {
continue;
p = strappend("/dev/", de->d_name);
continue;
p = strappend("/dev/", de->d_name);
+ if (!p) {
+ closedir(d);
+ return -ENOMEM;
+ }
+
fd = open(p, flags);
free(p);
fd = open(p, flags);
free(p);
@@
-154,6
+161,7
@@
int hwclock_set_time(const struct tm *tm) {
return err;
}
return err;
}
+
int hwclock_is_localtime(void) {
FILE *f;
bool local = false;
int hwclock_is_localtime(void) {
FILE *f;
bool local = false;
@@
-192,14
+200,14
@@
int hwclock_set_timezone(int *min) {
const struct timeval *tv_null = NULL;
struct timespec ts;
struct tm *tm;
const struct timeval *tv_null = NULL;
struct timespec ts;
struct tm *tm;
- int minutes
west
;
+ int minutes
delta
;
struct timezone tz;
assert_se(clock_gettime(CLOCK_REALTIME, &ts) == 0);
assert_se(tm = localtime(&ts.tv_sec));
struct timezone tz;
assert_se(clock_gettime(CLOCK_REALTIME, &ts) == 0);
assert_se(tm = localtime(&ts.tv_sec));
- minutes
west
= tm->tm_gmtoff / 60;
+ minutes
delta
= tm->tm_gmtoff / 60;
- tz.tz_minuteswest = -minutes
west
;
+ tz.tz_minuteswest = -minutes
delta
;
tz.tz_dsttime = 0; /* DST_NONE*/
/*
tz.tz_dsttime = 0; /* DST_NONE*/
/*
@@
-210,7
+218,7
@@
int hwclock_set_timezone(int *min) {
if (settimeofday(tv_null, &tz) < 0)
return -errno;
if (min)
if (settimeofday(tv_null, &tz) < 0)
return -errno;
if (min)
- *min = minutes
west
;
+ *min = minutes
delta
;
return 0;
}
return 0;
}