From: Lennart Poettering Date: Wed, 24 Oct 2018 10:35:49 +0000 (+0200) Subject: sleep: let's use write_string_file() instead of write_string_stream() if we can X-Git-Tag: v240~475^2~10 X-Git-Url: http://git-history.diyao.me/?a=commitdiff_plain;h=f00aff0a0278fbbe883dac9b907fdf5092ff52bc;p=systemd%2F.git sleep: let's use write_string_file() instead of write_string_stream() if we can Let's shorten things. --- diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c index 0085cb0196..4b49d6aaef 100644 --- a/src/sleep/sleep.c +++ b/src/sleep/sleep.c @@ -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);