diff --git a/app/app_utils.hpp b/app/app_utils.hpp index 731a71af..2731f52d 100644 --- a/app/app_utils.hpp +++ b/app/app_utils.hpp @@ -14,4 +14,4 @@ namespace Util { bool strtol(const char* nptr, int64_t& n); } // namespace Util -#endif // #ifndef UTILS_HPP_ +#endif // APP_UTILS_HPP_ diff --git a/app/exiv2.cpp b/app/exiv2.cpp index 473aa940..1e95b347 100644 --- a/app/exiv2.cpp +++ b/app/exiv2.cpp @@ -149,7 +149,14 @@ int main(int argc, char* const argv[]) { std::cerr << params.progname() << ": " << _("Only one file is allowed when extracting to stdout") << std::endl; returnCode = EXIT_FAILURE; } else { - int w = filesCount > 9 ? filesCount > 99 ? 3 : 2 : 1; + int w = [=]() { + if (filesCount > 9) { + if (filesCount > 99) + return 3; + return 2; + } + return 1; + }(); int n = 1; for (const auto& file : params.files_) { // If extracting to stdout then ignore verbose @@ -1038,19 +1045,15 @@ int Params::getopt(int argc, char* const Argv[]) { std::cerr << progname() << ": " << _("At least one file is required\n"); rc = 1; } - if (rc == 0 && !cmdFiles_.empty()) { - // Parse command files - if (!parseCmdFiles(modifyCmds_, cmdFiles_)) { - std::cerr << progname() << ": " << _("Error parsing -m option arguments\n"); - rc = 1; - } + // Parse command files + if (rc == 0 && !cmdFiles_.empty() && !parseCmdFiles(modifyCmds_, cmdFiles_)) { + std::cerr << progname() << ": " << _("Error parsing -m option arguments\n"); + rc = 1; } - if (rc == 0 && !cmdLines_.empty()) { - // Parse command lines - if (!parseCmdLines(modifyCmds_, cmdLines_)) { - std::cerr << progname() << ": " << _("Error parsing -M option arguments\n"); - rc = 1; - } + // Parse command lines + if (rc == 0 && !cmdLines_.empty() && !parseCmdLines(modifyCmds_, cmdLines_)) { + std::cerr << progname() << ": " << _("Error parsing -M option arguments\n"); + rc = 1; } if (rc == 0 && (!cmdFiles_.empty() || !cmdLines_.empty())) { // We'll set them again, after reading the file @@ -1060,15 +1063,15 @@ int Params::getopt(int argc, char* const Argv[]) { std::cerr << progname() << ": " << _("-l option can only be used with extract or insert actions\n"); rc = 1; } - if (!suffix_.empty() && !(action_ == Action::insert)) { + if (!suffix_.empty() && action_ != Action::insert) { std::cerr << progname() << ": " << _("-S option can only be used with insert action\n"); rc = 1; } - if (timestamp_ && !(action_ == Action::rename)) { + if (timestamp_ && action_ != Action::rename) { std::cerr << progname() << ": " << _("-t option can only be used with rename action\n"); rc = 1; } - if (timestampOnly_ && !(action_ == Action::rename)) { + if (timestampOnly_ && action_ != Action::rename) { std::cerr << progname() << ": " << _("-T option can only be used with rename action\n"); rc = 1; } diff --git a/app/getopt.cpp b/app/getopt.cpp index 6081657c..935fd77d 100644 --- a/app/getopt.cpp +++ b/app/getopt.cpp @@ -83,7 +83,7 @@ int Getopt::getopt(int argc, char* const argv[], const std::string& optstring) { progname_ = fs::path(argv[0]).filename().string(); Util::optind = 0; // reset the Util::Getopt scanner - for (; !errcnt_;) { + while (!errcnt_) { int c = Util::getopt(argc, argv, optstring.c_str()); if (c == -1) { break; diff --git a/include/exiv2/bmffimage.hpp b/include/exiv2/bmffimage.hpp index 8907bd82..9f4e2c33 100644 --- a/include/exiv2/bmffimage.hpp +++ b/include/exiv2/bmffimage.hpp @@ -141,7 +141,7 @@ class EXIV2API BmffImage : public Image { std::string boxName(uint32_t box); static bool superBox(uint32_t box); static bool fullBox(uint32_t box); - static std::string uuidName(Exiv2::DataBuf& uuid); + static std::string uuidName(const Exiv2::DataBuf& uuid); }; // class BmffImage diff --git a/src/bmffimage.cpp b/src/bmffimage.cpp index 258f750e..674f559f 100644 --- a/src/bmffimage.cpp +++ b/src/bmffimage.cpp @@ -79,9 +79,13 @@ std::string BmffImage::toAscii(uint32_t n) { std::string result; for (int i = 0; i < 4; i++) { char c = p[isBigEndianPlatform() ? i : (3 - i)]; - result += (32 <= c && c < 127) ? c // only allow 7-bit printable ascii - : c == 0 ? '_' // show 0 as _ - : '.'; // others . + result += [c]() { + if (32 <= c && c < 127) + return c; // only allow 7-bit printable ascii + if (c == 0) + return '_'; // show 0 as _ + return '.'; // others . + }(); } return result; } @@ -141,7 +145,7 @@ uint32_t BmffImage::pixelHeight() const { return pixelHeight_; } -std::string BmffImage::uuidName(Exiv2::DataBuf& uuid) { +std::string BmffImage::uuidName(const Exiv2::DataBuf& uuid) { const char* uuidCano = "\x85\xC0\xB6\x87\x82\xF\x11\xE0\x81\x11\xF4\xCE\x46\x2B\x6A\x48"; const char* uuidXmp = "\xBE\x7A\xCF\xCB\x97\xA9\x42\xE8\x9C\x71\x99\x94\x91\xE3\xAF\xAC"; const char* uuidCanp = "\xEA\xF4\x2B\x5E\x1C\x98\x4B\x88\xB9\xFB\xB7\xDC\x40\x6E\x4D\x16"; diff --git a/src/canonmn_int.hpp b/src/canonmn_int.hpp index cb8b3eba..646837a8 100644 --- a/src/canonmn_int.hpp +++ b/src/canonmn_int.hpp @@ -12,8 +12,8 @@ 07-Mar-04, ahu: isolated as a separate component
12-Aug-06, dc: started updating all tags */ -#ifndef CANONMN_INT_HPP_ -#define CANONMN_INT_HPP_ +#ifndef EXIV2_CANONMN_INT_HPP +#define EXIV2_CANONMN_INT_HPP // ***************************************************************************** // included header files @@ -201,4 +201,4 @@ float canonEv(int64_t val); } // namespace Exiv2::Internal -#endif // #ifndef CANONMN_INT_HPP_ +#endif // EXIV2_CANONMN_INT_HPP diff --git a/src/casiomn_int.hpp b/src/casiomn_int.hpp index 01eabc74..5331b9e8 100644 --- a/src/casiomn_int.hpp +++ b/src/casiomn_int.hpp @@ -9,8 +9,8 @@ Specification by Evan Hunter. @date 30-Oct-13, ahu: created */ -#ifndef CASIOMN_INT_HPP_ -#define CASIOMN_INT_HPP_ +#ifndef EXIV2_CASIOMN_INT_HPP +#define EXIV2_CASIOMN_INT_HPP // ***************************************************************************** // included header files @@ -57,4 +57,4 @@ class Casio2MakerNote { } // namespace Exiv2::Internal -#endif // #ifndef CasioMN_INT_HPP_ +#endif // EXIV2_CASIOMN_INT_HPP diff --git a/src/convert.cpp b/src/convert.cpp index 4c1c34cc..e0a1ee63 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -1276,7 +1276,7 @@ std::string Converter::computeExifDigest(bool tiff) { MD5Final(digest, &context); res << ';'; res << std::setw(2) << std::setfill('0') << std::hex << std::uppercase; - for (auto&& i : digest) { + for (const auto& i : digest) { res << static_cast(i); } return res.str(); diff --git a/src/cr2header_int.hpp b/src/cr2header_int.hpp index e617e5e9..802ba82c 100644 --- a/src/cr2header_int.hpp +++ b/src/cr2header_int.hpp @@ -7,8 +7,8 @@ ahuggel@gmx.net @date 23-Apr-08, ahu: created */ -#ifndef CR2IMAGE_INT_HPP_ -#define CR2IMAGE_INT_HPP_ +#ifndef EXIV2_CR2HEADER_INT_HPP +#define EXIV2_CR2HEADER_INT_HPP // ***************************************************************************** // included header files @@ -55,4 +55,4 @@ class Cr2Header : public TiffHeaderBase { } // namespace Exiv2::Internal -#endif // #ifndef CR2IMAGE_INT_HPP_ +#endif // EXIV2_CR2HEADER_INT_HPP diff --git a/src/crwimage_int.hpp b/src/crwimage_int.hpp index bcaa5eda..4caaf85a 100644 --- a/src/crwimage_int.hpp +++ b/src/crwimage_int.hpp @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later -#ifndef CRWIMAGE_INT_HPP_ -#define CRWIMAGE_INT_HPP_ +#ifndef EXIV2_CRWIMAGE_INT_HPP +#define EXIV2_CRWIMAGE_INT_HPP // ***************************************************************************** // included header files @@ -656,4 +656,4 @@ DataBuf packIfdId(const ExifData& exifData, IfdId ifdId, ByteOrder byteOrder); } // namespace Exiv2::Internal -#endif // #ifndef CRWIMAGE_INT_HPP_ +#endif // EXIV2_CRWIMAGE_INT_HPP diff --git a/src/epsimage.cpp b/src/epsimage.cpp index 2a74336e..a88d2c72 100644 --- a/src/epsimage.cpp +++ b/src/epsimage.cpp @@ -828,7 +828,7 @@ void readWriteEpsMetadata(BasicIo& io, std::string& xmpPacket, NativePreviewList if (useFlexibleEmbedding) { positions.push_back(xmpPos); } - for (auto&& [r, s] : removableEmbeddings) { + for (const auto& [r, s] : removableEmbeddings) { positions.push_back(r); } std::sort(positions.begin(), positions.end()); @@ -842,7 +842,7 @@ void readWriteEpsMetadata(BasicIo& io, std::string& xmpPacket, NativePreviewList const uint32_t posEpsNew = posTemp(tempIo); size_t prevPos = posEps; size_t prevSkipPos = prevPos; - for (auto&& pos : positions) { + for (const auto& pos : positions) { if (pos == prevPos) continue; #ifdef DEBUG @@ -937,7 +937,7 @@ void readWriteEpsMetadata(BasicIo& io, std::string& xmpPacket, NativePreviewList } if (!useFlexibleEmbedding) { // remove preceding embedding(s) - for (auto&& [p, s] : removableEmbeddings) { + for (const auto& [p, s] : removableEmbeddings) { if (pos == p) { skipPos = s; #ifdef DEBUG diff --git a/src/futils.cpp b/src/futils.cpp index 83d5e957..720c1790 100644 --- a/src/futils.cpp +++ b/src/futils.cpp @@ -201,7 +201,7 @@ Protocol fileProtocol(const std::string& path) { } prots[] = {{"http://", pHttp, true}, {"https://", pHttps, true}, {"ftp://", pFtp, true}, {"sftp://", pSftp, true}, {"file://", pFileUri, true}, {"data://", pDataUri, true}, {"-", pStdin, false}}; - for (auto&& prot : prots) { + for (const auto& prot : prots) { if (result != pFile) break; diff --git a/src/http.cpp b/src/http.cpp index 21f535ea..1a954f33 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -177,7 +177,7 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st const char* NO_PROXY = getenv(NO_PROXI); const char* no_proxy = getenv(no_proxi); bool bNoProxy = NO_PROXY || no_proxy; - std::string no_prox = std::string(bNoProxy ? (no_proxy ? no_proxy : NO_PROXY) : ""); + auto no_prox = std::string(bNoProxy ? (no_proxy ? no_proxy : NO_PROXY) : ""); Exiv2::Dictionary noProxy = stringToDict(no_prox + ",localhost,127.0.0.1"); // if the server is on the no_proxy list ... ignore the proxy! @@ -214,7 +214,7 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st // convert unknown servername into IP address // http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/rzab6/rzab6uafinet.htm if (serv_addr.sin_addr.s_addr == static_cast(INADDR_NONE)) { - struct hostent* host = gethostbyname(servername_p); + auto host = gethostbyname(servername_p); if (!host) return error(errors, "no such host", servername_p); memcpy(&serv_addr.sin_addr, host->h_addr, sizeof(serv_addr.sin_addr)); @@ -300,7 +300,7 @@ int Exiv2::http(Exiv2::Dictionary& request, Exiv2::Dictionary& response, std::st break; } result = atoi(firstSpace); - char* c = strchr(h, C); + auto c = strchr(h, C); char* first_newline = strchr(h, N); while (c && first_newline && c < first_newline && h < buffer + body) { std::string key(h); diff --git a/src/makernote_int.hpp b/src/makernote_int.hpp index 0d582d17..158725c9 100644 --- a/src/makernote_int.hpp +++ b/src/makernote_int.hpp @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later -#ifndef MAKERNOTE_INT_HPP_ -#define MAKERNOTE_INT_HPP_ +#ifndef EXIV2_MAKERNOTE_INT_HPP +#define EXIV2_MAKERNOTE_INT_HPP // ***************************************************************************** // included header files @@ -700,4 +700,4 @@ DataBuf nikonCrypt(uint16_t tag, const byte* pData, size_t size, TiffComponent* } // namespace Exiv2::Internal -#endif // #ifndef MAKERNOTE_INT_HPP_ +#endif // EXIV2_MAKERNOTE_INT_HPP