Skip to content

Commit a5c521e

Browse files
Merge pull request #2252 from neheb/2
clang-tidy: use default member init
2 parents 60b3e28 + bae7da1 commit a5c521e

File tree

13 files changed

+73
-98
lines changed

13 files changed

+73
-98
lines changed

include/exiv2/basicio.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ class EXIV2API XPathIo : public FileIo {
735735

736736
private:
737737
// True if the file is a temporary file and it should be deleted in destructor.
738-
bool isTemp_;
738+
bool isTemp_{true};
739739
std::string tempFilePath_;
740740
}; // class XPathIo
741741
#endif

include/exiv2/image.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,8 @@ class EXIV2API Image {
467467
DataBuf iccProfile_; //!< ICC buffer (binary data)
468468
std::string comment_; //!< User comment
469469
std::string xmpPacket_; //!< XMP packet
470-
uint32_t pixelWidth_; //!< image pixel width
471-
uint32_t pixelHeight_; //!< image pixel height
470+
uint32_t pixelWidth_{0}; //!< image pixel width
471+
uint32_t pixelHeight_{0}; //!< image pixel height
472472
NativePreviewList nativePreviews_; //!< list of native previews
473473

474474
//! Return tag name for given tag id.
@@ -479,13 +479,13 @@ class EXIV2API Image {
479479

480480
private:
481481
// DATA
482-
ImageType imageType_; //!< Image type
483-
uint16_t supportedMetadata_; //!< Bitmap with all supported metadata types
484-
bool writeXmpFromPacket_; //!< Determines the source when writing XMP
485-
ByteOrder byteOrder_; //!< Byte order
482+
ImageType imageType_; //!< Image type
483+
uint16_t supportedMetadata_; //!< Bitmap with all supported metadata types
484+
bool writeXmpFromPacket_; //!< Determines the source when writing XMP
485+
ByteOrder byteOrder_{invalidByteOrder}; //!< Byte order
486486

487487
std::map<int, std::string> tags_; //!< Map of tags
488-
bool init_; //!< Flag marking if map of tags needs to be initialized
488+
bool init_{true}; //!< Flag marking if map of tags needs to be initialized
489489

490490
}; // class Image
491491

include/exiv2/tiffimage.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ class EXIV2API TiffImage : public Image {
8585
//@}
8686

8787
// DATA
88-
mutable std::string primaryGroup_; //!< The primary group
89-
mutable std::string mimeType_; //!< The MIME type
90-
mutable uint32_t pixelWidthPrimary_; //!< Width of the primary image in pixels
91-
mutable uint32_t pixelHeightPrimary_; //!< Height of the primary image in pixels
88+
mutable std::string primaryGroup_; //!< The primary group
89+
mutable std::string mimeType_; //!< The MIME type
90+
mutable uint32_t pixelWidthPrimary_{0}; //!< Width of the primary image in pixels
91+
mutable uint32_t pixelHeightPrimary_{0}; //!< Height of the primary image in pixels
9292

9393
}; // class TiffImage
9494

include/exiv2/value.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class EXIV2API Value {
229229
*/
230230
Value& operator=(const Value&) = default;
231231
// DATA
232-
mutable bool ok_; //!< Indicates the status of the previous to<Type> conversion
232+
mutable bool ok_{true}; //!< Indicates the status of the previous to<Type> conversion
233233

234234
private:
235235
//! Internal virtual copy constructor.
@@ -648,8 +648,8 @@ class EXIV2API XmpValue : public Value {
648648

649649
private:
650650
// DATA
651-
XmpArrayType xmpArrayType_; //!< Type of XMP array
652-
XmpStruct xmpStruct_; //!< XMP structure indicator
651+
XmpArrayType xmpArrayType_{xaNone}; //!< Type of XMP array
652+
XmpStruct xmpStruct_{xsNone}; //!< XMP structure indicator
653653

654654
}; // class XmpValue
655655

src/basicio.cpp

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ void XPathIo::ReadDataUri(const std::string& path) {
901901
}
902902

903903
#else
904-
XPathIo::XPathIo(const std::string& orgPath) : FileIo(XPathIo::writeDataToFile(orgPath)), isTemp_(true) {
904+
XPathIo::XPathIo(const std::string& orgPath) : FileIo(XPathIo::writeDataToFile(orgPath)) {
905905
tempFilePath_ = path();
906906
}
907907

@@ -994,15 +994,15 @@ class RemoteIo::Impl {
994994
Impl& operator=(const Impl&) = delete;
995995

996996
// DATA
997-
std::string path_; //!< (Standard) path
998-
size_t blockSize_; //!< Size of the block memory.
999-
BlockMap* blocksMap_; //!< An array contains all blocksMap
1000-
size_t size_; //!< The file size
1001-
size_t idx_; //!< Index into the memory area
1002-
bool isMalloced_; //!< Was the blocksMap_ allocated?
1003-
bool eof_; //!< EOF indicator
1004-
Protocol protocol_; //!< the protocol of url
1005-
size_t totalRead_; //!< bytes requested from host
997+
std::string path_; //!< (Standard) path
998+
size_t blockSize_; //!< Size of the block memory.
999+
BlockMap* blocksMap_{nullptr}; //!< An array contains all blocksMap
1000+
size_t size_{0}; //!< The file size
1001+
size_t idx_{0}; //!< Index into the memory area
1002+
bool isMalloced_{false}; //!< Was the blocksMap_ allocated?
1003+
bool eof_{false}; //!< EOF indicator
1004+
Protocol protocol_; //!< the protocol of url
1005+
size_t totalRead_{0}; //!< bytes requested from host
10061006

10071007
// METHODS
10081008
/*!
@@ -1044,15 +1044,7 @@ class RemoteIo::Impl {
10441044
}; // class RemoteIo::Impl
10451045

10461046
RemoteIo::Impl::Impl(const std::string& url, size_t blockSize) :
1047-
path_(url),
1048-
blockSize_(blockSize),
1049-
blocksMap_(nullptr),
1050-
size_(0),
1051-
idx_(0),
1052-
isMalloced_(false),
1053-
eof_(false),
1054-
protocol_(fileProtocol(url)),
1055-
totalRead_(0) {
1047+
path_(url), blockSize_(blockSize), protocol_(fileProtocol(url)) {
10561048
}
10571049

10581050
size_t RemoteIo::Impl::populateBlocks(size_t lowBlock, size_t highBlock) {

src/image.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,13 @@ std::string pathOfFileUrl(const std::string& url) {
116116
namespace Exiv2 {
117117
Image::Image(ImageType type, uint16_t supportedMetadata, BasicIo::UniquePtr io) :
118118
io_(std::move(io)),
119-
pixelWidth_(0),
120-
pixelHeight_(0),
121119
imageType_(type),
122120
supportedMetadata_(supportedMetadata),
123121
#ifdef EXV_HAVE_XMP_TOOLKIT
124-
writeXmpFromPacket_(false),
122+
writeXmpFromPacket_(false) {
125123
#else
126-
writeXmpFromPacket_(true),
124+
writeXmpFromPacket_(true) {
127125
#endif
128-
byteOrder_(invalidByteOrder),
129-
init_(true) {
130126
}
131127

132128
void Image::printStructure(std::ostream&, PrintStructureOption, int /*depth*/) {

src/preview.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,16 @@ class Loader {
101101
const Image& image_;
102102

103103
//! Preview image width
104-
size_t width_;
104+
size_t width_{0};
105105

106106
//! Preview image length
107-
size_t height_;
107+
size_t height_{0};
108108

109109
//! Preview image size in bytes
110-
size_t size_;
110+
size_t size_{0};
111111

112112
//! True if the source image contains a preview image of given type
113-
bool valid_;
113+
bool valid_{false};
114114
};
115115

116116
//! Loader for native previews
@@ -163,7 +163,7 @@ class LoaderExifJpeg : public Loader {
163163
static const Param param_[];
164164

165165
//! Offset value
166-
size_t offset_;
166+
size_t offset_{0};
167167
};
168168

169169
//! Function to create new LoaderExifJpeg
@@ -335,8 +335,7 @@ Loader::UniquePtr Loader::create(PreviewId id, const Image& image) {
335335
return loader;
336336
}
337337

338-
Loader::Loader(PreviewId id, const Image& image) :
339-
id_(id), image_(image), width_(0), height_(0), size_(0), valid_(false) {
338+
Loader::Loader(PreviewId id, const Image& image) : id_(id), image_(image) {
340339
}
341340

342341
PreviewProperties Loader::getProperties() const {
@@ -457,7 +456,7 @@ bool LoaderNative::readDimensions() {
457456
return true;
458457
}
459458

460-
LoaderExifJpeg::LoaderExifJpeg(PreviewId id, const Image& image, int parIdx) : Loader(id, image), offset_(0) {
459+
LoaderExifJpeg::LoaderExifJpeg(PreviewId id, const Image& image, int parIdx) : Loader(id, image) {
461460
const ExifData& exifData = image_.exifData();
462461
auto pos = exifData.findKey(ExifKey(param_[parIdx].offsetKey_));
463462
if (pos != exifData.end() && pos->count() > 0) {

src/tiffcomposite_int.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ bool TiffMappingInfo::operator==(const TiffMappingInfo::Key& key) const {
2828
}
2929

3030
IoWrapper::IoWrapper(BasicIo& io, const byte* pHeader, size_t size, OffsetWriter* pow) :
31-
io_(io), pHeader_(pHeader), size_(size), wroteHeader_(false), pow_(pow) {
31+
io_(io), pHeader_(pHeader), size_(size), pow_(pow) {
3232
if (!pHeader_ || size_ == 0)
3333
wroteHeader_ = true;
3434
}
@@ -73,7 +73,7 @@ TiffMnEntry::TiffMnEntry(uint16_t tag, IfdId group, IfdId mnGroup) :
7373
}
7474

7575
TiffIfdMakernote::TiffIfdMakernote(uint16_t tag, IfdId group, IfdId mnGroup, MnHeader* pHeader, bool hasNext) :
76-
TiffComponent(tag, group), pHeader_(pHeader), ifd_(tag, mnGroup, hasNext), imageByteOrder_(invalidByteOrder) {
76+
TiffComponent(tag, group), pHeader_(pHeader), ifd_(tag, mnGroup, hasNext) {
7777
}
7878

7979
TiffBinaryArray::TiffBinaryArray(uint16_t tag, IfdId group, const ArrayCfg* arrayCfg, const ArrayDef* arrayDef,
@@ -90,8 +90,7 @@ TiffBinaryArray::TiffBinaryArray(uint16_t tag, IfdId group, const ArraySet* arra
9090
// We'll figure out the correct cfg later
9191
}
9292

93-
TiffBinaryElement::TiffBinaryElement(uint16_t tag, IfdId group) :
94-
TiffEntryBase(tag, group), elByteOrder_(invalidByteOrder) {
93+
TiffBinaryElement::TiffBinaryElement(uint16_t tag, IfdId group) : TiffEntryBase(tag, group) {
9594
elDef_.idx_ = 0;
9695
elDef_.tiffType_ = ttUndefined;
9796
elDef_.count_ = 0;

src/tiffcomposite_int.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ class IoWrapper {
134134

135135
private:
136136
// DATA
137-
BasicIo& io_; //! Reference for the IO instance.
138-
const byte* pHeader_; //! Pointer to the header data.
139-
size_t size_; //! Size of the header data.
140-
bool wroteHeader_; //! Indicates if the header has been written.
141-
OffsetWriter* pow_; //! Pointer to an offset-writer, if any, or 0
142-
}; // class IoWrapper
137+
BasicIo& io_; //! Reference for the IO instance.
138+
const byte* pHeader_; //! Pointer to the header data.
139+
size_t size_; //! Size of the header data.
140+
bool wroteHeader_{false}; //! Indicates if the header has been written.
141+
OffsetWriter* pow_; //! Pointer to an offset-writer, if any, or 0
142+
}; // class IoWrapper
143143

144144
/*!
145145
@brief Interface class for components of a TIFF directory hierarchy
@@ -1229,10 +1229,10 @@ class TiffIfdMakernote : public TiffComponent {
12291229

12301230
private:
12311231
// DATA
1232-
MnHeader* pHeader_; //!< Makernote header
1233-
TiffDirectory ifd_; //!< Makernote IFD
1234-
uint32_t mnOffset_{}; //!< Makernote offset
1235-
ByteOrder imageByteOrder_; //!< Byte order for the image
1232+
MnHeader* pHeader_; //!< Makernote header
1233+
TiffDirectory ifd_; //!< Makernote IFD
1234+
uint32_t mnOffset_{}; //!< Makernote offset
1235+
ByteOrder imageByteOrder_{invalidByteOrder}; //!< Byte order for the image
12361236

12371237
}; // class TiffIfdMakernote
12381238

@@ -1496,8 +1496,8 @@ class TiffBinaryElement : public TiffEntryBase {
14961496

14971497
private:
14981498
// DATA
1499-
ArrayDef elDef_; //!< The array element definition
1500-
ByteOrder elByteOrder_; //!< Byte order to read/write the element
1499+
ArrayDef elDef_; //!< The array element definition
1500+
ByteOrder elByteOrder_{invalidByteOrder}; //!< Byte order to read/write the element
15011501

15021502
}; // class TiffBinaryElement
15031503

src/tiffimage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace Exiv2 {
3939
using namespace Internal;
4040

4141
TiffImage::TiffImage(BasicIo::UniquePtr io, bool /*create*/) :
42-
Image(ImageType::tiff, mdExif | mdIptc | mdXmp, std::move(io)), pixelWidthPrimary_(0), pixelHeightPrimary_(0) {
42+
Image(ImageType::tiff, mdExif | mdIptc | mdXmp, std::move(io)) {
4343
} // TiffImage::TiffImage
4444

4545
//! Structure for TIFF compression to MIME type mappings

0 commit comments

Comments
 (0)