Merge pull request #2267 from neheb/clang

mostly clang-tidy fixes
main
Kevin Backhouse 3 years ago committed by GitHub
commit 97e58a4573
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -742,16 +742,15 @@ int Params::evalDelete(const std::string& optArg) {
switch (action_) {
case Action::none:
action_ = Action::erase;
target_ = CommonTarget(0);
target_ = static_cast<CommonTarget>(0);
// fallthrough
case Action::erase: {
const auto rc = parseCommonTargets(optArg, "erase");
if (rc > 0) {
target_ |= CommonTarget(rc);
target_ |= static_cast<CommonTarget>(rc);
return 0;
} else {
return 1;
}
return 1;
}
default:
std::cerr << progname() << ": " << _("Option -d is not compatible with a previous option\n");
@ -764,16 +763,15 @@ int Params::evalExtract(const std::string& optArg) {
case Action::none:
case Action::modify:
action_ = Action::extract;
target_ = CommonTarget(0);
target_ = static_cast<CommonTarget>(0);
// fallthrough
case Action::extract: {
const auto rc = parseCommonTargets(optArg, "extract");
if (rc > 0) {
target_ |= CommonTarget(rc);
target_ |= static_cast<CommonTarget>(rc);
return 0;
} else {
return 1;
}
return 1;
}
default:
std::cerr << progname() << ": " << _("Option -e is not compatible with a previous option\n");
@ -786,16 +784,15 @@ int Params::evalInsert(const std::string& optArg) {
case Action::none:
case Action::modify:
action_ = Action::insert;
target_ = CommonTarget(0);
target_ = static_cast<CommonTarget>(0);
// fallthrough
case Action::insert: {
const auto rc = parseCommonTargets(optArg, "insert");
if (rc > 0) {
target_ |= CommonTarget(rc);
target_ |= static_cast<CommonTarget>(rc);
return 0;
} else {
return 1;
}
return 1;
}
default:
std::cerr << progname() << ": " << _("Option -i is not compatible with a previous option\n");
@ -1139,7 +1136,7 @@ void printUnrecognizedArgument(const char argc, const std::string& action) {
int64_t parseCommonTargets(const std::string& optArg, const std::string& action) {
int64_t rc = 0;
Params::CommonTarget target = Params::CommonTarget(0);
auto target = static_cast<Params::CommonTarget>(0);
Params::CommonTarget all = Params::ctExif | Params::ctIptc | Params::ctComment | Params::ctXmp;
Params::CommonTarget extra = Params::ctXmpSidecar | Params::ctExif | Params::ctIptc | Params::ctXmp;
for (size_t i = 0; rc == 0 && i < optArg.size(); ++i) {
@ -1175,7 +1172,7 @@ int64_t parseCommonTargets(const std::string& optArg, const std::string& action)
target |= extra; // -eX
if (i > 0) { // -eXX or -iXX
target |= Params::ctXmpRaw;
target = Params::CommonTarget(target & ~extra); // turn off those bits
target = static_cast<Params::CommonTarget>(target & ~extra); // turn off those bits
}
break;
@ -1196,7 +1193,7 @@ int64_t parseCommonTargets(const std::string& optArg, const std::string& action)
break;
}
}
return rc ? rc : int64_t(target);
return rc ? rc : static_cast<int64_t>(target);
}
int parsePreviewNumbers(Params::PreviewNumbers& previewNumbers, const std::string& optArg, int j) {

@ -122,7 +122,7 @@ class Params : public Util::Getopt {
static Params& instance();
//! Prevent copy-construction: not implemented.
~Params() = default;
~Params() override = default;
Params(const Params&) = delete;
Params& operator=(const Params&) = delete;

@ -14,7 +14,7 @@
// namespace extensions
namespace Exiv2 {
EXIV2API bool enableBMFF(bool enable = true);
}
} // namespace Exiv2
#ifdef EXV_ENABLE_BMFF
namespace Exiv2 {

@ -8,6 +8,7 @@
// included header files
#include <mutex>
#include "datasets.hpp"
// *****************************************************************************

@ -54,7 +54,7 @@ class EXIV2API WebPImage : public Image {
[[nodiscard]] std::string mimeType() const override;
//@}
~WebPImage() = default;
~WebPImage() override = default;
//! Copy constructor
WebPImage(const WebPImage&) = delete;
//! Assignment operator

@ -58,16 +58,11 @@ class EXIV2API Xmpdatum : public Metadatum {
Calls setValue(const std::string&).
*/
Xmpdatum& operator=(const std::string& value);
/*!
@brief Assign const char* \em value to the %Xmpdatum.
Calls operator=(const std::string&).
*/
Xmpdatum& operator=(const char* value);
/*!
@brief Assign a boolean \em value to the %Xmpdatum.
Translates the value to a string "true" or "false".
*/
Xmpdatum& operator=(const bool& value);
Xmpdatum& operator=(bool value);
/*!
@brief Assign a \em value of any type with an output operator
to the %Xmpdatum. Calls operator=(const std::string&).
@ -227,23 +222,23 @@ class EXIV2API XmpData {
//! are we to use the packet?
[[nodiscard]] bool usePacket() const {
return usePacket_;
};
}
//! set usePacket_
bool usePacket(bool b) {
bool r = usePacket_;
usePacket_ = b;
return r;
};
}
//! setPacket
void setPacket(std::string xmpPacket) {
xmpPacket_ = std::move(xmpPacket);
usePacket(false);
};
}
// ! getPacket
[[nodiscard]] const std::string& xmpPacket() const {
return xmpPacket_;
};
}
//@}
@ -404,11 +399,7 @@ class EXIV2API XmpParser {
// *****************************************************************************
// free functions, template and inline definitions
inline Xmpdatum& Xmpdatum::operator=(const char* value) {
return Xmpdatum::operator=(std::string(value));
}
inline Xmpdatum& Xmpdatum::operator=(const bool& value) {
inline Xmpdatum& Xmpdatum::operator=(bool value) {
return operator=(value ? "True" : "False");
}

@ -1284,7 +1284,7 @@ std::string Converter::computeExifDigest(bool tiff) {
}
#else
std::string Converter::computeExifDigest(bool) {
return std::string("");
return {};
}
#endif

@ -3226,9 +3226,9 @@ std::ostream& Nikon3MakerNote::print0x009e(std::ostream& os, const Value& value,
std::string d = s.empty() ? "" : "; ";
const TagDetails* td = find(nikonRetouchHistory, l);
if (td) {
s = std::string(exvGettext(td->label_)) + d + s;
s = std::string(exvGettext(td->label_)).append(d).append(s);
} else {
s = std::string(_("Unknown")) + std::string(" (") + toString(l) + std::string(")") + d + s;
s = std::string(_("Unknown")).append(" (").append(toString(l)).append(")").append(d).append(s);
}
}
return os << s;

@ -318,31 +318,25 @@ void PngChunk::parseChunkContent(Image* pImage, const byte* key, size_t keySize,
} // PngChunk::parseChunkContent
std::string PngChunk::makeMetadataChunk(const std::string& metadata, MetadataId type) {
std::string chunk;
std::string rawProfile;
switch (type) {
case mdComment:
chunk = makeUtf8TxtChunk("Description", metadata, true);
break;
return makeUtf8TxtChunk("Description", metadata, true);
case mdExif:
rawProfile = writeRawProfile(metadata, "exif");
chunk = makeAsciiTxtChunk("Raw profile type exif", rawProfile, true);
break;
return makeAsciiTxtChunk("Raw profile type exif", rawProfile, true);
case mdIptc:
rawProfile = writeRawProfile(metadata, "iptc");
chunk = makeAsciiTxtChunk("Raw profile type iptc", rawProfile, true);
break;
return makeAsciiTxtChunk("Raw profile type iptc", rawProfile, true);
case mdXmp:
chunk = makeUtf8TxtChunk("XML:com.adobe.xmp", metadata, false);
break;
return makeUtf8TxtChunk("XML:com.adobe.xmp", metadata, false);
case mdIccProfile:
break;
case mdNone:
break;
return {};
}
return chunk;
return {};
} // PngChunk::makeMetadataChunk

@ -302,7 +302,7 @@ std::string ExifKey::tagLabel() const {
std::string ExifKey::tagDesc() const {
if (!p_->tagInfo_ || p_->tagInfo_->tag_ == 0xffff)
return "";
return {};
return _(p_->tagInfo_->desc_);
}

@ -178,7 +178,8 @@ byte* Exiv2::DataBuf::data(size_t offset) {
const byte* Exiv2::DataBuf::c_data(size_t offset) const {
if (pData_.empty()) {
return nullptr;
} else if (offset >= pData_.size()) {
}
if (offset >= pData_.size()) {
throw std::out_of_range("Overflow in Exiv2::DataBuf::c_data");
}
return &pData_[offset];

@ -14,7 +14,7 @@ constexpr bool startsWith(std::string_view s, std::string_view start) {
std::string upper(const std::string& str);
/// @brief Returns the lowercase version of \b str
std::string lower(const std::string& str);
std::string lower(const std::string& a);
} // namespace Exiv2::Internal

@ -53,7 +53,7 @@ class XMLValidator {
// error out if the depth exceeds this limit.
static const size_t max_recursion_limit_ = 1000;
const XML_Parser parser_;
XML_Parser parser_;
public:
// Runs an XML parser on `buf`. Throws an exception if the XML is invalid.

Loading…
Cancel
Save