From 3a983573fb493a5005f5cce5ceb7d4be666f6071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Wed, 23 Sep 2020 19:48:19 +0200 Subject: [PATCH] storage: storageBackendWipeLocal: reduce variable scope MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also use MIN instead of open-coding it. Signed-off-by: Ján Tomko Reviewed-by: Martin Kletzander --- src/storage/storage_util.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 94f62515f2..53d4d2a31a 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -2526,10 +2526,8 @@ storageBackendWipeLocal(const char *path, size_t writebuf_length, bool zero_end) { - int written = 0; unsigned long long remaining = 0; off_t size; - size_t write_size = 0; g_autofree char *writebuf = NULL; if (VIR_ALLOC_N(writebuf, writebuf_length) < 0) @@ -2557,9 +2555,9 @@ storageBackendWipeLocal(const char *path, remaining = wipe_len; while (remaining > 0) { + size_t write_size = MIN(writebuf_length, remaining); + int written = safewrite(fd, writebuf, write_size); - write_size = (writebuf_length < remaining) ? writebuf_length : remaining; - written = safewrite(fd, writebuf, write_size); if (written < 0) { virReportSystemError(errno, _("Failed to write %zu bytes to "