From 553acb7b6b8d4f16a4747b1f978e8b7888fbfb2c Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Mon, 1 Dec 2014 20:43:19 -0500 Subject: treewide: sanitize loop_write loop_write() didn't follow the usual systemd rules and returned status partially in errno and required extensive checks from callers. Some of the callers dealt with this properly, but many did not, treating partial writes as successful. Simplify things by conforming to usual rules. --- src/journal/journalctl.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/journal/journalctl.c') diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 3cec9a0c84..b2f6966fca 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -1406,17 +1406,15 @@ static int setup_keys(void) { h.fsprg_secpar = htole16(FSPRG_RECOMMENDED_SECPAR); h.fsprg_state_size = htole64(state_size); - l = loop_write(fd, &h, sizeof(h), false); - if (l < 0 || (size_t) l != sizeof(h)) { - log_error_errno(EIO, "Failed to write header: %m"); - r = -EIO; + r = loop_write(fd, &h, sizeof(h), false); + if (r < 0) { + log_error_errno(r, "Failed to write header: %m"); goto finish; } - l = loop_write(fd, state, state_size, false); - if (l < 0 || (size_t) l != state_size) { - log_error_errno(EIO, "Failed to write state: %m"); - r = -EIO; + r = loop_write(fd, state, state_size, false); + if (r < 0) { + log_error_errno(r, "Failed to write state: %m"); goto finish; } -- cgit v1.2.3-54-g00ecf