]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sleep: let's use write_string_file() instead of write_string_stream() if we can
authorLennart Poettering <lennart@poettering.net>
Wed, 24 Oct 2018 10:35:49 +0000 (12:35 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 24 Oct 2018 10:35:49 +0000 (12:35 +0200)
Let's shorten things.

src/sleep/sleep.c

index 0085cb0196fe8698bbd52c68f0b3868cb6cb933e..4b49d6aaef40384339e9fa6c269b5f6fada8e68d 100644 (file)
@@ -197,15 +197,9 @@ static int read_wakealarm(uint64_t *result) {
 }
 
 static int write_wakealarm(const char *str) {
-
-        _cleanup_fclose_ FILE *f = NULL;
         int r;
 
-        f = fopen("/sys/class/rtc/rtc0/wakealarm", "we");
-        if (!f)
-                return log_error_errno(errno, "Failed to open /sys/class/rtc/rtc0/wakealarm: %m");
-
-        r = write_string_stream(f, str, 0);
+        r = write_string_file("/sys/class/rtc/rtc0/wakealarm", str, 0);
         if (r < 0)
                 return log_error_errno(r, "Failed to write '%s' to /sys/class/rtc/rtc0/wakealarm: %m", str);