Skip to content

Commit 471b816

Browse files
authored
Merge pull request #2211 from neheb/1
clang-tidy: default member init
2 parents f3f6ffb + 3a8a8b2 commit 471b816

File tree

8 files changed

+37
-66
lines changed

8 files changed

+37
-66
lines changed

app/actions.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class Print : public Task {
162162
@return 1 if a line was written, 0 if the information was not found.
163163
*/
164164
int printTag(const Exiv2::ExifData& exifData, EasyAccessFct easyAccessFct, const std::string& label = "",
165-
EasyAccessFct easyAccessFctFallback = NULL) const;
165+
EasyAccessFct easyAccessFctFallback = nullptr) const;
166166

167167
private:
168168
std::string path_;

app/exiv2.cpp

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -176,26 +176,10 @@ int main(int argc, char* const argv[]) {
176176

177177
Params::Params() :
178178
optstring_(":hVvqfbuktTFa:Y:O:D:r:p:P:d:e:i:c:m:M:l:S:g:K:n:Q:"),
179-
help_(false),
180-
version_(false),
181-
verbose_(false),
182-
force_(false),
183-
binary_(false),
184-
unknown_(true),
185-
preserve_(false),
186-
timestamp_(false),
187-
timestampOnly_(false),
188-
fileExistsPolicy_(askPolicy),
189-
adjust_(false),
190-
printMode_(pmSummary),
191-
printItems_(0),
192-
printTags_(Exiv2::mdNone),
193-
action_(0),
179+
194180
target_(ctExif | ctIptc | ctComment | ctXmp),
195-
adjustment_(0),
196-
format_("%Y%m%d_%H%M%S"),
197-
formatSet_(false),
198-
first_(true) {
181+
182+
format_("%Y%m%d_%H%M%S") {
199183
yodAdjust_[yodYear] = emptyYodAdjust_[yodYear];
200184
yodAdjust_[yodMonth] = emptyYodAdjust_[yodMonth];
201185
yodAdjust_[yodDay] = emptyYodAdjust_[yodDay];
@@ -1453,9 +1437,10 @@ bool parseLine(ModifyCmd& modifyCmd, const std::string& line, int num) {
14531437

14541438
CmdId commandId(const std::string& cmdString) {
14551439
int i = 0;
1456-
for (; cmdIdAndString[i].cmdId_ != invalidCmdId && cmdIdAndString[i].cmdString_ != cmdString; ++i) {
1440+
while (cmdIdAndString[i].first != invalidCmdId && cmdIdAndString[i].second != cmdString) {
1441+
++i;
14571442
}
1458-
return cmdIdAndString[i].cmdId_;
1443+
return cmdIdAndString[i].first;
14591444
}
14601445

14611446
std::string parseEscapes(const std::string& input) {

app/exiv2app.hpp

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,19 @@ enum MetadataId {
3939
//! Structure for one parsed modification command
4040
struct ModifyCmd {
4141
//! C'tor
42-
ModifyCmd() :
43-
cmdId_(invalidCmdId), metadataId_(invalidMetadataId), typeId_(Exiv2::invalidTypeId), explicitType_(false) {
44-
}
45-
CmdId cmdId_; //!< Command identifier
46-
std::string key_; //!< Exiv2 key string
47-
MetadataId metadataId_; //!< Metadata identifier
48-
Exiv2::TypeId typeId_; //!< Exiv2 type identifier
42+
ModifyCmd() = default;
43+
CmdId cmdId_{invalidCmdId}; //!< Command identifier
44+
std::string key_; //!< Exiv2 key string
45+
MetadataId metadataId_{invalidMetadataId}; //!< Metadata identifier
46+
Exiv2::TypeId typeId_{Exiv2::invalidTypeId}; //!< Exiv2 type identifier
4947
//! Flag to indicate if the type was explicitly specified (true)
50-
bool explicitType_;
48+
bool explicitType_{false};
5149
std::string value_; //!< Data
5250
};
5351
//! Container for modification commands
5452
using ModifyCmds = std::vector<ModifyCmd>;
5553
//! Structure to link command identifiers to strings
56-
struct CmdIdAndString {
57-
CmdId cmdId_; //!< Commands identifier
58-
std::string cmdString_; //!< Command string
59-
};
60-
54+
using CmdIdAndString = std::pair<CmdId, std::string>;
6155
/*!
6256
@brief Implements the command line handling for the program.
6357
@@ -182,28 +176,28 @@ class Params : public Util::Getopt {
182176
long adjustment_; //!< Adjustment value.
183177
};
184178

185-
bool help_; //!< Help option flag.
186-
bool version_; //!< Version option flag.
187-
bool verbose_; //!< Verbose (talkative) option flag.
188-
bool force_; //!< Force overwrites flag.
189-
bool binary_; //!< Suppress long binary values.
190-
bool unknown_; //!< Suppress unknown tags.
191-
bool preserve_; //!< Preserve timestamps flag.
192-
bool timestamp_; //!< Rename also sets the file timestamp.
193-
bool timestampOnly_; //!< Rename only sets the file timestamp.
194-
FileExistsPolicy fileExistsPolicy_; //!< What to do if file to rename exists.
195-
bool adjust_; //!< Adjustment flag.
196-
PrintMode printMode_; //!< Print mode.
197-
unsigned long printItems_; //!< Print items.
198-
unsigned long printTags_; //!< Print tags (bitmap of MetadataId flags).
179+
bool help_{false}; //!< Help option flag.
180+
bool version_{false}; //!< Version option flag.
181+
bool verbose_{false}; //!< Verbose (talkative) option flag.
182+
bool force_{false}; //!< Force overwrites flag.
183+
bool binary_{false}; //!< Suppress long binary values.
184+
bool unknown_{true}; //!< Suppress unknown tags.
185+
bool preserve_{false}; //!< Preserve timestamps flag.
186+
bool timestamp_{false}; //!< Rename also sets the file timestamp.
187+
bool timestampOnly_{false}; //!< Rename only sets the file timestamp.
188+
FileExistsPolicy fileExistsPolicy_{askPolicy}; //!< What to do if file to rename exists.
189+
bool adjust_{false}; //!< Adjustment flag.
190+
PrintMode printMode_{pmSummary}; //!< Print mode.
191+
unsigned long printItems_{0}; //!< Print items.
192+
unsigned long printTags_{Exiv2::mdNone}; //!< Print tags (bitmap of MetadataId flags).
199193
//! %Action (integer rather than TaskType to avoid dependency).
200-
int action_;
194+
int action_{0};
201195
int target_; //!< What common target to process.
202196

203-
long adjustment_; //!< Adjustment in seconds.
197+
long adjustment_{0}; //!< Adjustment in seconds.
204198
YodAdjust yodAdjust_[3]; //!< Year, month and day adjustment info.
205199
std::string format_; //!< Filename format (-r option arg).
206-
bool formatSet_; //!< Whether the format is set with -r
200+
bool formatSet_{false}; //!< Whether the format is set with -r
207201
CmdFiles cmdFiles_; //!< Names of the modification command files
208202
CmdLines cmdLines_; //!< Commands from the command line
209203
ModifyCmds modifyCmds_; //!< Parsed modification commands
@@ -219,7 +213,7 @@ class Params : public Util::Getopt {
219213
Exiv2::DataBuf stdinBuf; //!< DataBuf with the binary bytes from stdin
220214

221215
private:
222-
bool first_;
216+
bool first_{true};
223217

224218
Params();
225219

app/getopt.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ int getopt(int argc, char* const argv[], const char* optstring) {
7979

8080
// *****************************************************************************
8181
// class Getopt
82-
Getopt::Getopt() : errcnt_(0) {
83-
}
84-
8582
int Getopt::getopt(int argc, char* const argv[], const std::string& optstring) {
8683
progname_ = fs::path(argv[0]).filename().string();
8784
Util::optind = 0; // reset the Util::Getopt scanner

app/getopt.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ int getopt(int argc, char* const argv[], const char* optstring);
2929
class Getopt {
3030
public:
3131
//! Default constructor.
32-
Getopt();
32+
Getopt() = default;
3333

3434
//! Destructor.
3535
virtual ~Getopt() = default;
@@ -96,7 +96,7 @@ class Getopt {
9696

9797
private:
9898
std::string progname_;
99-
int errcnt_;
99+
int errcnt_{0};
100100
};
101101

102102
}; // namespace Util

include/exiv2/value.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ class EXIV2API CommentValue : public StringValueBase {
582582

583583
public:
584584
// DATA
585-
ByteOrder byteOrder_; //!< Byte order of the comment string that was read
585+
ByteOrder byteOrder_{littleEndian}; //!< Byte order of the comment string that was read
586586

587587
}; // class CommentValue
588588

src/tags.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,6 @@ void ExifTags::taglist(std::ostream& os, const std::string& groupName) {
143143

144144
//! %Internal Pimpl structure with private members and data of class ExifKey.
145145
struct ExifKey::Impl {
146-
//! @name Creators
147-
//@{
148-
Impl() = default; //!< Default constructor
149-
//@}
150-
151146
//! @name Manipulators
152147
//@{
153148
/*!

src/value.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,10 @@ CommentValue::CharsetId CommentValue::CharsetInfo::charsetIdByCode(const std::st
330330
return charsetTable_[i].charsetId_ == lastCharsetId ? invalidCharsetId : charsetTable_[i].charsetId_;
331331
}
332332

333-
CommentValue::CommentValue() : StringValueBase(Exiv2::undefined), byteOrder_(littleEndian) {
333+
CommentValue::CommentValue() : StringValueBase(Exiv2::undefined) {
334334
}
335335

336-
CommentValue::CommentValue(const std::string& comment) : StringValueBase(Exiv2::undefined), byteOrder_(littleEndian) {
336+
CommentValue::CommentValue(const std::string& comment) : StringValueBase(Exiv2::undefined) {
337337
read(comment);
338338
}
339339

0 commit comments

Comments
 (0)