Skip to content

Commit

Permalink
tidy: Use default member initialization.
Browse files Browse the repository at this point in the history
The clang-tidy "use default member initialization" check pointed out
some additional places where explicit constructor initializers could
me removed since they were identical to the default initializer.
Changes made by clang-tidy, with some additions by hand.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-default-member-init.html
  • Loading branch information
linuxdude42 committed Dec 18, 2019
1 parent 5ef6c50 commit 7a41a97
Show file tree
Hide file tree
Showing 45 changed files with 152 additions and 186 deletions.
13 changes: 6 additions & 7 deletions mythplugins/mytharchive/mytharchive/remoteavformatcontext.h
Expand Up @@ -16,8 +16,7 @@ extern "C" {
class RemoteAVFormatContext
{
public:
explicit RemoteAVFormatContext(const QString &filename = "") :
m_inputFC(nullptr), m_inputIsRemote(false), m_rf(nullptr), m_byteIOContext(nullptr), m_buffer(nullptr)
explicit RemoteAVFormatContext(const QString &filename = "")
{ if (!filename.isEmpty()) Open(filename); }

~RemoteAVFormatContext()
Expand Down Expand Up @@ -133,10 +132,10 @@ class RemoteAVFormatContext
}

private:
AVFormatContext *m_inputFC;
bool m_inputIsRemote;
RemoteFile *m_rf;
AVIOContext *m_byteIOContext;
unsigned char *m_buffer;
AVFormatContext *m_inputFC { nullptr };
bool m_inputIsRemote { false };
RemoteFile *m_rf { nullptr };
AVIOContext *m_byteIOContext { nullptr };
unsigned char *m_buffer { nullptr };
};
#endif // REMOTEAVFORMATCONTEXT_H
22 changes: 11 additions & 11 deletions mythplugins/mythmusic/mythmusic/cddb.h
Expand Up @@ -17,11 +17,11 @@ struct Cddb
struct Match
{
QString discGenre;
discid_t discID;
discid_t discID { 0 };
QString artist;
QString title;

Match() : discID(0) {}
Match() {}
Match(const char *g, discid_t d, const char *a, const char *t) :
discGenre(g), discID(d), artist(a), title(t)
{}
Expand All @@ -36,12 +36,12 @@ struct Cddb
// CDDB query results
struct Matches
{
discid_t discID; // discID of query
bool isExact;
using match_t = QVector< Match >;
match_t matches;
discid_t discID { 0 }; // discID of query
bool isExact { false };
using match_t = QVector< Match >;
match_t matches;

Matches() : discID(0), isExact(false) {}
Matches() {}
};

struct Msf
Expand All @@ -65,10 +65,10 @@ struct Cddb
QString artist;
QString title;
QString genre; // the genre from the DGENRE= item
int year;
int year { 0 };
QString submitter;
int rev;
bool isCompilation;
int rev { 1 };
bool isCompilation { false };
using track_t = QVector< Track >;
track_t tracks;
QString extd;
Expand All @@ -77,7 +77,7 @@ struct Cddb
Toc toc;

Album(discid_t d = 0, const char* g = nullptr) :
discGenre(g), discID(d), year(0), rev(1), isCompilation(false) {}
discGenre(g), discID(d) {}

explicit Album(const QString& s) { *this = s; }

Expand Down
8 changes: 5 additions & 3 deletions mythplugins/mythmusic/mythmusic/polygon.h
Expand Up @@ -7,10 +7,12 @@ template<typename Pixel>
class Bitmap
{
public:
int width, height, extra;
Pixel *data;
int width { 0 };
int height { 0 };
int extra;
Pixel *data { nullptr };

explicit Bitmap(int e = 0) : width(0), height(0), extra(e), data(nullptr) { }
explicit Bitmap(int e = 0) : extra(e) {}
~Bitmap() { delete[] data; }

void size(int w,int h)
Expand Down
16 changes: 7 additions & 9 deletions mythplugins/mythmusic/mythmusic/remoteavformatcontext.h
Expand Up @@ -18,9 +18,7 @@ extern "C" {
class RemoteAVFormatContext
{
public:
explicit RemoteAVFormatContext(const QString &filename = "") :
m_inputFC(nullptr), m_inputIsRemote(false), m_isOpen(false),
m_rf(nullptr), m_byteIOContext(nullptr), m_buffer(nullptr)
explicit RemoteAVFormatContext(const QString &filename = "")
{ if (!filename.isEmpty()) Open(filename); }

~RemoteAVFormatContext()
Expand Down Expand Up @@ -152,11 +150,11 @@ class RemoteAVFormatContext
}

private:
AVFormatContext *m_inputFC;
bool m_inputIsRemote;
bool m_isOpen;
RemoteFile *m_rf;
AVIOContext *m_byteIOContext;
unsigned char *m_buffer;
AVFormatContext *m_inputFC { nullptr };
bool m_inputIsRemote { false };
bool m_isOpen { false };
RemoteFile *m_rf { nullptr };
AVIOContext *m_byteIOContext { nullptr };
unsigned char *m_buffer { nullptr };
};
#endif // REMOTEAVFORMATCONTEXT_H
32 changes: 13 additions & 19 deletions mythplugins/mythzoneminder/mythzoneminder/zmdefines.h
Expand Up @@ -40,7 +40,7 @@ class Event
{
}

Event() : m_monitorID(-1), m_eventID(-1) {}
Event() = default;

int monitorID(void) const { return m_monitorID; }

Expand Down Expand Up @@ -68,8 +68,8 @@ class Event
QString length(void) const { return m_length; }

private:
int m_monitorID;
int m_eventID;
int m_monitorID { -1 };
int m_eventID { -1 };
QString m_eventName;
QString m_monitorName;
QString m_length;
Expand Down Expand Up @@ -98,34 +98,28 @@ struct Frame
class Monitor
{
public:
Monitor() :
id(0), enabled(false), events(0),
width(0), height(0), bytes_per_pixel(0),
showNotifications(false), state(IDLE),
previousState(IDLE)
{
}
Monitor() = default;

public:
// used by console view
int id;
int id { 0 };
QString name;
QString type;
QString function;
bool enabled;
bool enabled { false };
QString device;
QString zmcStatus;
QString zmaStatus;
int events;
int events { 0 };
// used by live view
QString status;
int width;
int height;
int bytes_per_pixel;
int width { 0 };
int height { 0 };
int bytes_per_pixel { 0 };
// used by the alarm notiftications
bool showNotifications;
State state;
State previousState;
bool showNotifications { false };
State state { IDLE };
State previousState { IDLE };
};

Q_DECLARE_METATYPE(Monitor *)
Expand Down
11 changes: 5 additions & 6 deletions mythtv/libs/libmyth/programinfo.h
Expand Up @@ -665,14 +665,13 @@ class MPUBLIC ProgramInfo
// Get/set all markup
struct MarkupEntry
{
int type; // MarkTypes
uint64_t frame;
uint64_t data;
bool isDataNull;
int type { -1 }; // MarkTypes
uint64_t frame { 0 };
uint64_t data { 0 };
bool isDataNull { true };
MarkupEntry(int t, uint64_t f, uint64_t d, bool n)
: type(t), frame(f), data(d), isDataNull(n) {}
MarkupEntry(void)
: type(-1), frame(0), data(0), isDataNull(true) {}
MarkupEntry(void) = default;
};
void QueryMarkup(QVector<MarkupEntry> &mapMark,
QVector<MarkupEntry> &mapSeek) const;
Expand Down
9 changes: 0 additions & 9 deletions mythtv/libs/libmythbase/dbutil.cpp
Expand Up @@ -27,15 +27,6 @@

const int DBUtil::kUnknownVersionNumber = INT_MIN;

/** \fn DBUtil::DBUtil(void)
* \brief Constructs the DBUtil object.
*/
DBUtil::DBUtil(void)
: m_versionMajor(-1), m_versionMinor(-1),
m_versionPoint(-1)
{
}

/** \fn DBUtil::GetDBMSVersion(void)
* \brief Returns the QString version name of the DBMS or QString() in
* the event of an error.
Expand Down
11 changes: 7 additions & 4 deletions mythtv/libs/libmythbase/dbutil.h
Expand Up @@ -30,7 +30,10 @@ enum MythDBBackupStatus
class MBASE_PUBLIC DBUtil
{
public:
DBUtil();
/** \fn DBUtil::DBUtil(void)
* \brief Constructs the DBUtil object.
*/
DBUtil() = default;
~DBUtil() = default;

QString GetDBMSVersion(void);
Expand Down Expand Up @@ -74,9 +77,9 @@ class MBASE_PUBLIC DBUtil

QString m_versionString;

int m_versionMajor;
int m_versionMinor;
int m_versionPoint;
int m_versionMajor { -1 };
int m_versionMinor { -1 };
int m_versionPoint { -1 };

};

Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/housekeeper.cpp
Expand Up @@ -565,7 +565,7 @@ void HouseKeepingThread::run(void)
* Tasks cannot be removed from the housekeeper once added.
*
*/
HouseKeeper::HouseKeeper(void) : m_timer(nullptr)
HouseKeeper::HouseKeeper(void)
{
m_timer = new QTimer(this);
connect(m_timer, SIGNAL(timeout()), this, SLOT(Run()));
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/housekeeper.h
Expand Up @@ -164,7 +164,7 @@ class MBASE_PUBLIC HouseKeeper : public QObject
void Run(void);

private:
QTimer *m_timer;
QTimer *m_timer { nullptr };

QQueue<HouseKeeperTask*> m_taskQueue;
QMutex m_queueLock;
Expand Down
13 changes: 10 additions & 3 deletions mythtv/libs/libmythfreemheg/BaseClasses.h
Expand Up @@ -255,12 +255,19 @@ class MHGenericContentRef: public MHGenericBase
class MHParameter
{
public:
MHParameter(): m_Type(P_Null) {}
MHParameter() {}
void Initialise(MHParseNode *p, MHEngine *engine);
void PrintMe(FILE *fd, int nTabs) const;
MHObjectRef *GetReference(); // Get an indirect reference.

enum ParamTypes { P_Int, P_Bool, P_String, P_ObjRef, P_ContentRef, P_Null } m_Type; // Null is used when this is optional
enum ParamTypes {
P_Int,
P_Bool,
P_String,
P_ObjRef,
P_ContentRef,
P_Null
} m_Type { P_Null }; // Null is used when this is optional

MHGenericInteger m_IntVal;
MHGenericBoolean m_BoolVal;
Expand All @@ -275,7 +282,7 @@ class MHUnion
public:
MHUnion() = default;
MHUnion(int nVal) : m_Type(U_Int), m_nIntVal(nVal) {}
MHUnion(bool fVal) : m_Type(U_Bool), m_nIntVal(0), m_fBoolVal(fVal) {}
MHUnion(bool fVal) : m_Type(U_Bool), m_fBoolVal(fVal) {}
MHUnion(const MHOctetString &strVal) : m_Type(U_String) { m_StrVal.Copy(strVal); }
MHUnion(const MHObjectRef &objVal) : m_Type(U_ObjRef) { m_ObjRefVal.Copy(objVal); };
MHUnion(const MHContentRef &cnVal) : m_Type(U_ContentRef) { m_ContentRefVal.Copy(cnVal); }
Expand Down
12 changes: 8 additions & 4 deletions mythtv/libs/libmythfreemheg/Groups.h
Expand Up @@ -173,28 +173,32 @@ class MHQuit: public MHElemAction
class MHSendEvent: public MHElemAction
{
public:
MHSendEvent(): MHElemAction(":SendEvent"), m_EventType(EventIsAvailable) {}
MHSendEvent(): MHElemAction(":SendEvent") {}
void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
void Perform(MHEngine *engine) override; // MHElemAction
void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
protected:
MHGenericObjectRef m_EventSource; // Event source
enum EventType m_EventType; // Event type
enum EventType m_EventType { EventIsAvailable }; // Event type
MHParameter m_EventData; // Optional - Null means not specified. Can only be bool, int or string.
};

class MHSetTimer: public MHElemAction
{
public:
MHSetTimer(): MHElemAction(":SetTimer"), m_TimerType(ST_NoNewTimer) {}
MHSetTimer(): MHElemAction(":SetTimer") {}
void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
void Perform(MHEngine *engine) override; // MHElemAction
protected:
void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
MHGenericInteger m_TimerId;
// A new timer may not be specified in which case this cancels the timer.
// If the timer is specified the "absolute" flag is optional.
enum { ST_NoNewTimer, ST_TimerAbsolute, ST_TimerRelative } m_TimerType;
enum {
ST_NoNewTimer,
ST_TimerAbsolute,
ST_TimerRelative
} m_TimerType { ST_NoNewTimer };
MHGenericInteger m_TimerValue;
MHGenericBoolean m_AbsFlag;
};
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythfreemheg/Variables.h
Expand Up @@ -164,12 +164,12 @@ class MHSetVariable: public MHElemAction
class MHTestVariable: public MHElemAction
{
public:
MHTestVariable(): MHElemAction(":TestVariable"), m_nOperator(0) {}
MHTestVariable(): MHElemAction(":TestVariable") {}
void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
void Perform(MHEngine *engine) override; // MHElemAction
protected:
void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
int m_nOperator;
int m_nOperator {0};
MHParameter m_Comparison; // Value to compare with.
};

Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythfreemheg/freemheg.h
Expand Up @@ -78,13 +78,13 @@ class MHRgba
public:
MHRgba(int red, int green, int blue, int alpha):
m_red(red), m_green(green), m_blue(blue), m_alpha(alpha) {};
MHRgba(): m_red(0), m_green(0), m_blue(0), m_alpha(0) {};
MHRgba() = default;
int red() const { return m_red; }
int green() const { return m_green; }
int blue() const { return m_blue; }
int alpha() const { return m_alpha; }
private:
unsigned char m_red, m_green, m_blue, m_alpha;
unsigned char m_red{0}, m_green{0}, m_blue{0}, m_alpha{0};
};

// This abstract class provides operations that the surrounding context must provide
Expand Down
7 changes: 1 addition & 6 deletions mythtv/libs/libmythfreesurround/freesurround.cpp
Expand Up @@ -131,12 +131,7 @@ void FreeSurround::SetParams()
FreeSurround::fsurround_params::fsurround_params(int32_t center_width,
int32_t dimension) :
center_width(center_width),
dimension(dimension),
coeff_a(0.8165),coeff_b(0.5774),
phasemode(0),
steering(1),
front_sep(100),
rear_sep(100)
dimension(dimension)
{
}

Expand Down
10 changes: 6 additions & 4 deletions mythtv/libs/libmythfreesurround/freesurround.h
Expand Up @@ -63,10 +63,12 @@ class FreeSurround
struct fsurround_params {
int32_t center_width; // presence of the center channel
int32_t dimension; // dimension
float coeff_a,coeff_b; // surround mixing coefficients
int32_t phasemode; // phase shifting mode
int32_t steering; // steering mode (0=simple, 1=linear)
int32_t front_sep, rear_sep; // front/rear stereo separation
float coeff_a { 0.8165 }; // surround mixing coefficients
float coeff_b { 0.5774 }; // surround mixing coefficients
int32_t phasemode { 0 }; // phase shifting mode
int32_t steering { 1 }; // steering mode (0=simple, 1=linear)
int32_t front_sep { 100 }; // front stereo separation
int32_t rear_sep { 100 }; // rear stereo separation
// (default) constructor
fsurround_params(int32_t center_width=100, int32_t dimension=0);
} m_params;
Expand Down

0 comments on commit 7a41a97

Please sign in to comment.