summaryrefslogtreecommitdiff
path: root/src/shared/hwclock.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-11 19:02:37 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-11 19:13:18 -0400
commit8e2f9ebf28f93241ed36469302e76de498aa8e87 (patch)
tree773b295cb874034d714c87e993ffd1380b71a061 /src/shared/hwclock.c
parentbcb161b0230fdd1faf9176f95fee76a7db6afd59 (diff)
hwclock: use _cleanup_ to simplify function
Diffstat (limited to 'src/shared/hwclock.c')
-rw-r--r--src/shared/hwclock.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/shared/hwclock.c b/src/shared/hwclock.c
index 55b0fa8a0f..9076d8ffc7 100644
--- a/src/shared/hwclock.c
+++ b/src/shared/hwclock.c
@@ -163,8 +163,7 @@ int hwclock_set_time(const struct tm *tm) {
}
int hwclock_is_localtime(void) {
- FILE *f;
- bool local = false;
+ FILE _cleanup_fclose_ *f;
/*
* The third line of adjtime is "UTC" or "LOCAL" or nothing.
@@ -181,19 +180,16 @@ int hwclock_is_localtime(void) {
b = fgets(line, sizeof(line), f) &&
fgets(line, sizeof(line), f) &&
fgets(line, sizeof(line), f);
-
- fclose(f);
-
if (!b)
return -EIO;
truncate_nl(line);
- local = streq(line, "LOCAL");
+ return streq(line, "LOCAL");
} else if (errno != ENOENT)
return -errno;
- return local;
+ return 0;
}
int hwclock_set_timezone(int *min) {