diff --git a/app/actions.cpp b/app/actions.cpp index 0cb99382..9f665ef4 100644 --- a/app/actions.cpp +++ b/app/actions.cpp @@ -199,34 +199,25 @@ int setModeAndPrintStructure(Exiv2::PrintStructureOption option, const std::stri int Print::run(const std::string& path) { try { path_ = path; - int rc = 0; switch (Params::instance().printMode_) { case Params::pmSummary: - rc = Params::instance().greps_.empty() ? printSummary() : printList(); - break; + return Params::instance().greps_.empty() ? printSummary() : printList(); case Params::pmList: - rc = printList(); - break; + return printList(); case Params::pmComment: - rc = printComment(); - break; + return printComment(); case Params::pmPreview: - rc = printPreviewList(); - break; + return printPreviewList(); case Params::pmStructure: - rc = printStructure(std::cout, Exiv2::kpsBasic, path_); - break; + return printStructure(std::cout, Exiv2::kpsBasic, path_); case Params::pmRecursive: - rc = printStructure(std::cout, Exiv2::kpsRecursive, path_); - break; + return printStructure(std::cout, Exiv2::kpsRecursive, path_); case Params::pmXMP: - rc = setModeAndPrintStructure(Exiv2::kpsXMP, path_, binary()); - break; + return setModeAndPrintStructure(Exiv2::kpsXMP, path_, binary()); case Params::pmIccProfile: - rc = setModeAndPrintStructure(Exiv2::kpsIccProfile, path_, binary()); - break; + return setModeAndPrintStructure(Exiv2::kpsIccProfile, path_, binary()); } - return rc; + return 0; } catch (const Exiv2::Error& e) { std::cerr << "Exiv2 exception in print action for file " << path << ":\n" << e << "\n"; return 1; diff --git a/src/crwimage_int.cpp b/src/crwimage_int.cpp index 26051244..98dc859d 100644 --- a/src/crwimage_int.cpp +++ b/src/crwimage_int.cpp @@ -246,15 +246,11 @@ void CiffDirectory::readDirectory(const byte* pData, size_t size, ByteOrder byte for (uint16_t i = 0; i < count; ++i) { uint16_t tag = getUShort(pData + o, byteOrder); - std::unique_ptr m; - switch (CiffComponent::typeId(tag)) { - case directory: - m = std::make_unique(); - break; - default: - m = std::make_unique(); - break; - } + auto m = [this, tag]() -> std::unique_ptr { + if (this->typeId(tag) == TypeId::directory) + return std::make_unique(); + return std::make_unique(); + }(); m->setDir(this->tag()); m->read(pData, size, o, byteOrder); add(std::move(m)); diff --git a/src/exif.cpp b/src/exif.cpp index 79695b7d..750eae50 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -681,26 +681,22 @@ WriteMethod ExifParser::encode(Blob& blob, const byte* pData, size_t size, ByteO namespace { //! @cond IGNORE Thumbnail::UniquePtr Thumbnail::create(const Exiv2::ExifData& exifData) { - std::unique_ptr thumbnail; const Exiv2::ExifKey k1("Exif.Thumbnail.Compression"); auto pos = exifData.findKey(k1); if (pos != exifData.end()) { if (pos->count() == 0) - return thumbnail; + return nullptr; auto compression = pos->toInt64(); - if (compression == 6) { - thumbnail = std::make_unique(); - } else { - thumbnail = std::make_unique(); - } - } else { - const Exiv2::ExifKey k2("Exif.Thumbnail.JPEGInterchangeFormat"); - pos = exifData.findKey(k2); - if (pos != exifData.end()) { - thumbnail = std::make_unique(); - } + if (compression == 6) + return std::make_unique(); + return std::make_unique(); } - return thumbnail; + + const Exiv2::ExifKey k2("Exif.Thumbnail.JPEGInterchangeFormat"); + pos = exifData.findKey(k2); + if (pos != exifData.end()) + return std::make_unique(); + return nullptr; } const char* TiffThumbnail::mimeType() const { diff --git a/src/tiffimage_int.cpp b/src/tiffimage_int.cpp index 67e0008b..23f958a5 100644 --- a/src/tiffimage_int.cpp +++ b/src/tiffimage_int.cpp @@ -1807,24 +1807,19 @@ bool TiffTreeStruct::operator==(const TiffTreeStruct::Key& key) const { } TiffComponent::UniquePtr TiffCreator::create(uint32_t extendedTag, IfdId group) { - std::unique_ptr tc; auto tag = static_cast(extendedTag & 0xffff); const TiffGroupStruct* ts = find(tiffGroupStruct_, TiffGroupStruct::Key(extendedTag, group)); - if (ts && ts->newTiffCompFct_) { - tc = ts->newTiffCompFct_(tag, group); - } + if (ts && ts->newTiffCompFct_) + return ts->newTiffCompFct_(tag, group); #ifdef EXIV2_DEBUG_MESSAGES - else { - if (!ts) { - std::cerr << "Warning: No TIFF structure entry found for "; - } else { - std::cerr << "Warning: No TIFF component creator found for "; - } - std::cerr << "extended tag 0x" << std::setw(4) << std::setfill('0') << std::hex << std::right << extendedTag - << ", group " << groupName(group) << "\n"; - } + if (!ts) + std::cerr << "Warning: No TIFF structure entry found for "; + else + std::cerr << "Warning: No TIFF component creator found for "; + std::cerr << "extended tag 0x" << std::setw(4) << std::setfill('0') << std::hex << std::right << extendedTag + << ", group " << groupName(group) << "\n"; #endif - return tc; + return nullptr; } // TiffCreator::create void TiffCreator::getPath(TiffPath& tiffPath, uint32_t extendedTag, IfdId group, uint32_t root) { diff --git a/src/value.cpp b/src/value.cpp index 06880825..1f13d4dd 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -19,72 +19,51 @@ Value::Value(TypeId typeId) : type_(typeId) { } Value::UniquePtr Value::create(TypeId typeId) { - std::unique_ptr value; switch (typeId) { case invalidTypeId: case signedByte: case unsignedByte: - value = std::make_unique(typeId); - break; + return std::make_unique(typeId); case asciiString: - value = std::make_unique(); - break; + return std::make_unique(); case unsignedShort: - value = std::make_unique>(); - break; + return std::make_unique>(); case unsignedLong: case tiffIfd: - value = std::make_unique>(typeId); - break; + return std::make_unique>(typeId); case unsignedRational: - value = std::make_unique>(); - break; + return std::make_unique>(); case undefined: - value = std::make_unique(); - break; + return std::make_unique(); case signedShort: - value = std::make_unique>(); - break; + return std::make_unique>(); case signedLong: - value = std::make_unique>(); - break; + return std::make_unique>(); case signedRational: - value = std::make_unique>(); - break; + return std::make_unique>(); case tiffFloat: - value = std::make_unique>(); - break; + return std::make_unique>(); case tiffDouble: - value = std::make_unique>(); - break; + return std::make_unique>(); case string: - value = std::make_unique(); - break; + return std::make_unique(); case date: - value = std::make_unique(); - break; + return std::make_unique(); case time: - value = std::make_unique(); - break; + return std::make_unique(); case comment: - value = std::make_unique(); - break; + return std::make_unique(); case xmpText: - value = std::make_unique(); - break; + return std::make_unique(); case xmpBag: case xmpSeq: case xmpAlt: - value = std::make_unique(typeId); - break; + return std::make_unique(typeId); case langAlt: - value = std::make_unique(); - break; + return std::make_unique(); default: - value = std::make_unique(typeId); - break; + return std::make_unique(typeId); } - return value; } // Value::create int Value::setDataArea(const byte* /*buf*/, size_t /*len*/) {