From 15774dbe3293cd238935dfd281429f4ba5426577 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Mon, 11 Oct 2021 07:55:52 +0000 Subject: [PATCH] zdump: stdout_write_dump: replace `dfo_size()` calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Read the `dfo_size()` value only once and then reuse it. Reviewed-by: Alexander Egorenkov Signed-off-by: Marc Hartmayer Signed-off-by: Jan Höppner --- zdump/stdout.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zdump/stdout.c b/zdump/stdout.c index 3ddccc62..4ceee37f 100644 --- a/zdump/stdout.c +++ b/zdump/stdout.c @@ -16,6 +16,7 @@ int stdout_write_dump(void) { + const u64 output_size = dfo_size(); u64 cnt, written = 0; char buf[32768]; ssize_t rc; @@ -26,7 +27,7 @@ int stdout_write_dump(void) STDERR(" Source: %s\n", dfi_name()); STDERR(" Target: %s\n", dfo_name()); STDERR("\n"); - zg_progress_init("Copying dump", dfo_size()); + zg_progress_init("Copying dump", output_size); do { cnt = dfo_read(buf, sizeof(buf)); rc = write(STDOUT_FILENO, buf, cnt); @@ -36,7 +37,7 @@ int stdout_write_dump(void) ERR_EXIT("Error: Could not write full block"); written += cnt; zg_progress(written); - } while (written != dfo_size()); + } while (written != output_size); STDERR("\n"); STDERR("Success: Dump has been copied\n"); return 0;