From 024e026bbb6c1fccbbf548251751f1d1b1aefc57 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 20 Mar 2023 19:58:50 -0700 Subject: [PATCH] clang: small fixes Signed-off-by: Rosen Penev --- app/actions.cpp | 3 +- app/exiv2.cpp | 18 +++++---- samples/easyaccess-test.cpp | 74 +++++++++++++++++++------------------ src/tiffcomposite_int.cpp | 1 - src/tiffcomposite_int.hpp | 4 +- src/tiffvisitor_int.cpp | 4 ++ src/types.cpp | 8 +++- 7 files changed, 62 insertions(+), 50 deletions(-) diff --git a/app/actions.cpp b/app/actions.cpp index 70e570f3..8192b42e 100644 --- a/app/actions.cpp +++ b/app/actions.cpp @@ -89,7 +89,7 @@ std::string tm2Str(const tm* tm); @brief Copy metadata from source to target according to Params::copyXyz @param source Source file path - @param target Target file path. An *.exv file is created if target doesn't + @param tgt Target file path. An *.exv file is created if target doesn't exist. @param targetType Image type for the target image in case it needs to be created. @@ -1881,7 +1881,6 @@ int renameFile(std::string& newPath, const tm* tm) { break; default: // skip return -1; - break; } } } else { diff --git a/app/exiv2.cpp b/app/exiv2.cpp index 310b4dd8..a1f14666 100644 --- a/app/exiv2.cpp +++ b/app/exiv2.cpp @@ -124,8 +124,12 @@ int main(int argc, char* const argv[]) { #ifdef EXV_ENABLE_NLS setlocale(LC_ALL, ""); - const std::string localeDir = - EXV_LOCALEDIR[0] == '/' ? EXV_LOCALEDIR : (Exiv2::getProcessPath() + EXV_SEPARATOR_STR + EXV_LOCALEDIR); + auto localeDir = []() -> std::string { + if constexpr (EXV_LOCALEDIR[0] == '/') + return EXV_LOCALEDIR; + else + return Exiv2::getProcessPath() + EXV_SEPARATOR_STR + EXV_LOCALEDIR; + }(); bindtextdomain(EXV_PACKAGE_NAME, localeDir.c_str()); textdomain(EXV_PACKAGE_NAME); #endif @@ -580,7 +584,7 @@ int Params::evalAdjust(const std::string& optArg) { int Params::evalYodAdjust(const Yod& yod, const std::string& optArg) { int rc = 0; switch (action_) { - case Action::none: // fall-through + case Action::none: case Action::adjust: if (yodAdjust_[yod].flag_) { std::cerr << progname() << ": " << _("Ignoring surplus option") << " " << yodAdjust_[yod].option_ << " " @@ -759,7 +763,7 @@ int Params::evalDelete(const std::string& optArg) { case Action::none: action_ = Action::erase; target_ = static_cast(0); - // fallthrough + [[fallthrough]]; case Action::erase: { const auto rc = parseCommonTargets(optArg, "erase"); if (rc > 0) { @@ -780,7 +784,7 @@ int Params::evalExtract(const std::string& optArg) { case Action::modify: action_ = Action::extract; target_ = static_cast(0); - // fallthrough + [[fallthrough]]; case Action::extract: { const auto rc = parseCommonTargets(optArg, "extract"); if (rc > 0) { @@ -801,7 +805,7 @@ int Params::evalInsert(const std::string& optArg) { case Action::modify: action_ = Action::insert; target_ = static_cast(0); - // fallthrough + [[fallthrough]]; case Action::insert: { const auto rc = parseCommonTargets(optArg, "insert"); if (rc > 0) { @@ -820,7 +824,7 @@ int Params::evalModify(int opt, const std::string& optArg) { switch (action_) { case Action::none: action_ = Action::modify; - // fallthrough + [[fallthrough]]; case Action::modify: case Action::extract: case Action::insert: diff --git a/samples/easyaccess-test.cpp b/samples/easyaccess-test.cpp index bfb7e296..e3695bf5 100644 --- a/samples/easyaccess-test.cpp +++ b/samples/easyaccess-test.cpp @@ -8,41 +8,45 @@ // Type for an Exiv2 Easy access function using EasyAccessFct = Exiv2::ExifData::const_iterator (*)(const Exiv2::ExifData&); -static constexpr auto easyAccess = std::array{ - std::make_tuple("Orientation", &Exiv2::orientation, "Orientation"), - std::make_tuple("ISO speed", &Exiv2::isoSpeed, "ISOspeed"), - std::make_tuple("Date & time original", &Exiv2::dateTimeOriginal, "DateTimeOriginal"), - std::make_tuple("Flash bias", &Exiv2::flashBias, "FlashBias"), - std::make_tuple("Exposure mode", &Exiv2::exposureMode, "ExposureMode"), - std::make_tuple("Scene mode", &Exiv2::sceneMode, "SceneMode"), - std::make_tuple("Macro mode", &Exiv2::macroMode, "MacroMode"), - std::make_tuple("Image quality", &Exiv2::imageQuality, "ImageQuality"), - std::make_tuple("White balance", &Exiv2::whiteBalance, "WhiteBalance"), - std::make_tuple("Lens name", &Exiv2::lensName, "LensName"), - std::make_tuple("Saturation", &Exiv2::saturation, "Saturation"), - std::make_tuple("Sharpness", &Exiv2::sharpness, "Sharpness"), - std::make_tuple("Contrast", &Exiv2::contrast, "Contrast"), - std::make_tuple("Scene capture type", &Exiv2::sceneCaptureType, "SceneCaptureType"), - std::make_tuple("Metering mode", &Exiv2::meteringMode, "MeteringMode"), - std::make_tuple("Camera make", &Exiv2::make, "Make"), - std::make_tuple("Camera model", &Exiv2::model, "Model"), - std::make_tuple("Exposure time", &Exiv2::exposureTime, "ExposureTime"), - std::make_tuple("FNumber", &Exiv2::fNumber, "FNumber"), - std::make_tuple("Shutter speed value", &Exiv2::shutterSpeedValue, "ShutterSpeed"), - std::make_tuple("Aperture value", &Exiv2::apertureValue, "Aperture"), - std::make_tuple("Brightness value", &Exiv2::brightnessValue, "Brightness"), - std::make_tuple("Exposure bias", &Exiv2::exposureBiasValue, "ExposureBias"), - std::make_tuple("Max aperture value", &Exiv2::maxApertureValue, "MaxAperture"), - std::make_tuple("Subject distance", &Exiv2::subjectDistance, "SubjectDistance"), - std::make_tuple("Light source", &Exiv2::lightSource, "LightSource"), - std::make_tuple("Flash", &Exiv2::flash, "Flash"), - std::make_tuple("Camera serial number", &Exiv2::serialNumber, "SerialNumber"), - std::make_tuple("Focal length", &Exiv2::focalLength, "FocalLength"), - std::make_tuple("Subject location/area", &Exiv2::subjectArea, "SubjectArea"), - std::make_tuple("Flash energy", &Exiv2::flashEnergy, "FlashEnergy"), - std::make_tuple("Exposure index", &Exiv2::exposureIndex, "ExposureIndex"), - std::make_tuple("Sensing method", &Exiv2::sensingMethod, "SensingMethod"), - std::make_tuple("AF point", &Exiv2::afPoint, "AFpoint"), +static constexpr struct { + const char* l; + EasyAccessFct f; + const char* n; +} easyAccess[] = { + {"Orientation", &Exiv2::orientation, "Orientation"}, + {"ISO speed", &Exiv2::isoSpeed, "ISOspeed"}, + {"Date & time original", &Exiv2::dateTimeOriginal, "DateTimeOriginal"}, + {"Flash bias", &Exiv2::flashBias, "FlashBias"}, + {"Exposure mode", &Exiv2::exposureMode, "ExposureMode"}, + {"Scene mode", &Exiv2::sceneMode, "SceneMode"}, + {"Macro mode", &Exiv2::macroMode, "MacroMode"}, + {"Image quality", &Exiv2::imageQuality, "ImageQuality"}, + {"White balance", &Exiv2::whiteBalance, "WhiteBalance"}, + {"Lens name", &Exiv2::lensName, "LensName"}, + {"Saturation", &Exiv2::saturation, "Saturation"}, + {"Sharpness", &Exiv2::sharpness, "Sharpness"}, + {"Contrast", &Exiv2::contrast, "Contrast"}, + {"Scene capture type", &Exiv2::sceneCaptureType, "SceneCaptureType"}, + {"Metering mode", &Exiv2::meteringMode, "MeteringMode"}, + {"Camera make", &Exiv2::make, "Make"}, + {"Camera model", &Exiv2::model, "Model"}, + {"Exposure time", &Exiv2::exposureTime, "ExposureTime"}, + {"FNumber", &Exiv2::fNumber, "FNumber"}, + {"Shutter speed value", &Exiv2::shutterSpeedValue, "ShutterSpeed"}, + {"Aperture value", &Exiv2::apertureValue, "Aperture"}, + {"Brightness value", &Exiv2::brightnessValue, "Brightness"}, + {"Exposure bias", &Exiv2::exposureBiasValue, "ExposureBias"}, + {"Max aperture value", &Exiv2::maxApertureValue, "MaxAperture"}, + {"Subject distance", &Exiv2::subjectDistance, "SubjectDistance"}, + {"Light source", &Exiv2::lightSource, "LightSource"}, + {"Flash", &Exiv2::flash, "Flash"}, + {"Camera serial number", &Exiv2::serialNumber, "SerialNumber"}, + {"Focal length", &Exiv2::focalLength, "FocalLength"}, + {"Subject location/area", &Exiv2::subjectArea, "SubjectArea"}, + {"Flash energy", &Exiv2::flashEnergy, "FlashEnergy"}, + {"Exposure index", &Exiv2::exposureIndex, "ExposureIndex"}, + {"Sensing method", &Exiv2::sensingMethod, "SensingMethod"}, + {"AF point", &Exiv2::afPoint, "AFpoint"}, }; static void printFct(EasyAccessFct fct, Exiv2::ExifData ed, const char* label) { diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index d182bcd6..af15e720 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -975,7 +975,6 @@ size_t TiffEntryBase::writeOffset(byte* buf, size_t offset, TiffType tiffType, B break; default: throw Error(ErrorCode::kerUnsupportedDataAreaOffsetType); - break; } return rc; } // TiffEntryBase::writeOffset diff --git a/src/tiffcomposite_int.hpp b/src/tiffcomposite_int.hpp index 5fbc10fa..54ddc68f 100644 --- a/src/tiffcomposite_int.hpp +++ b/src/tiffcomposite_int.hpp @@ -598,9 +598,7 @@ class TiffDataEntryBase : public TiffEntryBase { //! @name Creators //@{ //! Constructor - TiffDataEntryBase(uint16_t tag, IfdId group, uint16_t szTag, IfdId szGroup) : - TiffEntryBase(tag, group), szTag_(szTag), szGroup_(szGroup) { - } + TiffDataEntryBase(uint16_t tag, IfdId group, uint16_t szTag, IfdId szGroup); //@} //! @name Manipulators diff --git a/src/tiffvisitor_int.cpp b/src/tiffvisitor_int.cpp index 7c1de8b6..8d83e66b 100644 --- a/src/tiffvisitor_int.cpp +++ b/src/tiffvisitor_int.cpp @@ -340,6 +340,10 @@ static const TagInfo* findTag(const TagInfo* pList, uint16_t tag) { return pList->tag_ != 0xffff ? pList : nullptr; } +TiffDataEntryBase::TiffDataEntryBase(uint16_t tag, IfdId group, uint16_t szTag, IfdId szGroup) : + TiffEntryBase(tag, group), szTag_(szTag), szGroup_(szGroup) { +} + void TiffDecoder::decodeCanonAFInfo(const TiffEntryBase* object) { // report Exif.Canon.AFInfo as usual TiffDecoder::decodeStdTiffEntry(object); diff --git a/src/types.cpp b/src/types.cpp index 95857762..70510919 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -644,8 +644,12 @@ const char* _exvGettext(const char* str) { if (!exvGettextInitialized) { // bindtextdomain(EXV_PACKAGE_NAME, EXV_LOCALEDIR); - const std::string localeDir = - EXV_LOCALEDIR[0] == '/' ? EXV_LOCALEDIR : (Exiv2::getProcessPath() + EXV_SEPARATOR_STR + EXV_LOCALEDIR); + auto localeDir = []() -> std::string { + if constexpr (EXV_LOCALEDIR[0] == '/') + return EXV_LOCALEDIR; + else + return Exiv2::getProcessPath() + EXV_SEPARATOR_STR + EXV_LOCALEDIR; + }(); bindtextdomain(EXV_PACKAGE_NAME, localeDir.c_str()); #ifdef EXV_HAVE_BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset(EXV_PACKAGE_NAME, "UTF-8");