Skip to content

Commit

Permalink
Simplify structure declarations.
Browse files Browse the repository at this point in the history
Many structures in the code are defined in the form:

    typedef struct A {...} AA;

In C++ this is redundant, creating both the names A and AA that can be
used interchangeably.  Simplify these to the form:

    struct AA {...};

These changes were inspired by the clang-tidy "modernize use using"
checker which looks to replace the use of the "typedef" keyword with
the newer "using" keyword.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-using.html
  • Loading branch information
linuxdude42 committed Nov 29, 2019
1 parent 9535a9d commit 1df26a1
Show file tree
Hide file tree
Showing 50 changed files with 156 additions and 163 deletions.
16 changes: 8 additions & 8 deletions mythplugins/mytharchive/mytharchive/archiveutil.h
Expand Up @@ -23,32 +23,32 @@ enum ARCHIVEDESTINATION

Q_DECLARE_METATYPE (ARCHIVEDESTINATION);

typedef struct ArchiveDestination
struct ArchiveDestination
{
ARCHIVEDESTINATION type;
const char *name;
const char *description;
int64_t freeSpace;
}_ArchiveDestination;
};

extern struct ArchiveDestination ArchiveDestinations[];
extern int ArchiveDestinationsCount;

typedef struct
struct EncoderProfile
{
QString name;
QString description;
float bitrate;
} EncoderProfile;
};

typedef struct ThumbImage
struct ThumbImage
{
QString caption;
QString filename;
qint64 frame;
} ThumbImage;
};

typedef struct
struct ArchiveItem
{
int id;
QString type;
Expand All @@ -70,7 +70,7 @@ typedef struct
bool useCutlist;
bool editedDetails;
QList<ThumbImage*> thumbList;
} ArchiveItem;
};

QString formatSize(int64_t sizeKB, int prec = 2);
QString getTempDirectory(bool showError = false);
Expand Down
4 changes: 2 additions & 2 deletions mythplugins/mytharchive/mytharchive/fileselector.h
Expand Up @@ -14,13 +14,13 @@
// mytharchive
#include "archiveutil.h"

typedef struct
struct FileData
{
bool directory;
bool selected;
QString filename;
int64_t size;
} FileData;
};

enum FSTYPE
{
Expand Down
8 changes: 4 additions & 4 deletions mythplugins/mytharchive/mytharchive/importnative.h
Expand Up @@ -17,15 +17,15 @@
// mytharchive
#include "fileselector.h"

typedef struct
struct FileInfo
{
bool directory;
bool selected;
QString filename;
int64_t size;
} FileInfo;
};

typedef struct
struct FileDetails
{
QString title;
QString subtitle;
Expand All @@ -35,7 +35,7 @@ typedef struct
QString chanNo;
QString chanName;
QString callsign;
} FileDetails;
};


class MythUIText;
Expand Down
4 changes: 2 additions & 2 deletions mythplugins/mytharchive/mytharchive/thumbfinder.h
Expand Up @@ -19,11 +19,11 @@ extern "C" {
#include "remoteavformatcontext.h"
#include "mythavutil.h"

typedef struct SeekAmount
struct SeekAmount
{
QString name;
int amount;
} SeekAmount;
};

extern struct SeekAmount SeekAmounts[];
extern int SeekAmountsCount;
Expand Down
4 changes: 2 additions & 2 deletions mythplugins/mytharchive/mytharchive/videoselector.h
Expand Up @@ -23,7 +23,7 @@ class MythUIButton;
class MythUIButtonList;
class MythUIButtonListItem;

typedef struct
struct VideoInfo
{
int id;
QString title;
Expand All @@ -33,7 +33,7 @@ typedef struct
QString coverfile;
int parentalLevel;
uint64_t size;
} VideoInfo;
};

class VideoSelector : public MythScreenType
{
Expand Down
4 changes: 2 additions & 2 deletions mythplugins/mythmusic/mythmusic/cdrip.h
Expand Up @@ -45,13 +45,13 @@ class CDEjectorThread: public MThread
Ripper *m_parent {nullptr};
};

