From 990f631cbcdab3a611fb4d90fbf8a06f5c5c1183 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 4 Sep 2020 18:02:05 +0200 Subject: [PATCH] archive/bzip2: make variables more local --- src/archive/plugins/Bzip2ArchivePlugin.cxx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/archive/plugins/Bzip2ArchivePlugin.cxx b/src/archive/plugins/Bzip2ArchivePlugin.cxx index 8e7ebab2c..bedb5c54a 100644 --- a/src/archive/plugins/Bzip2ArchivePlugin.cxx +++ b/src/archive/plugins/Bzip2ArchivePlugin.cxx @@ -141,16 +141,13 @@ Bzip2InputStream::Read(void *ptr, size_t length) const ScopeUnlock unlock(mutex); - int bz_result; - size_t nbytes = 0; - bzstream.next_out = (char *)ptr; bzstream.avail_out = length; do { const bool had_input = FillBuffer(); - bz_result = BZ2_bzDecompress(&bzstream); + const int bz_result = BZ2_bzDecompress(&bzstream); if (bz_result == BZ_STREAM_END) { eof = true; @@ -164,7 +161,7 @@ Bzip2InputStream::Read(void *ptr, size_t length) throw std::runtime_error("Unexpected end of bzip2 file"); } while (bzstream.avail_out == length); - nbytes = length - bzstream.avail_out; + const size_t nbytes = length - bzstream.avail_out; offset += nbytes; return nbytes;