diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-03-09 21:23:53 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-03-09 22:10:54 -0400 |
commit | a6dcc7e5924f9c27d3e9c6560a448b02ec28b65f (patch) | |
tree | 694aa3c7b5b2f4e61fb8c25d5bd8d1f023cf511e /src/journal/journalctl.c | |
parent | ad7bcf526d5ec54838bc9411a0e09a293845a015 (diff) |
Introduce loop_read_exact helper
Usually when using loop_read(), we want to read the full buffer.
Add a helper that mirrors loop_write(), and returns 0 when full buffer
was read, and an error otherwise.
Use -ENODATA for the short read, to distinguish it from a read error.
Diffstat (limited to 'src/journal/journalctl.c')
-rw-r--r-- | src/journal/journalctl.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index f0f03b0697..4d45f5a691 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -1286,7 +1286,6 @@ static int setup_keys(void) { #ifdef HAVE_GCRYPT size_t mpk_size, seed_size, state_size, i; uint8_t *mpk, *seed, *state; - ssize_t l; int fd = -1, r; sd_id128_t machine, boot; char *p = NULL, *k = NULL; @@ -1351,10 +1350,9 @@ static int setup_keys(void) { } log_info("Generating seed..."); - l = loop_read(fd, seed, seed_size, true); - if (l < 0 || (size_t) l != seed_size) { - log_error_errno(EIO, "Failed to read random seed: %m"); - r = -EIO; + r = loop_read_exact(fd, seed, seed_size, true); + if (r < 0) { + log_error_errno(r, "Failed to read random seed: %m"); goto finish; } |