Skip to content

Commit

Permalink
tidy: Initialize member fields in constructor. (libs)
Browse files Browse the repository at this point in the history
The clang-tidy "member initialization" checker pointed out a number of
classes where member variables were not initialized in the
constructor.  Add initializers for these member variables.

https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.html
  • Loading branch information
linuxdude42 committed Jan 10, 2020
1 parent 3f37d48 commit 8e70b50
Show file tree
Hide file tree
Showing 64 changed files with 224 additions and 214 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Expand Up @@ -120,7 +120,7 @@ Checks: '-*,
-cppcoreguidelines-pro-type-const-cast,
# Bunch of warnings.... ,
-cppcoreguidelines-pro-type-cstyle-cast,
-cppcoreguidelines-pro-type-member-init,
cppcoreguidelines-pro-type-member-init,
-cppcoreguidelines-pro-type-reinterpret-cast,
# The qapplication.h header file includes a static_cast.
Expand Down
3 changes: 0 additions & 3 deletions mythtv/libs/libmyth/audio/audiooutputalsa.cpp
Expand Up @@ -33,9 +33,6 @@ using namespace std;
AudioOutputALSA::AudioOutputALSA(const AudioSettings &settings) :
AudioOutputBase(settings)
{
m_mixer.handle = nullptr;
m_mixer.elem = nullptr;

// Set everything up
if (m_passthruDevice == "auto")
{
Expand Down
10 changes: 5 additions & 5 deletions mythtv/libs/libmyth/audio/audiooutputalsa.h
Expand Up @@ -51,11 +51,11 @@ class AudioOutputALSA : public AudioOutputBase
struct {
QString device;
QString control;
snd_mixer_t* handle;
snd_mixer_elem_t* elem;
long volmin;
long volmax;
long volrange;
snd_mixer_t* handle { nullptr };
snd_mixer_elem_t* elem { nullptr };
long volmin { 0L };
long volmax { 0L };
long volrange { 0L };
} m_mixer;

};
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmyth/audio/audiooutputjack.h
Expand Up @@ -58,8 +58,8 @@ class AudioOutputJACK : public AudioOutputBase
void DeinterleaveAudio(const float *aubuf, float **bufs,
int nframes, const int* channel_volumes);

jack_port_t *m_ports[JACK_CHANNELS_MAX];
int m_chanVolumes[JACK_CHANNELS_MAX];
jack_port_t *m_ports[JACK_CHANNELS_MAX] {};
int m_chanVolumes[JACK_CHANNELS_MAX] {};
jack_client_t *m_client {nullptr};
jack_client_t *m_staleClient {nullptr};
int m_jackLatency {0};
Expand Down
34 changes: 17 additions & 17 deletions mythtv/libs/libmyth/audio/eldutils.h
Expand Up @@ -103,23 +103,23 @@ class MPUBLIC ELD
* ELD: EDID Like Data
*/
struct eld_data {
bool eld_valid;
int eld_size;
int baseline_len;
int eld_ver;
int cea_edid_ver;
char monitor_name[ELD_MAX_MNL + 1];
int manufacture_id;
int product_id;
uint64_t port_id;
uint64_t formats;
int support_hdcp;
int support_ai;
int conn_type;
int aud_synch_delay;
int spk_alloc;
int sad_count;
struct cea_sad sad[ELD_MAX_SAD];
bool eld_valid { false };
int eld_size { 0 };
int baseline_len { 0 };
int eld_ver { 0 };
int cea_edid_ver { 0 };
char monitor_name[ELD_MAX_MNL + 1] {};
int manufacture_id { 0 };
int product_id { 0 };
uint64_t port_id { 0 };
uint64_t formats { 0 };
int support_hdcp { 0 };
int support_ai { 0 };
int conn_type { 0 };
int aud_synch_delay { 0 };
int spk_alloc { 0 };
int sad_count { 0 };
struct cea_sad sad[ELD_MAX_SAD] {};
eld_data() { memset(this, 0, sizeof(*this)); }
};
eld_data m_e;
Expand Down
7 changes: 5 additions & 2 deletions mythtv/libs/libmyth/mythmediamonitor.h
Expand Up @@ -13,10 +13,13 @@
#include "mythmedia.h"

/// Stores details of media handlers

// Adding member initializers caused compilation to fail with an error
// that it cannot convert a brace-enclosed initializer list to MHData.
struct MHData
{
void (*callback)(MythMediaDevice *mediadevice);
int MythMediaType;
void (*callback)(MythMediaDevice *mediadevice); // NOLINT(cppcoreguidelines-pro-type-member-init)
int MythMediaType; // NOLINT(cppcoreguidelines-pro-type-member-init)
QString destination;
QString description;
};
Expand Down
32 changes: 16 additions & 16 deletions mythtv/libs/libmyth/rssparse.h
Expand Up @@ -71,33 +71,33 @@ struct MRSSScene
struct MRSSEntry
{
QString URL;
qint64 Size;
qint64 Size {0};
QString Type;
QString Medium;
bool IsDefault;
bool IsDefault {false};
QString Expression;
int Bitrate;
double Framerate;
double SamplingRate;
int Channels;
int Duration;
int Width;
int Height;
int Bitrate {0};
double Framerate {0.0};
double SamplingRate {0.0};
int Channels {0};
int Duration {0};
int Width {0};
int Height {0};
QString Lang;
int Group;
int Group {0};
QString Rating;
QString RatingScheme;
QString Title;
QString Description;
QString Keywords;
QString CopyrightURL;
QString CopyrightText;
int RatingAverage;
int RatingCount;
int RatingMin;
int RatingMax;
int Views;
int Favs;
int RatingAverage {0};
int RatingCount {0};
int RatingMin {0};
int RatingMax {0};
int Views {0};
int Favs {0};
QString Tags;
QList<MRSSThumbnail> Thumbnails;
QList<MRSSCredit> Credits;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/mythcdrom.cpp
Expand Up @@ -186,7 +186,7 @@ MythCDROM::ImageType MythCDROM::inspectImage(const QString &path)
imageType = kDVD;
else
{
blockInput_t blockInput;
blockInput_t blockInput {};

blockInput.m_file = new RemoteFile(path); // Normally deleted via a call to udfread_close
blockInput.m_input.close = _def_close;
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythbase/mythdbcon.h
Expand Up @@ -89,9 +89,9 @@ class MBASE_PUBLIC MDBManager
/// \brief MSqlDatabase Info, used by MSqlQuery. Do not use directly.
struct MSqlQueryInfo
{
MSqlDatabase *db;
MSqlDatabase *db {nullptr};
QSqlDatabase qsqldb;
bool returnConnection;
bool returnConnection {false};
};

/// \brief typedef for a map of string -> string bindings for generic queries.
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythbase/signalhandling.cpp
Expand Up @@ -202,7 +202,7 @@ struct SignalInfo {

void SignalHandler::signalHandler(int signum, siginfo_t *info, void *context)
{
SignalInfo signalInfo;
SignalInfo signalInfo {};

(void)context;
signalInfo.m_signum = signum;
Expand Down Expand Up @@ -287,7 +287,7 @@ void SignalHandler::handleSignal(void)
#ifndef _WIN32
m_notifier->setEnabled(false);

SignalInfo signalInfo;
SignalInfo signalInfo {};
int ret = ::read(s_sigFd[1], &signalInfo, sizeof(SignalInfo));
bool infoComplete = (ret == sizeof(SignalInfo));
int signum = (infoComplete ? signalInfo.m_signum : 0);
Expand Down
8 changes: 4 additions & 4 deletions mythtv/libs/libmythbase/verbosedefs.h
Expand Up @@ -201,17 +201,17 @@ LOGLEVEL_POSTAMBLE
#ifndef _IMPLEMENT_VERBOSE
#ifdef __cplusplus
struct VerboseDef {
uint64_t mask;
uint64_t mask {0};
QString name;
bool additive;
bool additive {false};
QString helpText;
};
using VerboseMap = QMap<QString, VerboseDef *>;

struct LoglevelDef {
int value;
int value {LOG_UNKNOWN};
QString name;
char shortname;
char shortname {'-'};
};
using LoglevelMap = QMap<int, LoglevelDef *>;
using ComponentLogLevelMap = QMap<uint64_t, LogLevel_t>;
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythbase/zipentry_p.h
Expand Up @@ -60,10 +60,10 @@ class ZipEntryP

quint32 lhOffset; // Offset of the local header record for this entry
quint32 dataOffset; // Offset of the file data for this entry
unsigned char gpFlag[2]; // General purpose flag
unsigned char gpFlag[2] {}; // General purpose flag
quint16 compMethod; // Compression method
unsigned char modTime[2]; // Last modified time
unsigned char modDate[2]; // Last modified date
unsigned char modTime[2] {}; // Last modified time
unsigned char modDate[2] {}; // Last modified date
quint32 crc; // CRC32
quint32 szComp; // Compressed file size
quint32 szUncomp; // Uncompressed file size
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythfreemheg/BaseClasses.h
Expand Up @@ -128,7 +128,7 @@ class MHOctetString
void PrintMe(FILE *fd, int nTabs) const;

protected:
int m_nLength;
int m_nLength {0};
unsigned char *m_pChars {nullptr};
};

Expand Down Expand Up @@ -192,7 +192,7 @@ class MHGenericBase
{
public:
MHObjectRef *GetReference(); // Return the indirect reference or fail if it's direct
bool m_fIsDirect;
bool m_fIsDirect {false};
protected:
MHObjectRef m_Indirect;
};
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythfreemheg/Groups.h
Expand Up @@ -38,7 +38,7 @@ class MHVisible;
//
class MHTimer {
public:
int m_nTimerId;
int m_nTimerId {0};
QTime m_Time;
};

Expand Down
20 changes: 11 additions & 9 deletions mythtv/libs/libmythfreesurround/el_processor.cpp
Expand Up @@ -547,17 +547,19 @@ class decoder_impl {
std::vector<float> m_inbuf[2]; // the sliding input buffers
std::vector<float> m_outbuf[6]; // the sliding output buffers
// coefficients
float m_surroundHigh,m_surroundLow; // high and low surround mixing coefficient (e.g. 0.8165/0.5774)
float m_surroundBalance; // the xfs balance that follows from the coeffs
float m_surroundLevel; // gain for the surround channels (follows from the coeffs
float m_phaseOffsetL, m_phaseOffsetR;// phase shifts to be applied to the rear channels
float m_frontSeparation; // front stereo separation
float m_rearSeparation; // rear stereo separation
bool m_linearSteering; // whether the steering should be linear or not
float m_surroundHigh {0.0F}; // high surround mixing coefficient (e.g. 0.8165/0.5774)
float m_surroundLow {0.0F}; // low surround mixing coefficient (e.g. 0.8165/0.5774)
float m_surroundBalance {0.0F}; // the xfs balance that follows from the coeffs
float m_surroundLevel {0.0F}; // gain for the surround channels (follows from the coeffs
float m_phaseOffsetL {0.0F}; // phase shifts to be applied to the rear channels
float m_phaseOffsetR {0.0F}; // phase shifts to be applied to the rear channels
float m_frontSeparation {0.0F}; // front stereo separation
float m_rearSeparation {0.0F}; // rear stereo separation
bool m_linearSteering {false}; // whether the steering should be linear or not
cfloat m_a,m_b,m_c,m_d,m_e,m_f,m_g,m_h; // coefficients for the linear steering
int m_currentBuf; // specifies which buffer is 2nd half of input sliding buffer
float * m_inbufs[2]; // for passing back to driver
float * m_outbufs[6]; // for passing back to driver
float * m_inbufs[2] {}; // for passing back to driver
float * m_outbufs[6] {}; // for passing back to driver

friend class fsurround_decoder;
};
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythmetadata/dbaccess.h
Expand Up @@ -39,7 +39,7 @@ class META_PUBLIC MultiValue
public:
struct entry
{
int id;
int id {0};
using values_type = std::vector<long>;
values_type values;
};
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythmetadata/musicmetadata.h
Expand Up @@ -349,7 +349,7 @@ class META_PUBLIC MusicMetadata

LyricsData *m_lyricsData {nullptr};

IdType m_id;
IdType m_id {0};
QString m_filename; // file name as stored in the DB
QString m_hostname; // host where file is located as stored in the DB
QString m_actualFilename; // actual URL of the file if found
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythmetadata/videoscan.h
Expand Up @@ -78,7 +78,7 @@ class META_PUBLIC VideoScannerThread : public MThread

struct CheckStruct
{
bool check;
bool check {false};
QString host;
};

Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/AirPlay/mythraopconnection.h
Expand Up @@ -135,7 +135,7 @@ class MTV_PUBLIC MythRAOPConnection : public QObject
QMap<uint16_t,uint64_t> m_resends;
// crypto
QByteArray m_aesIV;
AES_KEY m_aesKey;
AES_KEY m_aesKey {};
static RSA *g_rsa;
static QString g_rsaLastError;
// audio out
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/HLS/httplivestreambuffer.cpp
Expand Up @@ -377,7 +377,7 @@ class HLSSegment
#endif

private:
int m_id; // unique sequence number
int m_id {0}; // unique sequence number
int m_duration {0}; // segment duration (seconds)
uint64_t m_bitrate {0}; // bitrate of segment's content (bits per second)
QString m_title; // human-readable informative title of the media segment
Expand Down Expand Up @@ -848,11 +848,11 @@ class HLSStream
#endif

private:
int m_id; // program id
int m_id {0}; // program id
int m_version {1}; // protocol version should be 1
int m_startsequence {0}; // media starting sequence number
int m_targetduration {-1}; // maximum duration per segment (s)
uint64_t m_bitrate; // bitrate of stream content (bits per second)
uint64_t m_bitrate {0LL}; // bitrate of stream content (bits per second)
uint64_t m_size {0LL}; // stream length is calculated by taking the sum
// foreach segment of (segment->duration * hls->bitrate/8)
int64_t m_duration {0LL}; // duration of the stream in seconds
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/cc708decoder.h
Expand Up @@ -38,9 +38,9 @@ class CC708Decoder
void services(uint seconds, bool seen[64]) const;

private:
CaptionPacket m_partialPacket;
CC708Reader *m_reader {nullptr};
time_t m_lastSeen[64];
CaptionPacket m_partialPacket {};
CC708Reader *m_reader {nullptr};
time_t m_lastSeen[64] {};
};

#endif // CC708DECODER_H_
16 changes: 8 additions & 8 deletions mythtv/libs/libmythtv/cc708reader.h
Expand Up @@ -75,18 +75,18 @@ class CC708Reader
short* unicode_string, short len);

// Data
unsigned char *m_buf[k708MaxServices];
uint m_bufAlloc[k708MaxServices];
uint m_bufSize[k708MaxServices];
bool m_delayed[k708MaxServices];
unsigned char *m_buf[k708MaxServices] {};
uint m_bufAlloc[k708MaxServices] {};
uint m_bufSize[k708MaxServices] {};
bool m_delayed[k708MaxServices] {};

short *m_tempStr[k708MaxServices];
int m_tempStrAlloc[k708MaxServices];
int m_tempStrSize[k708MaxServices];
short *m_tempStr[k708MaxServices] {};
int m_tempStrAlloc[k708MaxServices] {};
int m_tempStrSize[k708MaxServices] {};

int m_currentService {1};
CC708Service CC708services[k708MaxServices];
int CC708DelayedDeletes[k708MaxServices];
int CC708DelayedDeletes[k708MaxServices] {};

MythPlayer *m_parent {nullptr};
bool m_enabled {false};
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/cc708window.h
Expand Up @@ -177,8 +177,8 @@ class CC708Character
class CC708String
{
public:
uint m_x;
uint m_y;
uint m_x {0};
uint m_y {0};
QString m_str;
CC708CharacterAttribute m_attr;
};
Expand Down

0 comments on commit 8e70b50

Please sign in to comment.