chiark / gitweb /
Add set_consume which always takes ownership
[elogind.git] / src / shared / hwclock.c
index 55b0fa8a0f1c855ade2f9ee26bbc141aaf1f6cf2..a3b33ed4cc90dc2fad7bc594c2e65a48cf2e6d99 100644 (file)
@@ -163,8 +163,7 @@ int hwclock_set_time(const struct tm *tm) {
 }
 
 int hwclock_is_localtime(void) {
-        FILE *f;
-        bool local = false;
+        _cleanup_fclose_ FILE *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) {