From a941bcced3d0f4a0edb80b567e280c367301058d Mon Sep 17 00:00:00 2001 From: tastytea Date: Fri, 21 May 2021 07:05:44 +0200 Subject: [PATCH] Initialize the variables where they're needed. --- src/zip.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/zip.cpp b/src/zip.cpp index b340178..17134c2 100644 --- a/src/zip.cpp +++ b/src/zip.cpp @@ -35,22 +35,19 @@ using fmt::format; std::vector list(const fs::path &filepath) { - struct archive *zipfile{}; - struct archive_entry *entry{}; - int result{}; - std::vector toc; - - zipfile = archive_read_new(); + auto *zipfile{archive_read_new()}; archive_read_support_filter_all(zipfile); archive_read_support_format_all(zipfile); - result = archive_read_open_filename(zipfile, filepath.c_str(), 10240); + auto result{archive_read_open_filename(zipfile, filepath.c_str(), 10240)}; if (result != ARCHIVE_OK) { throw exception{format(translate("Could not open {0:s}.").str(), filepath.string())}; } + struct archive_entry *entry{}; + std::vector toc; while (archive_read_next_header(zipfile, &entry) == ARCHIVE_OK) { toc.emplace_back(archive_entry_pathname(entry));