typedef struct
struct RipTrack
{
MusicMetadata *metadata;
bool active;
int length;
bool isNew;
} RipTrack;
};

Q_DECLARE_METATYPE(RipTrack *)

Expand Down
4 changes: 2 additions & 2 deletions mythplugins/mythmusic/mythmusic/importmusic.h
Expand Up @@ -21,12 +21,12 @@ class MythUIButtonList;
class MythUICheckBox;
class MythDialogBox;

typedef struct
struct TrackInfo
{
MusicMetadata *metadata;
bool isNewTune;
bool metadataHasChanged;
} TrackInfo;
};

class FileScannerThread: public MThread
{
Expand Down
4 changes: 2 additions & 2 deletions mythplugins/mythmusic/mythmusic/visualize.h
Expand Up @@ -245,7 +245,7 @@ class Piano : public VisualBase
#define PIANO_MIN_VOL -10
#define PIANO_KEYPRESS_TOO_LIGHT .2

typedef struct piano_key_data {
struct piano_key_data {
goertzel_data q1, q2, coeff, magnitude;
goertzel_data max_magnitude_seen;

Expand All @@ -256,7 +256,7 @@ typedef struct piano_key_data {
int samples_process_before_display_update;

bool is_black_note; // These are painted on top of white notes, and have different colouring
} piano_key_data;
};

public:
Piano();
Expand Down
24 changes: 12 additions & 12 deletions mythplugins/mythzoneminder/mythzmserver/zmserver.h
Expand Up @@ -69,7 +69,7 @@ enum State
};

// shared data for ZM version 1.24.x and 1.25.x
typedef struct
struct SharedData
{
int size;
bool valid;
Expand All @@ -89,10 +89,10 @@ typedef struct
int alarm_x;
int alarm_y;
char control_state[256];
} SharedData;
};

// shared data for ZM version 1.26.x
typedef struct
struct SharedData26
{
uint32_t size;
uint32_t last_write_index;
Expand Down Expand Up @@ -122,10 +122,10 @@ typedef struct
uint64_t extrapad2;
};
uint8_t control_state[256];
} SharedData26;
};

// shared data for ZM version 1.32.x
typedef struct
struct SharedData32
{
uint32_t size;
uint32_t last_write_index;
Expand Down Expand Up @@ -160,23 +160,23 @@ typedef struct
uint8_t control_state[256];

char alarm_cause[256];
} SharedData32;
};

enum TriggerState { TRIGGER_CANCEL, TRIGGER_ON, TRIGGER_OFF };

// Triggerdata for ZM version 1.24.x and 1.25.x
typedef struct
struct TriggerData
{
int size;
TriggerState trigger_state;
int trigger_score;
char trigger_cause[32];
char trigger_text[256];
char trigger_showtext[256];
} TriggerData;
};

// Triggerdata for ZM version 1.26.x and 1.32.x
typedef struct
struct TriggerData26
{
uint32_t size;
uint32_t trigger_state;
Expand All @@ -185,16 +185,16 @@ typedef struct
char trigger_cause[32];
char trigger_text[256];
char trigger_showtext[256];
} TriggerData26;
};

// VideoStoreData for ZM version 1.32.x
typedef struct
struct VideoStoreData
{
uint32_t size;
uint64_t current_event;
char event_file[4096];
timeval recording;
} VideoStoreData;
};

class MONITOR
{
Expand Down
4 changes: 2 additions & 2 deletions mythplugins/mythzoneminder/mythzoneminder/zmdefines.h
Expand Up @@ -89,11 +89,11 @@ enum State
};

// event frame details
typedef struct
struct Frame
{
QString type;
double delta;
} Frame;
};

class Monitor
{
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythbase/mythdbcon.h
Expand Up @@ -87,12 +87,12 @@ class MBASE_PUBLIC MDBManager
};

