Skip to content

Commit 97e58a4

Browse files
Merge pull request #2267 from neheb/clang
mostly clang-tidy fixes
2 parents 2c31430 + 7575300 commit 97e58a4

File tree

13 files changed

+36
-52
lines changed

13 files changed

+36
-52
lines changed

app/exiv2.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -742,16 +742,15 @@ int Params::evalDelete(const std::string& optArg) {
742742
switch (action_) {
743743
case Action::none:
744744
action_ = Action::erase;
745-
target_ = CommonTarget(0);
745+
target_ = static_cast<CommonTarget>(0);
746746
// fallthrough
747747
case Action::erase: {
748748
const auto rc = parseCommonTargets(optArg, "erase");
749749
if (rc > 0) {
750-
target_ |= CommonTarget(rc);
750+
target_ |= static_cast<CommonTarget>(rc);
751751
return 0;
752-
} else {
753-
return 1;
754752
}
753+
return 1;
755754
}
756755
default:
757756
std::cerr << progname() << ": " << _("Option -d is not compatible with a previous option\n");
@@ -764,16 +763,15 @@ int Params::evalExtract(const std::string& optArg) {
764763
case Action::none:
765764
case Action::modify:
766765
action_ = Action::extract;
767-
target_ = CommonTarget(0);
766+
target_ = static_cast<CommonTarget>(0);
768767
// fallthrough
769768
case Action::extract: {
770769
const auto rc = parseCommonTargets(optArg, "extract");
771770
if (rc > 0) {
772-
target_ |= CommonTarget(rc);
771+
target_ |= static_cast<CommonTarget>(rc);
773772
return 0;
774-
} else {
775-
return 1;
776773
}
774+
return 1;
777775
}
778776
default:
779777
std::cerr << progname() << ": " << _("Option -e is not compatible with a previous option\n");
@@ -786,16 +784,15 @@ int Params::evalInsert(const std::string& optArg) {
786784
case Action::none:
787785
case Action::modify:
788786
action_ = Action::insert;
789-
target_ = CommonTarget(0);
787+
target_ = static_cast<CommonTarget>(0);
790788
// fallthrough
791789
case Action::insert: {
792790
const auto rc = parseCommonTargets(optArg, "insert");
793791
if (rc > 0) {
794-
target_ |= CommonTarget(rc);
792+
target_ |= static_cast<CommonTarget>(rc);
795793
return 0;
796-
} else {
797-
return 1;
798794
}
795+
return 1;
799796
}
800797
default:
801798
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) {
11391136

11401137
int64_t parseCommonTargets(const std::string& optArg, const std::string& action) {
11411138
int64_t rc = 0;
1142-
Params::CommonTarget target = Params::CommonTarget(0);
1139+
auto target = static_cast<Params::CommonTarget>(0);
11431140
Params::CommonTarget all = Params::ctExif | Params::ctIptc | Params::ctComment | Params::ctXmp;
11441141
Params::CommonTarget extra = Params::ctXmpSidecar | Params::ctExif | Params::ctIptc | Params::ctXmp;
11451142
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)
11751172
target |= extra; // -eX
11761173
if (i > 0) { // -eXX or -iXX
11771174
target |= Params::ctXmpRaw;
1178-
target = Params::CommonTarget(target & ~extra); // turn off those bits
1175+
target = static_cast<Params::CommonTarget>(target & ~extra); // turn off those bits
11791176
}
11801177
break;
11811178

@@ -1196,7 +1193,7 @@ int64_t parseCommonTargets(const std::string& optArg, const std::string& action)
11961193
break;
11971194
}
11981195
}
1199-
return rc ? rc : int64_t(target);
1196+
return rc ? rc : static_cast<int64_t>(target);
12001197
}
12011198

12021199
int parsePreviewNumbers(Params::PreviewNumbers& previewNumbers, const std::string& optArg, int j) {

app/exiv2app.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class Params : public Util::Getopt {
122122
static Params& instance();
123123

124124
//! Prevent copy-construction: not implemented.
125-
~Params() = default;
125+
~Params() override = default;
126126
Params(const Params&) = delete;
127127
Params& operator=(const Params&) = delete;
128128

include/exiv2/bmffimage.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// namespace extensions
1515
namespace Exiv2 {
1616
EXIV2API bool enableBMFF(bool enable = true);
17-
}
17+
} // namespace Exiv2
1818

1919
#ifdef EXV_ENABLE_BMFF
2020
namespace Exiv2 {

include/exiv2/properties.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
// included header files
1010
#include <mutex>
11+
1112
#include "datasets.hpp"
1213

1314
// *****************************************************************************

include/exiv2/webpimage.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class EXIV2API WebPImage : public Image {
5454
[[nodiscard]] std::string mimeType() const override;
5555
//@}
5656

57-
~WebPImage() = default;
57+
~WebPImage() override = default;
5858
//! Copy constructor
5959
WebPImage(const WebPImage&) = delete;
6060
//! Assignment operator

include/exiv2/xmp_exiv2.hpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,11 @@ class EXIV2API Xmpdatum : public Metadatum {
5858
Calls setValue(const std::string&).
5959
*/
6060
Xmpdatum& operator=(const std::string& value);
61-
/*!
62-
@brief Assign const char* \em value to the %Xmpdatum.
63-
Calls operator=(const std::string&).
64-
*/
65-
Xmpdatum& operator=(const char* value);
6661
/*!
6762
@brief Assign a boolean \em value to the %Xmpdatum.
6863
Translates the value to a string "true" or "false".
6964
*/
70-
Xmpdatum& operator=(const bool& value);
65+
Xmpdatum& operator=(bool value);
7166
/*!
7267
@brief Assign a \em value of any type with an output operator
7368
to the %Xmpdatum. Calls operator=(const std::string&).
@@ -227,23 +222,23 @@ class EXIV2API XmpData {
227222
//! are we to use the packet?
228223
[[nodiscard]] bool usePacket() const {
229224
return usePacket_;
230-
};
225+
}
231226

232227
//! set usePacket_
233228
bool usePacket(bool b) {
234229
bool r = usePacket_;
235230
usePacket_ = b;
236231
return r;
237-
};
232+
}
238233
//! setPacket
239234
void setPacket(std::string xmpPacket) {
240235
xmpPacket_ = std::move(xmpPacket);
241236
usePacket(false);
242-
};
237+
}
243238
// ! getPacket
244239
[[nodiscard]] const std::string& xmpPacket() const {
245240
return xmpPacket_;
246-
};
241+
}
247242

248243
//@}
249244

@@ -404,11 +399,7 @@ class EXIV2API XmpParser {
404399
// *****************************************************************************
405400
// free functions, template and inline definitions
406401

407-
inline Xmpdatum& Xmpdatum::operator=(const char* value) {
408-
return Xmpdatum::operator=(std::string(value));
409-
}
410-
411-
inline Xmpdatum& Xmpdatum::operator=(const bool& value) {
402+
inline Xmpdatum& Xmpdatum::operator=(bool value) {
412403
return operator=(value ? "True" : "False");
413404
}
414405

src/convert.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ std::string Converter::computeExifDigest(bool tiff) {
12841284
}
12851285
#else
12861286
std::string Converter::computeExifDigest(bool) {
1287-
return std::string("");
1287+
return {};
12881288
}
12891289
#endif
12901290

src/nikonmn_int.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3226,9 +3226,9 @@ std::ostream& Nikon3MakerNote::print0x009e(std::ostream& os, const Value& value,
32263226
std::string d = s.empty() ? "" : "; ";
32273227
const TagDetails* td = find(nikonRetouchHistory, l);
32283228
if (td) {
3229-
s = std::string(exvGettext(td->label_)) + d + s;
3229+
s = std::string(exvGettext(td->label_)).append(d).append(s);
32303230
} else {
3231-
s = std::string(_("Unknown")) + std::string(" (") + toString(l) + std::string(")") + d + s;
3231+
s = std::string(_("Unknown")).append(" (").append(toString(l)).append(")").append(d).append(s);
32323232
}
32333233
}
32343234
return os << s;

src/pngchunk_int.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -318,31 +318,25 @@ void PngChunk::parseChunkContent(Image* pImage, const byte* key, size_t keySize,
318318
} // PngChunk::parseChunkContent
319319

320320
std::string PngChunk::makeMetadataChunk(const std::string& metadata, MetadataId type) {
321-
std::string chunk;
322321
std::string rawProfile;
323322

324323
switch (type) {
325324
case mdComment:
326-
chunk = makeUtf8TxtChunk("Description", metadata, true);
327-
break;
325+
return makeUtf8TxtChunk("Description", metadata, true);
328326
case mdExif:
329327
rawProfile = writeRawProfile(metadata, "exif");
330-
chunk = makeAsciiTxtChunk("Raw profile type exif", rawProfile, true);
331-
break;
328+
return makeAsciiTxtChunk("Raw profile type exif", rawProfile, true);
332329
case mdIptc:
333330
rawProfile = writeRawProfile(metadata, "iptc");
334-
chunk = makeAsciiTxtChunk("Raw profile type iptc", rawProfile, true);
335-
break;
331+
return makeAsciiTxtChunk("Raw profile type iptc", rawProfile, true);
336332
case mdXmp:
337-
chunk = makeUtf8TxtChunk("XML:com.adobe.xmp", metadata, false);
338-
break;
333+
return makeUtf8TxtChunk("XML:com.adobe.xmp", metadata, false);
339334
case mdIccProfile:
340-
break;
341335
case mdNone:
342-
break;
336+
return {};
343337
}
344338

345-
return chunk;
339+
return {};
346340

347341
} // PngChunk::makeMetadataChunk
348342

src/tags.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ std::string ExifKey::tagLabel() const {
302302

303303
std::string ExifKey::tagDesc() const {
304304
if (!p_->tagInfo_ || p_->tagInfo_->tag_ == 0xffff)
305-
return "";
305+
return {};
306306
return _(p_->tagInfo_->desc_);
307307
}
308308

0 commit comments

Comments
 (0)