diff --git a/app/exiv2.cpp b/app/exiv2.cpp index bc01364e..01f6c1c8 100644 --- a/app/exiv2.cpp +++ b/app/exiv2.cpp @@ -160,7 +160,6 @@ int main(int argc, char* const argv[]) assert(task); // Process all files - int n = 1; int s = static_cast(params.files_.size()); if (params.action_ & Action::extract && params.target_ & Params::ctStdInOut && s > 1) { std::cerr << params.progname() << ": " << _("Only one file is allowed when extracting to stdout") << std::endl; @@ -168,6 +167,7 @@ int main(int argc, char* const argv[]) } else { int w = s > 9 ? s > 99 ? 3 : 2 : 1; + int n = 1; for (auto&& file : params.files_) { // If extracting to stdout then ignore verbose if (params.verbose_ && !(params.action_ & Action::extract && params.target_ & Params::ctStdInOut)) { diff --git a/src/crwimage_int.cpp b/src/crwimage_int.cpp index d1e33647..230d4ef1 100644 --- a/src/crwimage_int.cpp +++ b/src/crwimage_int.cpp @@ -605,10 +605,10 @@ namespace Exiv2 { CiffComponent* CiffDirectory::doFindComponent(uint16_t crwTagId, uint16_t crwDir) const { - CiffComponent* cc; for (auto&& component : components_) { - cc = component->findComponent(crwTagId, crwDir); - if (cc) return cc; + auto cc = component->findComponent(crwTagId, crwDir); + if (cc) + return cc; } return nullptr; } // CiffDirectory::doFindComponent diff --git a/src/futils.cpp b/src/futils.cpp index 8e28184b..ef0312f1 100644 --- a/src/futils.cpp +++ b/src/futils.cpp @@ -152,7 +152,6 @@ namespace Exiv2 { int base64encode(const void* data_buf, size_t dataLength, char* result, size_t resultSize) { auto encoding_table = base64_encode; - size_t mod_table[] = {0, 2, 1}; size_t output_length = 4 * ((dataLength + 2) / 3); int rc = result && data_buf && output_length < resultSize ? 1 : 0; @@ -172,6 +171,7 @@ namespace Exiv2 { result[j++] = encoding_table[(triple >> 0 * 6) & 0x3F]; } + const size_t mod_table[] = {0, 2, 1}; for (size_t i = 0; i < mod_table[dataLength % 3]; i++) result[output_length - 1 - i] = '='; result[output_length]=0; diff --git a/src/pngimage.cpp b/src/pngimage.cpp index 4d25d21c..2e264d39 100644 --- a/src/pngimage.cpp +++ b/src/pngimage.cpp @@ -150,11 +150,11 @@ namespace Exiv2 { static bool tEXtToDataBuf(const byte* bytes,long length,DataBuf& result) { - static const char* hexdigits = "0123456789ABCDEF"; static std::array value; static bool bFirst = true; if ( bFirst ) { value.fill(0); + const char* hexdigits = "0123456789ABCDEF"; for ( int i = 0 ; i < 16 ; i++ ) { value[tolower(hexdigits[i])]=i+1; value[toupper(hexdigits[i])]=i+1; diff --git a/src/value.cpp b/src/value.cpp index d99c0e9f..5bc3687f 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -804,7 +804,6 @@ namespace Exiv2 { std::string lang = "x-default"; if (buf.length() > 5 && buf.substr(0, 5) == "lang=") { static const char* ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - static const char* ALPHA_NUM = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; const std::string::size_type pos = buf.find_first_of(' '); if (pos == std::string::npos) { @@ -829,6 +828,7 @@ namespace Exiv2 { // Check language is in the correct format (see https://www.ietf.org/rfc/rfc3066.txt) std::string::size_type charPos = lang.find_first_not_of(ALPHA); if (charPos != std::string::npos) { + static const char* ALPHA_NUM = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; if (lang.at(charPos) != '-' || lang.find_first_not_of(ALPHA_NUM, charPos+1) != std::string::npos) throw Error(kerInvalidLangAltValue, buf); }