From e53548a95a5b519b11ff8d1a25624a70e2c39c3e Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 10 Jun 2021 01:32:24 -0700 Subject: [PATCH] clang-tidy: use default member init Found with modernize-use-default-member-init Signed-off-by: Rosen Penev --- include/exiv2/value.hpp | 47 +++++++++++++++++-------------------- include/exiv2/xmp_exiv2.hpp | 4 ++-- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/include/exiv2/value.hpp b/include/exiv2/value.hpp index aa5e2648..205f1186 100644 --- a/include/exiv2/value.hpp +++ b/include/exiv2/value.hpp @@ -992,10 +992,10 @@ namespace Exiv2 { //! Simple Date helper structure struct EXIV2API Date { - Date() : year(0), month(0), day(0) {} - int year; //!< Year - int month; //!< Month - int day; //!< Day + Date() = default; + int year{0}; //!< Year + int month{0}; //!< Month + int day{0}; //!< Day }; //! @name Manipulators @@ -1096,13 +1096,13 @@ namespace Exiv2 { //! Simple Time helper structure struct Time { - Time() : hour(0), minute(0), second(0), tzHour(0), tzMinute(0) {} + Time() = default; - int hour; //!< Hour - int minute; //!< Minute - int second; //!< Second - int tzHour; //!< Hours ahead or behind UTC - int tzMinute; //!< Minutes ahead or behind UTC + int hour{0}; //!< Hour + int minute{0}; //!< Minute + int second{0}; //!< Second + int tzHour{0}; //!< Hours ahead or behind UTC + int tzMinute{0}; //!< Minutes ahead or behind UTC }; //! @name Manipulators @@ -1321,9 +1321,9 @@ namespace Exiv2 { // DATA //! Pointer to the buffer, nullptr if none has been allocated - byte* pDataArea_; + byte* pDataArea_{nullptr}; //! The current size of the buffer - long sizeDataArea_; + long sizeDataArea_{0}; }; // class ValueType //! Unsigned short value type @@ -1493,28 +1493,24 @@ namespace Exiv2 { return d2Data(buf, t, byteOrder); } - template - ValueType::ValueType() - : Value(getType()), pDataArea_(nullptr), sizeDataArea_(0) + template + ValueType::ValueType() : Value(getType()) { } - template - ValueType::ValueType(TypeId typeId) - : Value(typeId), pDataArea_(nullptr), sizeDataArea_(0) + template + ValueType::ValueType(TypeId typeId) : Value(typeId) { } - template - ValueType::ValueType(const byte* buf, long len, ByteOrder byteOrder, TypeId typeId) - : Value(typeId), pDataArea_(nullptr), sizeDataArea_(0) + template + ValueType::ValueType(const byte* buf, long len, ByteOrder byteOrder, TypeId typeId) : Value(typeId) { read(buf, len, byteOrder); } - template - ValueType::ValueType(const T& val, TypeId typeId) - : Value(typeId), pDataArea_(nullptr), sizeDataArea_(0) + template + ValueType::ValueType(const T& val, TypeId typeId) : Value(typeId) { value_.push_back(val); } @@ -1523,8 +1519,7 @@ namespace Exiv2 { ValueType::ValueType(const ValueType& rhs) : Value(rhs.typeId()) , value_(rhs.value_) - , pDataArea_(nullptr) - , sizeDataArea_(0) + { if (rhs.sizeDataArea_ > 0) { pDataArea_ = new byte[rhs.sizeDataArea_]; diff --git a/include/exiv2/xmp_exiv2.hpp b/include/exiv2/xmp_exiv2.hpp index 6cb3620e..6e7a76bc 100644 --- a/include/exiv2/xmp_exiv2.hpp +++ b/include/exiv2/xmp_exiv2.hpp @@ -166,7 +166,7 @@ namespace Exiv2 { class EXIV2API XmpData { public: //! Default constructor - XmpData() : xmpMetadata_(), xmpPacket_(), usePacket_(0) {} + XmpData() = default; //! XmpMetadata iterator type typedef XmpMetadata::iterator iterator; @@ -257,7 +257,7 @@ namespace Exiv2 { // DATA XmpMetadata xmpMetadata_; std::string xmpPacket_ ; - bool usePacket_ ; + bool usePacket_{0}; }; // class XmpData /*!