chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
errno is positive
[elogind.git]
/
src
/
shared
/
hwclock.c
diff --git
a/src/shared/hwclock.c
b/src/shared/hwclock.c
index b93855d95704388d4c0a2568b2c679d82fe507a5..55b0fa8a0f1c855ade2f9ee26bbc141aaf1f6cf2 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;
@@
-94,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);
@@
-184,7
+190,7
@@
int hwclock_is_localtime(void) {
truncate_nl(line);
local = streq(line, "LOCAL");
truncate_nl(line);
local = streq(line, "LOCAL");
- } else if (errno !=
-
ENOENT)
+ } else if (errno != ENOENT)
return -errno;
return local;
return -errno;
return local;
@@
-194,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*/
/*
@@
-212,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;
}