From 524017ac069bc4c9053ee592fc35ccd774f22e0c Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Fri, 24 Sep 2021 08:50:25 +0000 Subject: [PATCH] zdump: stdout_write_dump: if dfo_size() == 0 then don't enter the loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While at it, decrease the scope of @cnt and @rc. Reviewed-by: Alexander Egorenkov Signed-off-by: Marc Hartmayer Signed-off-by: Jan Höppner --- zdump/stdout.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/zdump/stdout.c b/zdump/stdout.c index 4ceee37f..af6facf6 100644 --- a/zdump/stdout.c +++ b/zdump/stdout.c @@ -17,9 +17,8 @@ int stdout_write_dump(void) { const u64 output_size = dfo_size(); - u64 cnt, written = 0; + u64 written = 0; char buf[32768]; - ssize_t rc; if (!dfi_feat_copy()) ERR_EXIT("Copying not possible for %s dumps", dfi_name()); @@ -28,7 +27,10 @@ int stdout_write_dump(void) STDERR(" Target: %s\n", dfo_name()); STDERR("\n"); zg_progress_init("Copying dump", output_size); - do { + while (written != output_size) { + ssize_t rc; + u64 cnt; + cnt = dfo_read(buf, sizeof(buf)); rc = write(STDOUT_FILENO, buf, cnt); if (rc == -1) @@ -37,7 +39,7 @@ int stdout_write_dump(void) ERR_EXIT("Error: Could not write full block"); written += cnt; zg_progress(written); - } while (written != output_size); + }; STDERR("\n"); STDERR("Success: Dump has been copied\n"); return 0;