From 2142da9ef98ea6c7c76a7204854ae60f685fa424 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Sat, 9 Jun 2018 13:11:15 +0200 Subject: [PATCH 01/51] Fix missing newline in end status message This was broken in commit e97782c. --- src/cli/main.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/cli/main.cpp b/src/cli/main.cpp index 2ce448e..0caeec8 100644 --- a/src/cli/main.cpp +++ b/src/cli/main.cpp @@ -416,9 +416,12 @@ int main(int argc, char * argv[]) { o.gog_galaxy = (options.count("no-gog-galaxy") == 0); o.data_version = (options.count("data-version") != 0); - if(o.data_version && explicit_action) { - log_error << "Combining --data-version with other options is not allowed"; - return ExitUserError; + if(o.data_version) { + logger::quiet = true; + if(explicit_action) { + log_error << "Combining --data-version with other options is not allowed"; + return ExitUserError; + } } o.extract_unknown = (options.count("no-extract-unknown") == 0); @@ -456,9 +459,7 @@ int main(int argc, char * argv[]) { if(!logger::quiet || logger::total_errors || logger::total_warnings) { progress::clear(); std::ostream & os = logger::quiet ? std::cerr : std::cout; - if(!o.data_version || logger::total_errors || logger::total_warnings) { - os << color::green << "Done" << color::reset << std::dec; - } + os << color::green << "Done" << color::reset << std::dec; if(logger::total_errors || logger::total_warnings) { os << " with "; if(logger::total_errors) { @@ -475,9 +476,7 @@ int main(int argc, char * argv[]) { << color::reset; } } - if(logger::total_errors) { - os << '.' << std::endl; - } + os << '.' << std::endl; } return logger::total_errors == 0 ? ExitSuccess : ExitDataError; From cdac943c47abffdfa410d2887de05dbbc8e61b49 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 09:25:27 +0200 Subject: [PATCH 02/51] windows: Update Windows version names --- src/setup/windows.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/setup/windows.cpp b/src/setup/windows.cpp index 7eba1c1..ffaa06d 100644 --- a/src/setup/windows.cpp +++ b/src/setup/windows.cpp @@ -95,7 +95,10 @@ windows_version_name windows_nt_version_names[] = { { "Windows XP", { 5, 1, 2600 } }, { "Windows XP x64", { 5, 2, 3790 } }, { "Windows Vista", { 6, 0, 6000 } }, - { "Windows 7", { 6, 1, 7600 } } + { "Windows 7", { 6, 1, 7600 } }, + { "Windows 8", { 6, 2, 0 } }, + { "Windows 8.1", { 6, 3, 0 } }, + { "Windows 10", { 10, 0, 0 } }, }; const char * get_version_name(const windows_version::data & version, bool nt = false) { From 453b7244515711489511595a4983244494db8e0b Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 09:40:09 +0200 Subject: [PATCH 03/51] Doxygen: Fix ARC4 warnings --- doc/Doxyfile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index a12b9cb..a9b60d2 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -1512,7 +1512,7 @@ INCLUDE_FILE_PATTERNS = # undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = INNOEXTRACT_HAVE_LZMA +PREDEFINED = INNOEXTRACT_HAVE_ARC4 INNOEXTRACT_HAVE_LZMA # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. From 2e7f6b6e86a53c29a05d7da71f48f5236c068b43 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 09:43:38 +0200 Subject: [PATCH 04/51] encoding: Fix signed/unsigned comparison warnings --- src/util/encoding.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/util/encoding.cpp b/src/util/encoding.cpp index 7297ddb..bbc4c60 100644 --- a/src/util/encoding.cpp +++ b/src/util/encoding.cpp @@ -161,10 +161,10 @@ static const char * get_encoding_name(codepage_id codepage) { } } -static const char replacement_char = '_'; - typedef boost::uint32_t unicode_char; +static const unicode_char replacement_char = '_'; + static size_t get_encoding_size(codepage_id codepage) { switch(codepage) { case 1200: return 2u; // UTF-16LE @@ -204,7 +204,7 @@ static void to_utf8_fallback(const std::string & from, std::string & to, codepag // replace non-ASCII characters with underscores if((unicode_char(ascii) << shift) != unicode) { warn = true; - ascii = replacement_char; + ascii = char(replacement_char); } to.push_back(ascii); @@ -221,7 +221,7 @@ bool is_utf8_continuation_byte(unicode_char chr) { } template -unicode_char utf8_read(In & it, In end, unicode_char replacement = unicode_char(replacement_char)) { +unicode_char utf8_read(In & it, In end, unicode_char replacement = replacement_char) { if(it == end) { return unicode_char(-1); @@ -436,7 +436,7 @@ static void windows1252_to_utf8(const std::string & from, std::string & to) { unicode_char chr = boost::uint8_t(c); if(chr >= 128 && chr < 160) { chr = windows1252_replacements[chr - 128]; - warn = warn || (chr == unicode_char(replacement_char)); + warn = warn || chr == replacement_char; } utf8_write(to, chr); @@ -567,9 +567,9 @@ static bool to_utf8_iconv(const std::string & from, std::string & to, codepage_i } else if(/*errno == EILSEQ &&*/ insize >= 2) { // invalid byte (sequence) - add a replacement char and try the next byte if(outsize == 0) { - to.push_back(replacement_char); + to.push_back(char(replacement_char)); } else { - *outbuf = replacement_char; + *outbuf = char(replacement_char); outsize--; } inbuf.buf += skip; From 791bc9b586a1d106859937ae0ada611c53a9f444 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 09:45:10 +0200 Subject: [PATCH 05/51] encoding: Fix signed/unsigned comparison warnings with old Boost --- src/util/encoding.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/encoding.cpp b/src/util/encoding.cpp index bbc4c60..8a0cfea 100644 --- a/src/util/encoding.cpp +++ b/src/util/encoding.cpp @@ -462,12 +462,12 @@ static void utf8_to_windows1252(const std::string & from, std::string & to) { // Windows-1252 maps almost directly to Unicode - yay! if(chr >= 256 || (chr >= 128 && chr < 160)) { size_t i = 0; - for(; i < boost::size(windows1252_replacements); i++) { + for(; i < size_t(boost::size(windows1252_replacements)); i++) { if(chr == windows1252_replacements[i] && windows1252_replacements[i] != replacement_char) { break; } } - if(i < boost::size(windows1252_replacements)) { + if(i < size_t(boost::size(windows1252_replacements))) { chr = unicode_char(128 + i); } else { chr = replacement_char; From cda6a4e830d3d74ad6f3b90ebe67d8c91eb06235 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 09:48:45 +0200 Subject: [PATCH 06/51] [clang-alanyzer] data: Initialize all fields of struct tm --- src/setup/data.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup/data.cpp b/src/setup/data.cpp index 3e0c2c8..a065bae 100644 --- a/src/setup/data.cpp +++ b/src/setup/data.cpp @@ -80,7 +80,7 @@ void data_entry::load(std::istream & is, const version & version) { boost::uint16_t time = util::load(is); boost::uint16_t date = util::load(is); - struct tm t; + struct tm t = { }; t.tm_sec = util::get_bits(time, 0, 4) * 2; // [0, 58] t.tm_min = util::get_bits(time, 5, 10); // [0, 59] t.tm_hour = util::get_bits(time, 11, 15); // [0, 23] From 180da3d97e6af5d633869b809299b8bd38124ffe Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 09:51:55 +0200 Subject: [PATCH 07/51] [clang-analyzer] console: Fix unused assignment warning --- src/util/console.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/console.cpp b/src/util/console.cpp index 1689e7b..0e3f507 100644 --- a/src/util/console.cpp +++ b/src/util/console.cpp @@ -357,12 +357,13 @@ bool progress::update(boost::uint64_t delta, bool force) { } } - boost::uint64_t time = last_time; + boost::uint64_t time; try { boost::posix_time::ptime now(boost::posix_time::microsec_clock::universal_time()); time = boost::uint64_t((now - start_time).total_microseconds()); } catch(...) { // this shouldn't happen, assume no time has passed + time = last_time; } #if defined(_WIN32) From a9fc4c40dc176ba26a3cb384b604d544609f2cd5 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 09:54:18 +0200 Subject: [PATCH 08/51] [clang-tidy] extract: Remove useless else clause --- src/cli/extract.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cli/extract.cpp b/src/cli/extract.cpp index 9435e86..a0959bb 100644 --- a/src/cli/extract.cpp +++ b/src/cli/extract.cpp @@ -917,9 +917,8 @@ void process_file(const fs::path & file, const extract_options & o) { if(checksum.finalize() != info.header.password) { if(o.check_password) { throw std::runtime_error("Incorrect password provided"); - } else { - log_error << "Incorrect password provided"; } + log_error << "Incorrect password provided"; password.clear(); } } From 8ddc8ad3447fad467103e4ff016d0b3db64010fc Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 09:57:56 +0200 Subject: [PATCH 09/51] [clang-tidy] extract: Initialize extract_options fields --- src/cli/extract.hpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/cli/extract.hpp b/src/cli/extract.hpp index 44e57e9..d28ad17 100644 --- a/src/cli/extract.hpp +++ b/src/cli/extract.hpp @@ -82,6 +82,28 @@ struct extract_options { boost::filesystem::path output_dir; + extract_options() + : quiet(false) + , silent(false) + , warn_unused(false) + , data_version(false) + , list(false) + , test(false) + , extract(false) + , list_languages(false) + , gog_game_id(false) + , show_password(false) + , check_password(false) + , preserve_file_times(false) + , local_timestamps(false) + , gog(false) + , gog_galaxy(false) + , extract_unknown(false) + , extract_temp(false) + , language_only(false) + , collisions(OverwriteCollisions) + { } + }; void process_file(const boost::filesystem::path & file, const extract_options & o); From 98c255afbb4e1ea28aa0ab78904d6fcfae650ee5 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:00:10 +0200 Subject: [PATCH 10/51] arc4: Use boost::uint8_t --- src/crypto/arc4.cpp | 6 +++--- src/crypto/arc4.hpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/crypto/arc4.cpp b/src/crypto/arc4.cpp index b9c5142..a8f91bc 100644 --- a/src/crypto/arc4.cpp +++ b/src/crypto/arc4.cpp @@ -31,12 +31,12 @@ void arc4::init(const char * key, size_t length) { a = b = 0; for(size_t i = 0; i < sizeof(state); i++){ - state[i] = (unsigned char)i; + state[i] = boost::uint8_t(i); } size_t j = 0; for(size_t i = 0; i < sizeof(state); i++) { - j = (j + state[i] + (unsigned char)key[i % length]) % sizeof(state); + j = (j + state[i] + boost::uint8_t(key[i % length])) % sizeof(state); std::swap(state[i], state[j]); } @@ -63,7 +63,7 @@ void arc4::crypt(const char * in, char * out, size_t length) { for(size_t i = 0; i < length; i++) { update(); - out[i] = char(state[size_t(state[a] + state[b]) % sizeof(state)] ^ (unsigned char)in[i]); + out[i] = char(state[size_t(state[a] + state[b]) % sizeof(state)] ^ boost::uint8_t(in[i])); } } diff --git a/src/crypto/arc4.hpp b/src/crypto/arc4.hpp index ea2da30..6363617 100644 --- a/src/crypto/arc4.hpp +++ b/src/crypto/arc4.hpp @@ -49,7 +49,7 @@ private: void update(); - unsigned char state[256]; + boost::uint8_t state[256]; size_t a, b; }; From a4731f1971e65359a1785fe575c23a066923663e Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:04:23 +0200 Subject: [PATCH 11/51] [clang-tidy] encoding: Remove redundant static keywords --- src/util/encoding.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/util/encoding.cpp b/src/util/encoding.cpp index 8a0cfea..0a6748b 100644 --- a/src/util/encoding.cpp +++ b/src/util/encoding.cpp @@ -89,7 +89,7 @@ enum known_codepages { namespace { //! Get names for encodings where iconv doesn't have the codepage alias -static const char * get_encoding_name(codepage_id codepage) { +const char * get_encoding_name(codepage_id codepage) { switch(codepage) { case 708: return "ISO-8859-6"; case 936: return "GBK"; @@ -163,9 +163,9 @@ static const char * get_encoding_name(codepage_id codepage) { typedef boost::uint32_t unicode_char; -static const unicode_char replacement_char = '_'; +const unicode_char replacement_char = '_'; -static size_t get_encoding_size(codepage_id codepage) { +size_t get_encoding_size(codepage_id codepage) { switch(codepage) { case 1200: return 2u; // UTF-16LE case 1201: return 2u; // UTF-16BE @@ -176,7 +176,7 @@ static size_t get_encoding_size(codepage_id codepage) { } //! Fallback conversion that will at least work for ASCII characters -static void to_utf8_fallback(const std::string & from, std::string & to, codepage_id cp) { +void to_utf8_fallback(const std::string & from, std::string & to, codepage_id cp) { size_t skip = get_encoding_size(cp); @@ -270,7 +270,7 @@ unicode_char utf8_read(In & it, In end, unicode_char replacement = replacement_c return chr; } -static size_t utf8_length(unicode_char chr) { +size_t utf8_length(unicode_char chr) { if (chr < 0x80) return 1; else if(chr < 0x800) return 2; else if(chr < 0x10000) return 3; @@ -278,7 +278,7 @@ static size_t utf8_length(unicode_char chr) { return 1; } -static void utf8_write(std::string & to, unicode_char chr) { +void utf8_write(std::string & to, unicode_char chr) { static const boost::uint8_t first_bytes[7] = { 0x00, 0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc @@ -310,16 +310,16 @@ static void utf8_write(std::string & to, unicode_char chr) { } //! \return true c is is the first part of an UTF-16 surrogate pair -static bool is_utf16_high_surrogate(unicode_char chr) { +bool is_utf16_high_surrogate(unicode_char chr) { return chr >= 0xd800 && chr <= 0xdbff; } //! \return true c is is the second part of an UTF-16 surrogate pair -static bool is_utf16_low_surrogate(unicode_char chr) { +bool is_utf16_low_surrogate(unicode_char chr) { return chr >= 0xdc00 && chr <= 0xdfff; } -static void utf16le_to_utf8(const std::string & from, std::string & to) { +void utf16le_to_utf8(const std::string & from, std::string & to) { if(from.size() % 2 != 0) { log_warning << "Unexpected trailing byte in UTF-16 string."; @@ -414,7 +414,7 @@ void utf8_to_utf16le(const std::string & from, std::string & to) { } -static unicode_char windows1252_replacements[] = { +unicode_char windows1252_replacements[] = { 0x20ac, replacement_char, 0x201a, 0x192, 0x201e, 0x2026, 0x2020, 0x2021, 0x2c6, 0x2030, 0x160, 0x2039, 0x152, replacement_char, 0x17d, replacement_char, replacement_char, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x2dc, @@ -423,7 +423,7 @@ static unicode_char windows1252_replacements[] = { BOOST_STATIC_ASSERT(sizeof(windows1252_replacements) == (160 - 128) * sizeof(*windows1252_replacements)); -static void windows1252_to_utf8(const std::string & from, std::string & to) { +void windows1252_to_utf8(const std::string & from, std::string & to) { to.clear(); to.reserve(from.size()); // optimistically, most strings only have ASCII characters @@ -448,7 +448,7 @@ static void windows1252_to_utf8(const std::string & from, std::string & to) { } -static void utf8_to_windows1252(const std::string & from, std::string & to) { +void utf8_to_windows1252(const std::string & from, std::string & to) { to.clear(); to.reserve(from.size()); // optimistically, most strings only have ASCII characters @@ -487,9 +487,9 @@ static void utf8_to_windows1252(const std::string & from, std::string & to) { #if INNOEXTRACT_HAVE_ICONV typedef boost::unordered_map converter_map; -static converter_map converters; +converter_map converters; -static iconv_t get_converter(codepage_id codepage) { +iconv_t get_converter(codepage_id codepage) { // Try to reuse an existing converter if possible converter_map::const_iterator i = converters.find(codepage); @@ -524,7 +524,7 @@ static iconv_t get_converter(codepage_id codepage) { return converters[codepage] = handle; } -static bool to_utf8_iconv(const std::string & from, std::string & to, codepage_id cp) { +bool to_utf8_iconv(const std::string & from, std::string & to, codepage_id cp) { iconv_t converter = get_converter(cp); if(converter == iconv_t(-1)) { @@ -598,7 +598,7 @@ static bool to_utf8_iconv(const std::string & from, std::string & to, codepage_i #if INNOEXTRACT_HAVE_WIN32_CONV -static std::string windows_error_string(DWORD code) { +std::string windows_error_string(DWORD code) { char * error; DWORD n = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, code, 0, reinterpret_cast(&error), 0, @@ -615,7 +615,7 @@ static std::string windows_error_string(DWORD code) { } } -static bool to_utf8_win32(const std::string & from, std::string & to, codepage_id cp) { +bool to_utf8_win32(const std::string & from, std::string & to, codepage_id cp) { int ret = 0; From 9ce544f087436d0addb74b5b8f09c95d2d90c855 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:06:50 +0200 Subject: [PATCH 12/51] [cppcheck] chunk: Pass strign by reference --- src/stream/chunk.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stream/chunk.hpp b/src/stream/chunk.hpp index b5be7b2..10a1193 100644 --- a/src/stream/chunk.hpp +++ b/src/stream/chunk.hpp @@ -47,7 +47,7 @@ class slice_reader; //! Error thrown by \ref chunk_reader::get if there was a problem. struct chunk_error : public std::ios_base::failure { - explicit chunk_error(std::string msg) : std::ios_base::failure(msg) { } + explicit chunk_error(const std::string & msg) : std::ios_base::failure(msg) { } }; From 8668b368707edfb18129f2653aa1efb5ccaf39fa Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:08:17 +0200 Subject: [PATCH 13/51] [clang-tidy] exereader: Remove redundant static keyword --- src/loader/exereader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/loader/exereader.cpp b/src/loader/exereader.cpp index 1539120..25f62f9 100644 --- a/src/loader/exereader.cpp +++ b/src/loader/exereader.cpp @@ -45,7 +45,7 @@ enum BinaryType { PEMagic2 = 0x0000, // "\0\0" }; -static BinaryType determine_binary_type(std::istream & is) { +BinaryType determine_binary_type(std::istream & is) { boost::uint16_t dos_magic = util::load(is.seekg(0)); if(is.fail() || dos_magic != DOSMagic) { From 0b1678411a9cce0c3df38e29eff6f215d4443e30 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:08:55 +0200 Subject: [PATCH 14/51] [clang-tidy] offsets: Remove redundant static keyword --- src/loader/offsets.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/loader/offsets.cpp b/src/loader/offsets.cpp index 072038d..86564fe 100644 --- a/src/loader/offsets.cpp +++ b/src/loader/offsets.cpp @@ -47,7 +47,7 @@ struct setup_loader_version { }; -static const setup_loader_version known_setup_loader_versions[] = { +const setup_loader_version known_setup_loader_versions[] = { { { 'r', 'D', 'l', 'P', 't', 'S', '0', '2', 0x87, 'e', 'V', 'x' }, INNO_VERSION(1, 2, 10) }, { { 'r', 'D', 'l', 'P', 't', 'S', '0', '4', 0x87, 'e', 'V', 'x' }, INNO_VERSION(4, 0, 0) }, { { 'r', 'D', 'l', 'P', 't', 'S', '0', '5', 0x87, 'e', 'V', 'x' }, INNO_VERSION(4, 0, 3) }, From 96ac41087ca6e4e25975911da71ff3a9134b358d Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:09:47 +0200 Subject: [PATCH 15/51] [clang-tidy] expression: Remove redundant static keyword --- src/setup/expression.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/setup/expression.cpp b/src/setup/expression.cpp index 5b6505f..0ed1a74 100644 --- a/src/setup/expression.cpp +++ b/src/setup/expression.cpp @@ -31,11 +31,11 @@ namespace setup { namespace { -static bool is_identifier_start(char c) { +bool is_identifier_start(char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '-'; } -static bool is_identifier(char c) { +bool is_identifier(char c) { return is_identifier_start(c) || (c >= '0' && c <= '9') || c == '\\'; } From fdf73d8d973b3e0b67fbe84d5d6ac94f6322ec17 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:10:31 +0200 Subject: [PATCH 16/51] [clang-tidy] filename: Remove redundant static keyword --- src/setup/filename.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup/filename.cpp b/src/setup/filename.cpp index d920de6..73a7e81 100644 --- a/src/setup/filename.cpp +++ b/src/setup/filename.cpp @@ -53,7 +53,7 @@ struct is_unsafe_path_char { } }; -static std::string replace_unsafe_chars(const std::string & str) { +std::string replace_unsafe_chars(const std::string & str) { std::string result; result.resize(str.size()); std::replace_copy_if(str.begin(), str.end(), result.begin(), is_unsafe_path_char(), '$'); From 86b1ca1d83da3359e3540051c0c87dea5b851ce1 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:11:56 +0200 Subject: [PATCH 17/51] [clang-tidy] version: Remove redundant static keyword --- src/setup/version.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/setup/version.cpp b/src/setup/version.cpp index 087c0ea..86bfd77 100644 --- a/src/setup/version.cpp +++ b/src/setup/version.cpp @@ -53,7 +53,7 @@ struct known_legacy_version { }; -static const known_legacy_version legacy_versions[] = { +const known_legacy_version legacy_versions[] = { { "i1.2.10--16\x1a", INNO_VERSION(1, 2, 10), 16 }, { "i1.2.10--32\x1a", INNO_VERSION(1, 2, 10), 32 }, }; @@ -71,7 +71,7 @@ struct known_version { }; -static const known_version versions[] = { +const known_version versions[] = { { "Inno Setup Setup Data (1.3.21)", INNO_VERSION_EXT(1, 3, 21, 0), false }, { "Inno Setup Setup Data (1.3.25)", INNO_VERSION_EXT(1, 3, 25, 0), false }, { "Inno Setup Setup Data (2.0.0)", INNO_VERSION_EXT(2, 0, 0, 0), false }, From d3872816a1069acfa9241934cbaf098da994906f Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:15:28 +0200 Subject: [PATCH 18/51] [clang-tidy] exefilter: Fix unnamed parameter warnings --- src/stream/exefilter.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stream/exefilter.hpp b/src/stream/exefilter.hpp index 21ef002..7ea1c53 100644 --- a/src/stream/exefilter.hpp +++ b/src/stream/exefilter.hpp @@ -63,7 +63,7 @@ public: template - void close(const Source &) { + void close(const Source & /* source */) { addr_bytes_left = 0, addr_offset = 5; } @@ -103,7 +103,7 @@ public: std::streamsize read(Source & src, char * dest, std::streamsize n); template - void close(const Source &) { + void close(const Source & /* source */) { offset = 0, flush_bytes = 0; } From 1938882fb02496a03aacf388442a719a5c20fb57 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:16:20 +0200 Subject: [PATCH 19/51] [clang-tidy] flags: Fix unnamed parameter warning --- src/util/flags.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/flags.hpp b/src/util/flags.hpp index 54cc412..00d3578 100644 --- a/src/util/flags.hpp +++ b/src/util/flags.hpp @@ -63,7 +63,7 @@ public: /* implicit */ inline flags(enum_type flag) : _flags(Type().set(size_t(flag))) { } - /* implicit */ inline flags(Zero = 0) : _flags() { } + /* implicit */ inline flags(Zero /* zero */ = 0) : _flags() { } flags(const flags & o) : _flags(o._flags) { } From dc8fb603bf67532a1b9f3ae3e3e1c3f58a76f219 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:17:34 +0200 Subject: [PATCH 20/51] [clang-tidy] math: Fix unnamed parameter warning --- src/util/math.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/math.hpp b/src/util/math.hpp index 478e2b5..703769c 100644 --- a/src/util/math.hpp +++ b/src/util/math.hpp @@ -56,12 +56,12 @@ template struct safe_shifter { template - static T right_shift(T, unsigned int) { + static T right_shift(T /* value */, unsigned int /* bits */) { return 0; } template - static T left_shift(T, unsigned int) { + static T left_shift(T /* value */, unsigned int /* bits */) { return 0; } From 84195029ec897ea73496e4ff24edfd002a07fbcd Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:19:16 +0200 Subject: [PATCH 21/51] [clang-tidy] adler32: Fix mismatched parameter names --- src/crypto/adler32.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/crypto/adler32.cpp b/src/crypto/adler32.cpp index 5459f63..fb5cc35 100644 --- a/src/crypto/adler32.cpp +++ b/src/crypto/adler32.cpp @@ -25,7 +25,7 @@ namespace crypto { -void adler32::update(const char * input, size_t length) { +void adler32::update(const char * data, size_t length) { const boost::uint_fast32_t base = 65521; @@ -35,7 +35,7 @@ void adler32::update(const char * input, size_t length) { if(length % 8 != 0) { do { - s1 += boost::uint8_t(*input++); + s1 += boost::uint8_t(*data++); s2 += s1; length--; } while(length % 8 != 0); @@ -49,17 +49,17 @@ void adler32::update(const char * input, size_t length) { while(length > 0) { - s1 += boost::uint8_t(input[0]), s2 += s1; - s1 += boost::uint8_t(input[1]), s2 += s1; - s1 += boost::uint8_t(input[2]), s2 += s1; - s1 += boost::uint8_t(input[3]), s2 += s1; - s1 += boost::uint8_t(input[4]), s2 += s1; - s1 += boost::uint8_t(input[5]), s2 += s1; - s1 += boost::uint8_t(input[6]), s2 += s1; - s1 += boost::uint8_t(input[7]), s2 += s1; + s1 += boost::uint8_t(data[0]), s2 += s1; + s1 += boost::uint8_t(data[1]), s2 += s1; + s1 += boost::uint8_t(data[2]), s2 += s1; + s1 += boost::uint8_t(data[3]), s2 += s1; + s1 += boost::uint8_t(data[4]), s2 += s1; + s1 += boost::uint8_t(data[5]), s2 += s1; + s1 += boost::uint8_t(data[6]), s2 += s1; + s1 += boost::uint8_t(data[7]), s2 += s1; length -= 8; - input += 8; + data += 8; if(s1 >= base) { s1 -= base; From d472094b5c1519d8bdf5cbc56565c69ed6cdff59 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:20:01 +0200 Subject: [PATCH 22/51] [clang-tidy] checksum: Fix mismatched parameter names --- src/crypto/checksum.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/crypto/checksum.cpp b/src/crypto/checksum.cpp index 94db8d6..8b35844 100644 --- a/src/crypto/checksum.cpp +++ b/src/crypto/checksum.cpp @@ -29,18 +29,18 @@ namespace crypto { -bool checksum::operator==(const checksum & o) const { +bool checksum::operator==(const checksum & other) const { - if(o.type != type) { + if(other.type != type) { return false; } switch(type) { case None: return true; - case Adler32: return (adler32 == o.adler32); - case CRC32: return (crc32 == o.crc32); - case MD5: return !memcmp(md5, o.md5, sizeof(md5)); - case SHA1: return !memcmp(sha1, o.sha1, sizeof(sha1)); + case Adler32: return (adler32 == other.adler32); + case CRC32: return (crc32 == other.crc32); + case MD5: return !memcmp(md5, other.md5, sizeof(md5)); + case SHA1: return !memcmp(sha1, other.sha1, sizeof(sha1)); default: return false; }; } From 3064428b87e00ea7f0b9a837979560d04a05f41d Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:21:34 +0200 Subject: [PATCH 23/51] [clang-tidy] crc32: Fix mismatched parameter names --- src/crypto/crc32.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/crypto/crc32.cpp b/src/crypto/crc32.cpp index 8dc2ffe..99b53a6 100644 --- a/src/crypto/crc32.cpp +++ b/src/crypto/crc32.cpp @@ -91,25 +91,26 @@ static boost::uint32_t crc32_shifted(boost::uint32_t crc) { return crc >> 8; } -void crc32::update(const char * s, size_t n) { +void crc32::update(const char * data, size_t length) { - for(; (size_t(s) % 4 != 0) && n > 0; n--) { - crc = crc32_table[crc32_index(crc) ^ boost::uint8_t(*s++)] ^ crc32_shifted(crc); + for(; (size_t(data) % 4 != 0) && length > 0; length--) { + crc = crc32_table[crc32_index(crc) ^ boost::uint8_t(*data++)] ^ crc32_shifted(crc); } - while(n >= 4) { - crc ^= util::little_endian::load(s); + while(length >= 4) { + crc ^= util::little_endian::load(data); crc = crc32_table[crc32_index(crc)] ^ crc32_shifted(crc); crc = crc32_table[crc32_index(crc)] ^ crc32_shifted(crc); crc = crc32_table[crc32_index(crc)] ^ crc32_shifted(crc); crc = crc32_table[crc32_index(crc)] ^ crc32_shifted(crc); - n -= 4; - s += 4; + length -= 4; + data += 4; } - while(n--) { - crc = crc32_table[crc32_index(crc) ^ boost::uint8_t(*s++)] ^ crc32_shifted(crc); + while(length--) { + crc = crc32_table[crc32_index(crc) ^ boost::uint8_t(*data++)] ^ crc32_shifted(crc); } + } } // namespace crypto From 8559ae4afec2cdf9dc8a2147b6067198aaabea25 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:25:40 +0200 Subject: [PATCH 24/51] [clang-tidy] iteratedhash: Fix mismatched parameter names --- src/crypto/iteratedhash.hpp | 52 ++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/crypto/iteratedhash.hpp b/src/crypto/iteratedhash.hpp index d15ab5b..c8a8a4d 100644 --- a/src/crypto/iteratedhash.hpp +++ b/src/crypto/iteratedhash.hpp @@ -68,7 +68,7 @@ private: } hash_word bit_count_lo() const { return count_lo << 3; } - char data[block_size]; + char buffer[block_size]; hash_word state[hash_size]; hash_word count_lo, count_hi; @@ -76,40 +76,40 @@ private: }; template -void iterated_hash::update(const char * input, size_t len) { +void iterated_hash::update(const char * data, size_t length) { hash_word old_count_lo = count_lo; - if((count_lo = old_count_lo + hash_word(len)) < old_count_lo) { + if((count_lo = old_count_lo + hash_word(length)) < old_count_lo) { count_hi++; // carry from low to high } - count_hi += hash_word(util::safe_right_shift<8 * sizeof(hash_word)>(len)); + count_hi += hash_word(util::safe_right_shift<8 * sizeof(hash_word)>(length)); size_t num = util::mod_power_of_2(old_count_lo, size_t(block_size)); if(num != 0) { // process left over data - if(num + len >= block_size) { - std::memcpy(data + num, input, block_size-num); - hash(data, block_size); - input += (block_size - num); - len -= (block_size - num); + if(num + length >= block_size) { + std::memcpy(buffer + num, data, block_size-num); + hash(buffer, block_size); + data += (block_size - num); + length -= (block_size - num); // drop through and do the rest } else { - std::memcpy(data + num, input, len); + std::memcpy(buffer + num, data, length); return; } } // now process the input data in blocks of BlockSize bytes and save the leftovers to m_data - if(len >= block_size) { - size_t leftOver = hash(input, len); - input += (len - leftOver); - len = leftOver; + if(length >= block_size) { + size_t left_over = hash(data, length); + data += (length - left_over); + length = left_over; } - if(len) { - memcpy(data, input, len); + if(length) { + memcpy(buffer, data, length); } } @@ -151,30 +151,30 @@ void iterated_hash::pad(size_t last_block_size, char pad_first) { size_t num = util::mod_power_of_2(count_lo, size_t(block_size)); - data[num++] = pad_first; + buffer[num++] = pad_first; if(num <= last_block_size) { - memset(data + num, 0, last_block_size - num); + memset(buffer + num, 0, last_block_size - num); } else { - memset(data + num, 0, block_size - num); - hash(data, block_size); - memset(data, 0, last_block_size); + memset(buffer + num, 0, block_size - num); + hash(buffer, block_size); + memset(buffer, 0, last_block_size); } } template -void iterated_hash::finalize(char * digest) { +void iterated_hash::finalize(char * result) { size_t order = transform::offset * sizeof(hash_word); size_t size = block_size - 2 * sizeof(hash_word); pad(size); - byte_order::store(bit_count_lo(), data + size + order); - byte_order::store(bit_count_hi(), data + size + sizeof(hash_word) - order); + byte_order::store(bit_count_lo(), buffer + size + order); + byte_order::store(bit_count_hi(), buffer + size + sizeof(hash_word) - order); - hash(data, block_size); + hash(buffer, block_size); - byte_order::store(state, hash_size, digest); + byte_order::store(state, hash_size, result); } From 90316e10ab1113f4e53954102ae7bcb9b858391b Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:28:52 +0200 Subject: [PATCH 25/51] [clang-tidy] md5: Fix mismatched parameter names --- src/crypto/md5.cpp | 168 ++++++++++++++++++++++----------------------- src/crypto/md5.hpp | 3 +- 2 files changed, 86 insertions(+), 85 deletions(-) diff --git a/src/crypto/md5.cpp b/src/crypto/md5.cpp index b355b19..7ee4aee 100644 --- a/src/crypto/md5.cpp +++ b/src/crypto/md5.cpp @@ -35,101 +35,101 @@ void md5_transform::init(hash_word * state) { state[3] = 0x10325476L; } -void md5_transform::transform(hash_word * digest, const hash_word * in) { +void md5_transform::transform(hash_word * state, const hash_word * data) { -#define F1(x, y, z) (z ^ (x & (y ^ z))) -#define F2(x, y, z) F1(z, x, y) -#define F3(x, y, z) (x ^ y ^ z) -#define F4(x, y, z) (y ^ (x | ~z)) + #define F1(x, y, z) (z ^ (x & (y ^ z))) + #define F2(x, y, z) F1(z, x, y) + #define F3(x, y, z) (x ^ y ^ z) + #define F4(x, y, z) (y ^ (x | ~z)) -#define MD5STEP(f, w, x, y, z, data, s) \ - w = util::rotl_fixed(w + f(x, y, z) + data, s) + x + #define MD5STEP(f, w, x, y, z, word, s) \ + w = util::rotl_fixed(w + f(x, y, z) + word, s) + x hash_word a, b, c, d; - a = digest[0]; - b = digest[1]; - c = digest[2]; - d = digest[3]; + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; - MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); - MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); - MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); - MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); - MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); - MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); - MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); - MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); - MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); - MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); - MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); - MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); - MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); - MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); - MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); - MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); + MD5STEP(F1, a, b, c, d, data[0] + 0xd76aa478, 7); + MD5STEP(F1, d, a, b, c, data[1] + 0xe8c7b756, 12); + MD5STEP(F1, c, d, a, b, data[2] + 0x242070db, 17); + MD5STEP(F1, b, c, d, a, data[3] + 0xc1bdceee, 22); + MD5STEP(F1, a, b, c, d, data[4] + 0xf57c0faf, 7); + MD5STEP(F1, d, a, b, c, data[5] + 0x4787c62a, 12); + MD5STEP(F1, c, d, a, b, data[6] + 0xa8304613, 17); + MD5STEP(F1, b, c, d, a, data[7] + 0xfd469501, 22); + MD5STEP(F1, a, b, c, d, data[8] + 0x698098d8, 7); + MD5STEP(F1, d, a, b, c, data[9] + 0x8b44f7af, 12); + MD5STEP(F1, c, d, a, b, data[10] + 0xffff5bb1, 17); + MD5STEP(F1, b, c, d, a, data[11] + 0x895cd7be, 22); + MD5STEP(F1, a, b, c, d, data[12] + 0x6b901122, 7); + MD5STEP(F1, d, a, b, c, data[13] + 0xfd987193, 12); + MD5STEP(F1, c, d, a, b, data[14] + 0xa679438e, 17); + MD5STEP(F1, b, c, d, a, data[15] + 0x49b40821, 22); - MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); - MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); - MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); - MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); - MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); - MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); - MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); - MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); - MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); - MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); - MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); - MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); - MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); - MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); - MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); - MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); + MD5STEP(F2, a, b, c, d, data[1] + 0xf61e2562, 5); + MD5STEP(F2, d, a, b, c, data[6] + 0xc040b340, 9); + MD5STEP(F2, c, d, a, b, data[11] + 0x265e5a51, 14); + MD5STEP(F2, b, c, d, a, data[0] + 0xe9b6c7aa, 20); + MD5STEP(F2, a, b, c, d, data[5] + 0xd62f105d, 5); + MD5STEP(F2, d, a, b, c, data[10] + 0x02441453, 9); + MD5STEP(F2, c, d, a, b, data[15] + 0xd8a1e681, 14); + MD5STEP(F2, b, c, d, a, data[4] + 0xe7d3fbc8, 20); + MD5STEP(F2, a, b, c, d, data[9] + 0x21e1cde6, 5); + MD5STEP(F2, d, a, b, c, data[14] + 0xc33707d6, 9); + MD5STEP(F2, c, d, a, b, data[3] + 0xf4d50d87, 14); + MD5STEP(F2, b, c, d, a, data[8] + 0x455a14ed, 20); + MD5STEP(F2, a, b, c, d, data[13] + 0xa9e3e905, 5); + MD5STEP(F2, d, a, b, c, data[2] + 0xfcefa3f8, 9); + MD5STEP(F2, c, d, a, b, data[7] + 0x676f02d9, 14); + MD5STEP(F2, b, c, d, a, data[12] + 0x8d2a4c8a, 20); - MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); - MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); - MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); - MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); - MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); - MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); - MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); - MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); - MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); - MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); - MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); - MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); - MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); - MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); - MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); - MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); + MD5STEP(F3, a, b, c, d, data[5] + 0xfffa3942, 4); + MD5STEP(F3, d, a, b, c, data[8] + 0x8771f681, 11); + MD5STEP(F3, c, d, a, b, data[11] + 0x6d9d6122, 16); + MD5STEP(F3, b, c, d, a, data[14] + 0xfde5380c, 23); + MD5STEP(F3, a, b, c, d, data[1] + 0xa4beea44, 4); + MD5STEP(F3, d, a, b, c, data[4] + 0x4bdecfa9, 11); + MD5STEP(F3, c, d, a, b, data[7] + 0xf6bb4b60, 16); + MD5STEP(F3, b, c, d, a, data[10] + 0xbebfbc70, 23); + MD5STEP(F3, a, b, c, d, data[13] + 0x289b7ec6, 4); + MD5STEP(F3, d, a, b, c, data[0] + 0xeaa127fa, 11); + MD5STEP(F3, c, d, a, b, data[3] + 0xd4ef3085, 16); + MD5STEP(F3, b, c, d, a, data[6] + 0x04881d05, 23); + MD5STEP(F3, a, b, c, d, data[9] + 0xd9d4d039, 4); + MD5STEP(F3, d, a, b, c, data[12] + 0xe6db99e5, 11); + MD5STEP(F3, c, d, a, b, data[15] + 0x1fa27cf8, 16); + MD5STEP(F3, b, c, d, a, data[2] + 0xc4ac5665, 23); - MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); - MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); - MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); - MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); - MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); - MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); - MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); - MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); - MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); - MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); - MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); - MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); - MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); - MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); - MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); - MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); + MD5STEP(F4, a, b, c, d, data[0] + 0xf4292244, 6); + MD5STEP(F4, d, a, b, c, data[7] + 0x432aff97, 10); + MD5STEP(F4, c, d, a, b, data[14] + 0xab9423a7, 15); + MD5STEP(F4, b, c, d, a, data[5] + 0xfc93a039, 21); + MD5STEP(F4, a, b, c, d, data[12] + 0x655b59c3, 6); + MD5STEP(F4, d, a, b, c, data[3] + 0x8f0ccc92, 10); + MD5STEP(F4, c, d, a, b, data[10] + 0xffeff47d, 15); + MD5STEP(F4, b, c, d, a, data[1] + 0x85845dd1, 21); + MD5STEP(F4, a, b, c, d, data[8] + 0x6fa87e4f, 6); + MD5STEP(F4, d, a, b, c, data[15] + 0xfe2ce6e0, 10); + MD5STEP(F4, c, d, a, b, data[6] + 0xa3014314, 15); + MD5STEP(F4, b, c, d, a, data[13] + 0x4e0811a1, 21); + MD5STEP(F4, a, b, c, d, data[4] + 0xf7537e82, 6); + MD5STEP(F4, d, a, b, c, data[11] + 0xbd3af235, 10); + MD5STEP(F4, c, d, a, b, data[2] + 0x2ad7d2bb, 15); + MD5STEP(F4, b, c, d, a, data[9] + 0xeb86d391, 21); - digest[0] += a; - digest[1] += b; - digest[2] += c; - digest[3] += d; + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; -#undef MD5STEP -#undef F4 -#undef F3 -#undef F2 -#undef F1 + #undef MD5STEP + #undef F4 + #undef F3 + #undef F2 + #undef F1 } diff --git a/src/crypto/md5.hpp b/src/crypto/md5.hpp index 00125a6..f4c1974 100644 --- a/src/crypto/md5.hpp +++ b/src/crypto/md5.hpp @@ -45,7 +45,8 @@ public: static void init(hash_word * state); - static void transform(hash_word * digest, const hash_word * data); + static void transform(hash_word * state, const hash_word * data); + }; typedef iterated_hash md5; From 56bd8eb160b109ddfd777e25c295e11285b53942 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:32:35 +0200 Subject: [PATCH 26/51] [clang-tidy] sha1: Fix mismatched parameter names --- src/crypto/sha1.cpp | 72 ++++++++++++++++++++++----------------------- src/crypto/sha1.hpp | 2 +- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/crypto/sha1.cpp b/src/crypto/sha1.cpp index aece111..485f113 100644 --- a/src/crypto/sha1.cpp +++ b/src/crypto/sha1.cpp @@ -37,31 +37,31 @@ void sha1_transform::init(hash_word * state) { void sha1_transform::transform(hash_word * state, const hash_word * data) { -#define blk0(i) (W[i] = data[i]) -#define blk1(i) (W[i & 15] = util::rotl_fixed(W[(i + 13) & 15] ^ W[(i + 8) & 15] \ - ^ W[(i + 2) & 15] ^ W[i & 15], 1)) - -#define f1(x, y, z) (z ^ (x & (y ^ z))) -#define f2(x, y, z) (x ^ y ^ z) -#define f3(x, y, z) ((x & y) | (z & (x | y))) -#define f4(x, y, z) (x ^ y ^ z) - -/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ -#define R0(v, w, x, y, z, i) \ - z += f1(w, x, y) + blk0(i) + 0x5A827999 + util::rotl_fixed(v, 5); \ - w = util::rotl_fixed(w, 30); -#define R1(v, w, x, y, z, i) \ - z += f1(w, x, y) + blk1(i) + 0x5A827999 + util::rotl_fixed(v, 5); \ - w = util::rotl_fixed(w, 30); -#define R2(v, w, x, y, z, i) \ - z += f2(w, x, y) + blk1(i) + 0x6ED9EBA1 + util::rotl_fixed(v, 5); \ - w = util::rotl_fixed(w, 30); -#define R3(v, w, x, y, z, i) \ - z += f3(w, x, y) + blk1(i) + 0x8F1BBCDC + util::rotl_fixed(v, 5); \ - w = util::rotl_fixed(w, 30); -#define R4(v, w, x, y, z, i) \ - z += f4(w, x, y) + blk1(i) + 0xCA62C1D6 + util::rotl_fixed(v, 5); \ - w = util::rotl_fixed(w, 30); + #define blk0(i) (W[i] = data[i]) + #define blk1(i) (W[i & 15] = util::rotl_fixed(W[(i + 13) & 15] ^ W[(i + 8) & 15] \ + ^ W[(i + 2) & 15] ^ W[i & 15], 1)) + + #define f1(x, y, z) (z ^ (x & (y ^ z))) + #define f2(x, y, z) (x ^ y ^ z) + #define f3(x, y, z) ((x & y) | (z & (x | y))) + #define f4(x, y, z) (x ^ y ^ z) + + /* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ + #define R0(v, w, x, y, z, i) \ + z += f1(w, x, y) + blk0(i) + 0x5A827999 + util::rotl_fixed(v, 5); \ + w = util::rotl_fixed(w, 30); + #define R1(v, w, x, y, z, i) \ + z += f1(w, x, y) + blk1(i) + 0x5A827999 + util::rotl_fixed(v, 5); \ + w = util::rotl_fixed(w, 30); + #define R2(v, w, x, y, z, i) \ + z += f2(w, x, y) + blk1(i) + 0x6ED9EBA1 + util::rotl_fixed(v, 5); \ + w = util::rotl_fixed(w, 30); + #define R3(v, w, x, y, z, i) \ + z += f3(w, x, y) + blk1(i) + 0x8F1BBCDC + util::rotl_fixed(v, 5); \ + w = util::rotl_fixed(w, 30); + #define R4(v, w, x, y, z, i) \ + z += f4(w, x, y) + blk1(i) + 0xCA62C1D6 + util::rotl_fixed(v, 5); \ + w = util::rotl_fixed(w, 30); hash_word W[16]; @@ -181,19 +181,19 @@ void sha1_transform::transform(hash_word * state, const hash_word * data) { state[3] += d; state[4] += e; -#undef R4 -#undef R3 -#undef R2 -#undef R1 -#undef R0 + #undef R4 + #undef R3 + #undef R2 + #undef R1 + #undef R0 -#undef f4 -#undef f3 -#undef f2 -#undef f1 + #undef f4 + #undef f3 + #undef f2 + #undef f1 -#undef blk1 -#undef blk0 + #undef blk1 + #undef blk0 } diff --git a/src/crypto/sha1.hpp b/src/crypto/sha1.hpp index 8a166db..4534892 100644 --- a/src/crypto/sha1.hpp +++ b/src/crypto/sha1.hpp @@ -45,7 +45,7 @@ public: static void init(hash_word * state); - static void transform(hash_word * digest, const hash_word * data); + static void transform(hash_word * state, const hash_word * data); }; typedef iterated_hash sha1; From af15c997ffacc70f5b9d20c6e50dd3a7b58924a9 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:34:15 +0200 Subject: [PATCH 27/51] [clang-tidy] exereader: Fix mismatched parameter names --- src/loader/exereader.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/loader/exereader.cpp b/src/loader/exereader.cpp index 25f62f9..ca5033a 100644 --- a/src/loader/exereader.cpp +++ b/src/loader/exereader.cpp @@ -365,7 +365,7 @@ bool pe_reader::get_resource_table(boost::uint32_t & entry, boost::uint32_t offs return is_table; } -boost::uint32_t pe_reader::find_resource_entry(std::istream & is, boost::uint32_t needle) { +boost::uint32_t pe_reader::find_resource_entry(std::istream & is, boost::uint32_t id) { // skip: characteristics + timestamp + major version + minor version if(is.seekg(4 + 4 + 2 + 2, std::ios_base::cur).fail()) { @@ -378,7 +378,7 @@ boost::uint32_t pe_reader::find_resource_entry(std::istream & is, boost::uint32_ // Number of id resource entries. boost::uint16_t nbids = util::load(is); - if(needle == Default) { + if(id == Default) { boost::uint32_t offset = util::load(is.seekg(4, std::ios_base::cur)); return is.fail() ? 0 : offset; } @@ -391,14 +391,14 @@ boost::uint32_t pe_reader::find_resource_entry(std::istream & is, boost::uint32_ for(size_t i = 0; i < nbids; i++) { - boost::uint32_t id = util::load(is); - boost::uint32_t offset = util::load(is); + boost::uint32_t entry_id = util::load(is); + boost::uint32_t entry_offset = util::load(is); if(is.fail()) { return 0; } - if(id == needle) { - return offset; + if(entry_id == id) { + return entry_offset; } } From fedb1141b23ab1e73da25b5e34beb4e959bd6bdf Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:36:00 +0200 Subject: [PATCH 28/51] [clang-tidy] expression: Fix mismatched parameter names --- src/setup/expression.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/setup/expression.cpp b/src/setup/expression.cpp index 0ed1a74..4bc205d 100644 --- a/src/setup/expression.cpp +++ b/src/setup/expression.cpp @@ -150,11 +150,11 @@ struct evaluator { } // anonymous namespace -bool expression_match(const std::string & test, const std::string & expr) { +bool expression_match(const std::string & test, const std::string & expression) { try { - return evaluator(expr, test).eval(); + return evaluator(expression, test).eval(); } catch(const std::runtime_error & error) { - log_warning << "Error evaluating \"" << expr << "\": " << error.what(); + log_warning << "Error evaluating \"" << expression << "\": " << error.what(); return true; } } From 00d0071ae85b675990c4e161db39acb6666c9f10 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:37:38 +0200 Subject: [PATCH 29/51] [clang-tidy] path: Fix mismatched parameter names --- src/setup/filename.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/setup/filename.cpp b/src/setup/filename.cpp index 73a7e81..fe4fa28 100644 --- a/src/setup/filename.cpp +++ b/src/setup/filename.cpp @@ -160,20 +160,20 @@ std::string filename_map::shorten_path(const std::string & path) const { return result; } -std::string filename_map::convert(std::string input) const { +std::string filename_map::convert(std::string path) const { // Convert paths to lower-case if requested if(lowercase) { - std::transform(input.begin(), input.end(), input.begin(), ::tolower); + std::transform(path.begin(), path.end(), path.begin(), ::tolower); } // Don't expand variables if requested if(!expand) { - return input; + return path; } - it begin = input.begin(); - std::string expanded = expand_variables(begin, input.end()); + it begin = path.begin(); + std::string expanded = expand_variables(begin, path.end()); return shorten_path(expanded); } From 97fb5ce2ce5e6227e9bc5cfb7386abb0a6dda349 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:47:01 +0200 Subject: [PATCH 30/51] [clang-tidy] info: Fix mismatched parameter names --- src/setup/info.cpp | 56 +++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/setup/info.cpp b/src/setup/info.cpp index 033441a..3ef9196 100644 --- a/src/setup/info.cpp +++ b/src/setup/info.cpp @@ -162,50 +162,50 @@ void check_is_end(stream::block_reader::pointer & is, const char * what) { } // anonymous namespace -void info::load(std::istream & ifs, entry_types e, const setup::version & v) { +void info::load(std::istream & is, entry_types entries, const setup::version & version) { - if(e & (Messages | NoSkip)) { - e |= Languages; + if(entries & (Messages | NoSkip)) { + entries |= Languages; } - stream::block_reader::pointer is = stream::block_reader::get(ifs, v); + stream::block_reader::pointer reader = stream::block_reader::get(is, version); - header.load(*is, v); + header.load(*reader, version); - load_entries(*is, v, e, header.language_count, languages, Languages); + load_entries(*reader, version, entries, header.language_count, languages, Languages); - if(v < INNO_VERSION(4, 0, 0)) { - load_wizard_and_decompressor(*is, v, header, *this, e); + if(version < INNO_VERSION(4, 0, 0)) { + load_wizard_and_decompressor(*reader, version, header, *this, entries); } - load_entries(*is, v, e, header.message_count, messages, Messages, languages); - load_entries(*is, v, e, header.permission_count, permissions, Permissions); - load_entries(*is, v, e, header.type_count, types, Types); - load_entries(*is, v, e, header.component_count, components, Components); - load_entries(*is, v, e, header.task_count, tasks, Tasks); - load_entries(*is, v, e, header.directory_count, directories, Directories); - load_entries(*is, v, e, header.file_count, files, Files); - load_entries(*is, v, e, header.icon_count, icons, Icons); - load_entries(*is, v, e, header.ini_entry_count, ini_entries, IniEntries); - load_entries(*is, v, e, header.registry_entry_count, registry_entries, RegistryEntries); - load_entries(*is, v, e, header.delete_entry_count, delete_entries, DeleteEntries); - load_entries(*is, v, e, header.uninstall_delete_entry_count, uninstall_delete_entries, + load_entries(*reader, version, entries, header.message_count, messages, Messages, languages); + load_entries(*reader, version, entries, header.permission_count, permissions, Permissions); + load_entries(*reader, version, entries, header.type_count, types, Types); + load_entries(*reader, version, entries, header.component_count, components, Components); + load_entries(*reader, version, entries, header.task_count, tasks, Tasks); + load_entries(*reader, version, entries, header.directory_count, directories, Directories); + load_entries(*reader, version, entries, header.file_count, files, Files); + load_entries(*reader, version, entries, header.icon_count, icons, Icons); + load_entries(*reader, version, entries, header.ini_entry_count, ini_entries, IniEntries); + load_entries(*reader, version, entries, header.registry_entry_count, registry_entries, RegistryEntries); + load_entries(*reader, version, entries, header.delete_entry_count, delete_entries, DeleteEntries); + load_entries(*reader, version, entries, header.uninstall_delete_entry_count, uninstall_delete_entries, UninstallDeleteEntries); - load_entries(*is, v, e, header.run_entry_count, run_entries, RunEntries); - load_entries(*is, v, e, header.uninstall_run_entry_count, uninstall_run_entries, + load_entries(*reader, version, entries, header.run_entry_count, run_entries, RunEntries); + load_entries(*reader, version, entries, header.uninstall_run_entry_count, uninstall_run_entries, UninstallRunEntries); - if(v >= INNO_VERSION(4, 0, 0)) { - load_wizard_and_decompressor(*is, v, header, *this, e); + if(version >= INNO_VERSION(4, 0, 0)) { + load_wizard_and_decompressor(*reader, version, header, *this, entries); } // restart the compression stream - check_is_end(is, "unknown data at end of primary header stream"); - is = stream::block_reader::get(ifs, v); + check_is_end(reader, "unknown data at end of primary header stream"); + reader = stream::block_reader::get(is, version); - load_entries(*is, v, e, header.data_entry_count, data_entries, DataEntries); + load_entries(*reader, version, entries, header.data_entry_count, data_entries, DataEntries); - check_is_end(is, "unknown data at end of secondary header stream"); + check_is_end(reader, "unknown data at end of secondary header stream"); } void info::load(std::istream & is, entry_types entries) { From 2f717ddfc67b1abb5f4ddf26f69799a50ceb661b Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:47:53 +0200 Subject: [PATCH 31/51] [clang-tidy] permission: Fix mismatched parameter names --- src/setup/permission.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/setup/permission.cpp b/src/setup/permission.cpp index dbf9e96..2b36fd1 100644 --- a/src/setup/permission.cpp +++ b/src/setup/permission.cpp @@ -25,9 +25,9 @@ namespace setup { -void permission_entry::load(std::istream & is, const version & v) { +void permission_entry::load(std::istream & is, const version & version) { - (void)v; + (void)version; is >> util::binary_string(permissions); // an array of TGrantPermissionEntry's From 3baf29196ac74a577619b2fabcb8f82cf7c8f609 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:49:16 +0200 Subject: [PATCH 32/51] [clang-tidy] version: Fix mismatched parameter names --- src/setup/version.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/setup/version.cpp b/src/setup/version.cpp index 86bfd77..1cec4df 100644 --- a/src/setup/version.cpp +++ b/src/setup/version.cpp @@ -157,19 +157,19 @@ const known_version versions[] = { } // anonymous namespace -std::ostream & operator<<(std::ostream & os, const version & v) { +std::ostream & operator<<(std::ostream & os, const version & version) { - os << v.a() << '.' << v.b() << '.' << v.c(); - if(v.d()) { - os << '.' << v.d(); + os << version.a() << '.' << version.b() << '.' << version.c(); + if(version.d()) { + os << '.' << version.d(); } - if(v.unicode) { + if(version.unicode) { os << " (unicode)"; } - if(v.bits != 32) { - os << " (" << int(v.bits) << "-bit)"; + if(version.bits != 32) { + os << " (" << int(version.bits) << "-bit)"; } return os; From 148135d4eb3f555e7f4a436c4ac9c01ed11e9d2c Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:50:39 +0200 Subject: [PATCH 33/51] [clang-tidy] windows: Fix mismatched parameter names --- src/setup/windows.cpp | 28 ++++++++++++++-------------- src/setup/windows.hpp | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/setup/windows.cpp b/src/setup/windows.cpp index ffaa06d..7e3c3a6 100644 --- a/src/setup/windows.cpp +++ b/src/setup/windows.cpp @@ -123,23 +123,23 @@ const char * get_version_name(const windows_version::data & version, bool nt = f } // anonymous namespace -std::ostream & operator<<(std::ostream & os, const windows_version::data & v) { - os << v.major << '.' << v.minor; - if(v.build) { - os << v.build; +std::ostream & operator<<(std::ostream & os, const windows_version::data & version) { + os << version.major << '.' << version.minor; + if(version.build) { + os << version.build; } return os; } -std::ostream & operator<<(std::ostream & os, const windows_version & v) { +std::ostream & operator<<(std::ostream & os, const windows_version & version) { - os << v.win_version; - if(v.nt_version != v.win_version) { - os << " nt " << v.nt_version; + os << version.win_version; + if(version.nt_version != version.win_version) { + os << " nt " << version.nt_version; } - const char * win_name = get_version_name(v.win_version); - const char * nt_name = get_version_name(v.nt_version, true); + const char * win_name = get_version_name(version.win_version); + const char * nt_name = get_version_name(version.nt_version, true); if(win_name || nt_name) { os << " ("; @@ -155,10 +155,10 @@ std::ostream & operator<<(std::ostream & os, const windows_version & v) { os << ')'; } - if(v.nt_service_pack.major || v.nt_service_pack.minor) { - os << " service pack " << v.nt_service_pack.major; - if(v.nt_service_pack.minor) { - os << '.' << v.nt_service_pack.minor; + if(version.nt_service_pack.major || version.nt_service_pack.minor) { + os << " service pack " << version.nt_service_pack.major; + if(version.nt_service_pack.minor) { + os << '.' << version.nt_service_pack.minor; } } diff --git a/src/setup/windows.hpp b/src/setup/windows.hpp index 481b8d6..edd7d18 100644 --- a/src/setup/windows.hpp +++ b/src/setup/windows.hpp @@ -97,8 +97,8 @@ struct windows_version_range { }; -std::ostream & operator<<(std::ostream & os, const windows_version::data & svd); -std::ostream & operator<<(std::ostream & os, const windows_version & svd); +std::ostream & operator<<(std::ostream & os, const windows_version::data & version); +std::ostream & operator<<(std::ostream & os, const windows_version & version); } // namespace setup From b6bc36eee7998bb2a058c97420869948cf8a6bd6 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:53:27 +0200 Subject: [PATCH 34/51] [clang-tidy] encoding: Fix mismatched parameter names --- src/util/encoding.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/util/encoding.cpp b/src/util/encoding.cpp index 0a6748b..904d4e2 100644 --- a/src/util/encoding.cpp +++ b/src/util/encoding.cpp @@ -176,12 +176,12 @@ size_t get_encoding_size(codepage_id codepage) { } //! Fallback conversion that will at least work for ASCII characters -void to_utf8_fallback(const std::string & from, std::string & to, codepage_id cp) { +void to_utf8_fallback(const std::string & from, std::string & to, codepage_id codepage) { - size_t skip = get_encoding_size(cp); + size_t skip = get_encoding_size(codepage); size_t shift = 0; - switch(cp) { + switch(codepage) { case 1201: shift = 1u * 8u; break; // UTF-16BE case 12001: shift = 3u * 8u; break; // UTF-32BE default: break; @@ -211,7 +211,7 @@ void to_utf8_fallback(const std::string & from, std::string & to, codepage_id cp } if(warn) { - log_warning << "Unknown data while converting from CP" << cp << " to UTF-8."; + log_warning << "Unknown data while converting from CP" << codepage << " to UTF-8."; } } @@ -524,9 +524,9 @@ iconv_t get_converter(codepage_id codepage) { return converters[codepage] = handle; } -bool to_utf8_iconv(const std::string & from, std::string & to, codepage_id cp) { +bool to_utf8_iconv(const std::string & from, std::string & to, codepage_id codepage) { - iconv_t converter = get_converter(cp); + iconv_t converter = get_converter(codepage); if(converter == iconv_t(-1)) { return false; } @@ -549,7 +549,7 @@ bool to_utf8_iconv(const std::string & from, std::string & to, codepage_id cp) { iconv(converter, NULL, NULL, NULL, NULL); - size_t skip = get_encoding_size(cp); + size_t skip = get_encoding_size(codepage); bool warn = false; @@ -586,7 +586,7 @@ bool to_utf8_iconv(const std::string & from, std::string & to, codepage_id cp) { } if(warn) { - log_warning << "Unexpected data while converting from CP" << cp << " to UTF-8."; + log_warning << "Unexpected data while converting from CP" << codepage << " to UTF-8."; } to.resize(outbase); @@ -615,7 +615,7 @@ std::string windows_error_string(DWORD code) { } } -bool to_utf8_win32(const std::string & from, std::string & to, codepage_id cp) { +bool to_utf8_win32(const std::string & from, std::string & to, codepage_id codepage) { int ret = 0; @@ -623,18 +623,18 @@ bool to_utf8_win32(const std::string & from, std::string & to, codepage_id cp) { const WCHAR * utf16; int utf16_size; std::vector buffer; - if(cp == cp_utf16le) { + if(codepage == cp_utf16le) { utf16 = reinterpret_cast(from.data()); utf16_size = int(from.size()) / 2; } else { - utf16_size = MultiByteToWideChar(cp, 0, from.data(), int(from.length()), NULL, 0); + utf16_size = MultiByteToWideChar(codepage, 0, from.data(), int(from.length()), NULL, 0); if(utf16_size > 0) { buffer.resize(size_t(utf16_size)); - ret = MultiByteToWideChar(cp, 0, from.data(), int(from.length()), + ret = MultiByteToWideChar(codepage, 0, from.data(), int(from.length()), &buffer.front(), utf16_size); } if(utf16_size <= 0 || ret <= 0) { - log_warning << "Error while converting from CP" << cp << " to UTF-16: " + log_warning << "Error while converting from CP" << codepage << " to UTF-16: " << windows_error_string(GetLastError()); return false; } @@ -661,19 +661,19 @@ bool to_utf8_win32(const std::string & from, std::string & to, codepage_id cp) { } // anonymous namespace -void to_utf8(const std::string & from, std::string & to, codepage_id cp) { +void to_utf8(const std::string & from, std::string & to, codepage_id codepage) { if(from.empty()) { to.clear(); return; } - if(cp == cp_utf8 || cp == cp_ascii) { + if(codepage == cp_utf8 || codepage == cp_ascii) { to = from; return; } - switch(cp) { + switch(codepage) { case cp_utf16le: utf16le_to_utf8(from, to); return; case cp_windows1252: windows1252_to_utf8(from, to); return; case cp_iso_8859_1: windows1252_to_utf8(from, to); return; @@ -681,18 +681,18 @@ void to_utf8(const std::string & from, std::string & to, codepage_id cp) { } #if INNOEXTRACT_HAVE_ICONV - if(to_utf8_iconv(from, to, cp)) { + if(to_utf8_iconv(from, to, codepage)) { return; } #endif #if INNOEXTRACT_HAVE_WIN32_CONV - if(to_utf8_win32(from, to, cp)) { + if(to_utf8_win32(from, to, codepage)) { return; } #endif - to_utf8_fallback(from, to, cp); + to_utf8_fallback(from, to, codepage); } From 9fb04d4b67a96fdd01e341337429cbe33682ba7b Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:54:55 +0200 Subject: [PATCH 35/51] [clang-tidy] time: Fix mismatched parameter names --- src/util/time.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/time.cpp b/src/util/time.cpp index 0bdfc15..9ec6444 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -258,7 +258,7 @@ extern "C" typedef int (*utimensat_proc) (int fd, const char *path, const struct timespec times[2], int flag); #endif -bool set_file_time(const boost::filesystem::path & path, time t, boost::uint32_t nsec) { +bool set_file_time(const boost::filesystem::path & path, time sec, boost::uint32_t nsec) { #if (INNOEXTRACT_HAVE_DYNAMIC_UTIMENSAT || INNOEXTRACT_HAVE_UTIMENSAT) \ && INNOEXTRACT_HAVE_AT_FDCWD @@ -266,7 +266,7 @@ bool set_file_time(const boost::filesystem::path & path, time t, boost::uint32_t // nanosecond precision, for Linux and POSIX.1-2008+ systems struct timespec timens[2]; - timens[0].tv_sec = to_time_t(t, path.string().c_str()); + timens[0].tv_sec = to_time_t(sec, path.string().c_str()); timens[0].tv_nsec = boost::int32_t(nsec); timens[1] = timens[0]; @@ -298,7 +298,7 @@ bool set_file_time(const boost::filesystem::path & path, time t, boost::uint32_t return false; } - FILETIME filetime = to_filetime(t, nsec); + FILETIME filetime = to_filetime(sec, nsec); bool ret = (SetFileTime(handle, &filetime, &filetime, &filetime) != 0); CloseHandle(handle); @@ -310,7 +310,7 @@ bool set_file_time(const boost::filesystem::path & path, time t, boost::uint32_t // microsecond precision, for older POSIX systems (4.3BSD, POSIX.1-2001) struct timeval times[2]; - times[0].tv_sec = to_time_t(t, path.string().c_str()); + times[0].tv_sec = to_time_t(sec, path.string().c_str()); times[0].tv_usec = boost::int32_t(nsec / 1000); times[1] = times[0]; @@ -322,7 +322,7 @@ bool set_file_time(const boost::filesystem::path & path, time t, boost::uint32_t try { (void)nsec; // sub-second precision not supported by Boost - std::time_t tt = to_time_t(t, path.string().c_str()); + std::time_t tt = to_time_t(sec, path.string().c_str()); boost::filesystem::last_write_time(path, tt); return true; } catch(...) { From 89c8fe06180c2ef02fbcb35703ec0aab7a206a54 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 10:57:50 +0200 Subject: [PATCH 36/51] [clang-tidy] encoding: Add missing braces --- src/util/encoding.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/util/encoding.cpp b/src/util/encoding.cpp index 904d4e2..0b27407 100644 --- a/src/util/encoding.cpp +++ b/src/util/encoding.cpp @@ -271,10 +271,15 @@ unicode_char utf8_read(In & it, In end, unicode_char replacement = replacement_c } size_t utf8_length(unicode_char chr) { - if (chr < 0x80) return 1; - else if(chr < 0x800) return 2; - else if(chr < 0x10000) return 3; - else if(chr <= 0x0010ffff) return 4; + if(chr < 0x80) { + return 1; + } else if(chr < 0x800) { + return 2; + } else if(chr < 0x10000) { + return 3; + } else if(chr <= 0x0010ffff) { + return 4; + } return 1; } From d177bbc9a64c72933052c9a28ed2c6cb63747bb9 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 11:01:52 +0200 Subject: [PATCH 37/51] [clang-tidy] flags: Remove explicit copy constructor --- src/util/flags.hpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/util/flags.hpp b/src/util/flags.hpp index 00d3578..137b668 100644 --- a/src/util/flags.hpp +++ b/src/util/flags.hpp @@ -65,8 +65,6 @@ public: /* implicit */ inline flags(Zero /* zero */ = 0) : _flags() { } - flags(const flags & o) : _flags(o._flags) { } - static flags load(Type _flags) { return flags(_flags, true); } @@ -144,11 +142,6 @@ public: return operator^=(flag); } - flags & operator=(flags o) { - _flags = o._flags; - return *this; - } - //! Get a set of flags with all possible values set. static flags all() { return flags(Type().flip()); From ea06fb0498f44c4fe0e813630c0cd06f1da08dd7 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 11:03:16 +0200 Subject: [PATCH 38/51] [clang-tidy] block: Pass string by reference --- src/stream/block.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stream/block.hpp b/src/stream/block.hpp index 36f2755..c97f0d4 100644 --- a/src/stream/block.hpp +++ b/src/stream/block.hpp @@ -41,7 +41,7 @@ namespace stream { //! Error thrown by \ref chunk_reader::get or the returned stream if there was a problem. struct block_error : public std::ios_base::failure { - explicit block_error(std::string msg) : std::ios_base::failure(msg) { } + explicit block_error(const std::string & msg) : std::ios_base::failure(msg) { } }; From 9a26922093616ce55de2d830f64d22f6b6eaf60b Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 11:04:06 +0200 Subject: [PATCH 39/51] [clang-tidy] lzma: Pass string by reference --- src/stream/lzma.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stream/lzma.hpp b/src/stream/lzma.hpp index dd207af..c72dbd9 100644 --- a/src/stream/lzma.hpp +++ b/src/stream/lzma.hpp @@ -41,7 +41,7 @@ namespace stream { //! Error thrown if there was en error in an LZMA stream struct lzma_error : public std::ios_base::failure { - lzma_error(std::string msg, int code) + lzma_error(const std::string & msg, int code) : std::ios_base::failure(msg), error_code(code) { } //! \return the liblzma code for the error. From 458c11355af215ba391b374ad930db19ba43a35c Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 11:04:44 +0200 Subject: [PATCH 40/51] [clang-tidy] slice: Pass string by reference --- src/stream/slice.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stream/slice.hpp b/src/stream/slice.hpp index 4ba9c88..89728e8 100644 --- a/src/stream/slice.hpp +++ b/src/stream/slice.hpp @@ -39,7 +39,7 @@ namespace stream { //! Error thrown by \ref slice_reader if there was a problem. struct slice_error : public std::ios_base::failure { - explicit slice_error(std::string msg) : std::ios_base::failure(msg) { } + explicit slice_error(const std::string & msg) : std::ios_base::failure(msg) { } }; From d2005847eb3f79bde660ee00fa5dc572c482fe93 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 11:10:36 +0200 Subject: [PATCH 41/51] [clang-tidy] gog: Avoid unnecessary copy initialization --- src/cli/gog.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/cli/gog.cpp b/src/cli/gog.cpp index 386ca22..2f964d1 100644 --- a/src/cli/gog.cpp +++ b/src/cli/gog.cpp @@ -102,8 +102,7 @@ void quit_handler(int /* ignored */) { quit_requested = 1; } -bool process_file_unrar(const fs::path & file, const extract_options & o, - const std::string & password) { +bool process_file_unrar(const std::string & file, const extract_options & o, const std::string & password) { std::vector args; args.push_back("unrar"); @@ -151,8 +150,7 @@ bool process_file_unrar(const fs::path & file, const extract_options & o, args.push_back("--"); - std::string filename = file.string(); - args.push_back(filename.c_str()); + args.push_back(file.c_str()); std::string dir = o.output_dir.string(); if(!dir.empty()) { @@ -178,15 +176,13 @@ bool process_file_unrar(const fs::path & file, const extract_options & o, } if(ret > 0) { - throw std::runtime_error("Could not " + get_verb(o) + " \"" + file.string() - + "\": unrar failed"); + throw std::runtime_error("Could not " + get_verb(o) + " \"" + file + "\": unrar failed"); } return true; } -bool process_file_unar(const fs::path & file, const extract_options & o, - const std::string & password) { +bool process_file_unar(const std::string & file, const extract_options & o, const std::string & password) { std::string dir = o.output_dir.string(); @@ -222,8 +218,7 @@ bool process_file_unar(const fs::path & file, const extract_options & o, args.push_back("--"); - std::string filename = file.string(); - args.push_back(filename.c_str()); + args.push_back(file.c_str()); args.push_back(NULL); @@ -233,14 +228,13 @@ bool process_file_unar(const fs::path & file, const extract_options & o, } if(ret > 0) { - throw std::runtime_error("Could not " + get_verb(o) + " \"" + file.string() - + "\": unar failed"); + throw std::runtime_error("Could not " + get_verb(o) + " \"" + file + "\": unar failed"); } return true; } -bool process_rar_file(const fs::path & file, const extract_options & o, const std::string & password) { +bool process_rar_file(const std::string & file, const extract_options & o, const std::string & password) { return process_file_unrar(file, o, password) || process_file_unar(file, o, password); } @@ -316,7 +310,7 @@ void process_rar_files(const std::vector & files, bool ok = true; BOOST_FOREACH(const fs::path & file, files) { - if(!process_rar_file(file, o, password)) { + if(!process_rar_file(file.string(), o, password)) { ok = false; } } @@ -382,7 +376,7 @@ void process_rar_files(const std::vector & files, + "\": unable to create .r?? symlinks"); } - if(process_rar_file(first_file, o, password)) { + if(process_rar_file(first_file.string(), o, password)) { return; } From a4db6b048ccb1e210438837fd1938eccbbd623c0 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 11:15:45 +0200 Subject: [PATCH 42/51] [clang-tidy] gog: Make temporary_directory noncopyable --- src/cli/gog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cli/gog.cpp b/src/cli/gog.cpp index 2f964d1..0c8798b 100644 --- a/src/cli/gog.cpp +++ b/src/cli/gog.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -246,7 +247,7 @@ char hex_char(int c) { } } -class temporary_directory { +class temporary_directory : private boost::noncopyable { fs::path path; From fcaad8ac4181ee589fbb3ca759b68e495afae265 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 11:20:42 +0200 Subject: [PATCH 43/51] [clang-tidy] hasher: Remove explicit copy constructor --- src/crypto/hasher.cpp | 15 ++------------- src/crypto/hasher.hpp | 1 - 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/crypto/hasher.cpp b/src/crypto/hasher.cpp index 16882c9..12ec403 100644 --- a/src/crypto/hasher.cpp +++ b/src/crypto/hasher.cpp @@ -22,19 +22,6 @@ namespace crypto { -hasher::hasher(const hasher & o) { - - type = o.type; - - switch(type) { - case crypto::None: break; - case crypto::Adler32: adler32 = o.adler32; break; - case crypto::CRC32: crc32 = o.crc32; break; - case crypto::MD5: md5 = o.md5; break; - case crypto::SHA1: sha1 = o.sha1; break; - }; -} - hasher::hasher(checksum_type type) : type(type) { switch(type) { @@ -44,6 +31,7 @@ hasher::hasher(checksum_type type) : type(type) { case crypto::MD5: md5.init(); break; case crypto::SHA1: sha1.init(); break; }; + } void hasher::update(const char * data, size_t size) { @@ -55,6 +43,7 @@ void hasher::update(const char * data, size_t size) { case crypto::MD5: md5.update(data, size); break; case crypto::SHA1: sha1.update(data, size); break; }; + } checksum hasher::finalize() { diff --git a/src/crypto/hasher.hpp b/src/crypto/hasher.hpp index 00290b6..7431d15 100644 --- a/src/crypto/hasher.hpp +++ b/src/crypto/hasher.hpp @@ -42,7 +42,6 @@ class hasher : checksum_base { public: explicit hasher(checksum_type type); - hasher(const hasher & o); void update(const char * data, size_t size); From 521eaf26718e8e6565f22e0aa8159e8a817375f7 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 11:25:39 +0200 Subject: [PATCH 44/51] [clang-tidy] checksum: Remove explicit copy constructor --- src/stream/checksum.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/stream/checksum.hpp b/src/stream/checksum.hpp index dced20f..96184a8 100644 --- a/src/stream/checksum.hpp +++ b/src/stream/checksum.hpp @@ -59,7 +59,6 @@ public: : hasher(type) , output(output) { } - checksum_filter(const checksum_filter & o) : hasher(o.hasher), output(o.output) { } template std::streamsize read(Source & src, char * dest, std::streamsize n) { From 52e11339b1e0b1f35d03a85e58f68d0d39a61fad Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 11:31:58 +0200 Subject: [PATCH 45/51] [clang-tidy] console: Remove explicit copy constructor --- src/util/console.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/util/console.hpp b/src/util/console.hpp index c405fd9..131c401 100644 --- a/src/util/console.hpp +++ b/src/util/console.hpp @@ -118,10 +118,6 @@ public: * \param show_rate Display the rate at which the progress changes. */ progress(boost::uint64_t max = 0, bool show_rate = true); - progress(const progress & o) - : max(o.max), value(o.value), show_rate(o.show_rate), start_time(o.start_time), - last_status(o.last_status), last_time(o.last_time), - last_rate(o.last_rate), label(o.label.str()) { } /*! * Update the progress bar. From 7e597e5bcb8515dd57cb982f7c4b30b4519e785e Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 11:35:38 +0200 Subject: [PATCH 46/51] [clang-tidy] log: Make logger noncopyable --- src/util/log.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/log.hpp b/src/util/log.hpp index e74a63d..075d461 100644 --- a/src/util/log.hpp +++ b/src/util/log.hpp @@ -29,6 +29,8 @@ #include #include +#include + #ifdef DEBUG #define debug(...) \ if(::logger::debug) \ @@ -46,7 +48,7 @@ /*! * logger class that allows longging via the stream operator. */ -class logger { +class logger : private boost::noncopyable { public: From f5e42c63065e6a7c39d2e817bc71df02a2fa9d52 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 11:42:41 +0200 Subject: [PATCH 47/51] [clang-tidy] gog: Replace C-style casts --- src/cli/gog.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cli/gog.cpp b/src/cli/gog.cpp index 0c8798b..5061a5e 100644 --- a/src/cli/gog.cpp +++ b/src/cli/gog.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -300,8 +301,8 @@ void process_rar_files(const std::vector & files, md5.finalize(hash); password.resize(size_t(boost::size(hash) * 2)); for(size_t i = 0; i < size_t(boost::size(hash)); i++) { - password[2 * i + 0] = hex_char(((unsigned char)hash[i]) / 16); - password[2 * i + 1] = hex_char(((unsigned char)hash[i]) % 16); + password[2 * i + 0] = hex_char(boost::uint8_t(hash[i]) / 16); + password[2 * i + 1] = hex_char(boost::uint8_t(hash[i]) % 16); } } From 0ab0c36baecf8a8ccae84c962782034589a2ca63 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 11:45:02 +0200 Subject: [PATCH 48/51] [clang-tidy] output: Replace C-style casts --- src/util/output.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/output.hpp b/src/util/output.hpp index b1820e2..2e8d56d 100644 --- a/src/util/output.hpp +++ b/src/util/output.hpp @@ -46,7 +46,7 @@ inline std::ostream & operator<<(std::ostream & os, const quoted & q) { color::shell_command prev = color::current; os << '"' << color::green; for(std::string::const_iterator i = q.str.begin(); i != q.str.end(); ++i) { - unsigned char c = (unsigned char)*i; + boost::uint8_t c = boost::uint8_t(*i); if(c < ' ' && c != '\t' && c != '\r' && c != '\n') { std::ios_base::fmtflags old = os.flags(); os << color::red << '<' << std::hex << std::setfill('0') << std::setw(2) From 57afa7962f701dff47820bb8480b270450faff5d Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 11:51:42 +0200 Subject: [PATCH 49/51] [coverity] storedenum: Initialize buffer --- src/util/storedenum.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/storedenum.hpp b/src/util/storedenum.hpp index eb2b00b..7a6fbd8 100644 --- a/src/util/storedenum.hpp +++ b/src/util/storedenum.hpp @@ -219,7 +219,7 @@ private: public: explicit stored_flag_reader(std::istream & _is, size_t pad_bits = 32) - : pad_bits(pad_bits), is(_is), pos(0), result(0), bytes(0) { } + : pad_bits(pad_bits), is(_is), pos(0), buffer(0), result(0), bytes(0) { } //! Declare the next possible flag. void add(enum_type flag) { From 158453f1f3a63436e1e30f55687c0c4e28da3067 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 11:56:21 +0200 Subject: [PATCH 50/51] [coverity] exefilter: Initialize addr --- src/stream/exefilter.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stream/exefilter.hpp b/src/stream/exefilter.hpp index 7ea1c53..aede2f6 100644 --- a/src/stream/exefilter.hpp +++ b/src/stream/exefilter.hpp @@ -64,7 +64,7 @@ public: template void close(const Source & /* source */) { - addr_bytes_left = 0, addr_offset = 5; + addr = 0, addr_bytes_left = 0, addr_offset = 5; } private: From 0e37f3550c0c2ff9082b09a3ae1689b63308f954 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Mon, 11 Jun 2018 12:06:02 +0200 Subject: [PATCH 51/51] [coverity] extract: Remove dead code --- src/cli/extract.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cli/extract.cpp b/src/cli/extract.cpp index a0959bb..0c4e901 100644 --- a/src/cli/extract.cpp +++ b/src/cli/extract.cpp @@ -288,7 +288,7 @@ void print_filter_info(const setup::item & item, bool temp) { bool first = true; if(!item.languages.empty()) { - std::cout << (first ? " [" : ", "); + std::cout << " ["; first = false; std::cout << color::green << item.languages << color::reset; } @@ -303,6 +303,7 @@ void print_filter_info(const setup::item & item, bool temp) { if(!first) { std::cout << "]"; } + } void print_filter_info(const setup::file_entry & file) {