/// \brief MSqlDatabase Info, used by MSqlQuery. Do not use directly.
typedef struct _MSqlQueryInfo
struct MSqlQueryInfo
{
MSqlDatabase *db;
QSqlDatabase qsqldb;
bool returnConnection;
} MSqlQueryInfo;
};

/// \brief typedef for a map of string -> string bindings for generic queries.
typedef QMap<QString, QVariant> MSqlBindings;
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythbase/mythmiscutil.h
Expand Up @@ -95,10 +95,10 @@ inline void rdtsc(uint64_t &x)
QueryPerformanceCounter((LARGE_INTEGER*)(&x));
}
#else
typedef struct {
struct timing_ab_t {
uint a;
uint b;
} timing_ab_t;
};
inline void rdtsc(uint64_t &x)
{
timing_ab_t &y = (timing_ab_t&) x;
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythbase/mythsystemwindows.cpp
Expand Up @@ -43,11 +43,11 @@ if( (x) ) { \
(x) = nullptr; \
}

typedef struct
struct FDType_t
{
MythSystemLegacyWindows *ms;
int type;
} FDType_t;
};
typedef QMap<HANDLE, FDType_t*> FDMap_t;

/**********************************
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythmetadata/metadataimagedownload.h
Expand Up @@ -9,11 +9,11 @@
#include "mythmetaexp.h"
#include "metadatacommon.h"

typedef struct {
struct ThumbnailData {
QString title;
QVariant data;
QString url;
} ThumbnailData;
};

class META_PUBLIC ImageDLEvent : public QEvent
{
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/cc708decoder.h
Expand Up @@ -12,11 +12,11 @@

#ifndef __CC_CALLBACKS_H__
/** EIA-708-A closed caption packet */
typedef struct CaptionPacket
struct CaptionPacket
{
unsigned char data[128+16];
int size;
} CaptionPacket;
};
#endif

class CC708Reader;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/channelscan/multiplexsetting.cpp
Expand Up @@ -57,7 +57,7 @@ void MultiplexSetting::Load(void)
{
QString ChannelNumber =
QString("Freq %1").arg(query.value(3).toInt());
struct CHANLIST* curList = chanlists[0].list;
CHANLIST* curList = chanlists[0].list;
int totalChannels = chanlists[0].count;
int findFrequency = (query.value(3).toInt() / 1000) - 1750;
for (int x = 0 ; x < totalChannels ; ++x)
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/decoders/decoderbase.h
Expand Up @@ -282,12 +282,12 @@ class DecoderBase
long long GetLastFrameInPosMap(void) const;
unsigned long GetPositionMapSize(void) const;

typedef struct posmapentry
struct PosMapEntry
{
long long index; // frame or keyframe number
long long adjFrame; // keyFrameAdjustTable adjusted frame number
long long pos; // position in stream
} PosMapEntry;
};
long long GetKey(const PosMapEntry &entry) const;

MythPlayer *m_parent {nullptr};
Expand Down
5 changes: 2 additions & 3 deletions mythtv/libs/libmythtv/deletemap.h
Expand Up @@ -9,15 +9,14 @@
class OSD;
class PlayerContext;

typedef struct DeleteMapUndoEntry
struct DeleteMapUndoEntry
{
frm_dir_map_t m_deleteMap;
QString m_message; // how we got from previous map to this map
DeleteMapUndoEntry(const frm_dir_map_t &dm, const QString &msg)
: m_deleteMap(dm), m_message(msg) { }
DeleteMapUndoEntry(void) = default;

} DeleteMapUndoEntry;
};

class MTV_PUBLIC DeleteMap
{
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/diseqc.h
Expand Up @@ -203,7 +203,7 @@ class DiSEqCDevDevice
uint m_ordinal {0};
uint m_repeat {1};

typedef struct { QString name; uint value; } TypeTable;
struct TypeTable { QString name; uint value; };
static QString TableToString(uint type, const TypeTable *table);
static uint TableFromString(const QString &type,
const TypeTable *table);
Expand Down

0 comments on commit 1df26a1

Please sign in to comment.