Skip to content

Commit

Permalink
tidy: Convert member functions to static if they don't use "this". (l…
Browse files Browse the repository at this point in the history
…ibmythtv/libmythui)

The clang-tidy readability "convert to static" checker pointed out a
large number of places where a member function doesn't reference the
current object, and thus doesn't need to be provided with a "this"
variable that points to an object.  These function should all be
declared as static, instead of as const.  Declaring a function as
"const" is a statement that it won't modify the object, but it still
possible for the function to somehow affect it.  A function declared
"static" doesn't receive a pointer to the object and so can't possibly
modify it.  Changes made by the clang-tidy program.

https://clang.llvm.https://clang.llvm.org/extra/clang-tidy/checks/readability-convert-member-functions-to-static.html
  • Loading branch information
linuxdude42 committed Nov 23, 2019
1 parent 147e8d8 commit ba243e2
Show file tree
Hide file tree
Showing 66 changed files with 203 additions and 201 deletions.
2 changes: 1 addition & 1 deletion mythtv/libs/libmythmetadata/metadatafactory.h
Expand Up @@ -125,7 +125,7 @@ class META_PUBLIC MetadataFactory : public QObject
m_imagedownload->isRunning() ||
m_videoscanner->isRunning(); };

bool VideoGrabbersFunctional();
static bool VideoGrabbersFunctional();

private:

Expand Down
12 changes: 6 additions & 6 deletions mythtv/libs/libmythtv/AirPlay/mythairplayserver.h
Expand Up @@ -89,12 +89,12 @@ class MTV_PUBLIC MythAirplayServer : public ServerPool
~MythAirplayServer(void) override;
void Teardown(void);
void HandleResponse(APHTTPRequest *req, QTcpSocket *socket);
QByteArray StatusToString(int status);
QString eventToString(AirplayEvent event);
void GetPlayerStatus(bool &playing, float &speed,
double &position, double &duration,
QString &pathname);
QString GetMacAddress();
static QByteArray StatusToString(int status);
static QString eventToString(AirplayEvent event);
static void GetPlayerStatus(bool &playing, float &speed,
double &position, double &duration,
QString &pathname);
static QString GetMacAddress();
bool SendReverseEvent(QByteArray &session, AirplayEvent event);
void SendResponse(QTcpSocket *socket,
int status, const QByteArray& header,
Expand Down
14 changes: 7 additions & 7 deletions mythtv/libs/libmythtv/AirPlay/mythraopconnection.h
Expand Up @@ -79,12 +79,12 @@ class MTV_PUBLIC MythRAOPConnection : public QObject
void ResetAudio(void);
void ProcessRequest(const QStringList &header,
const QByteArray &content);
void FinishResponse(_NetStream *stream, QTcpSocket *socket,
QString &option, QString &cseq, QString &responseData);
static void FinishResponse(_NetStream *stream, QTcpSocket *socket,
QString &option, QString &cseq, QString &responseData);
void FinishAuthenticationResponse(_NetStream *stream, QTcpSocket *socket,
QString &cseq);

RawHash FindTags(const QStringList &lines);
static RawHash FindTags(const QStringList &lines);
bool CreateDecoder(void);
void DestroyDecoder(void);
bool OpenAudioDevice(void);
Expand All @@ -96,16 +96,16 @@ class MTV_PUBLIC MythRAOPConnection : public QObject
// time sync
void SendTimeRequest(void);
void ProcessTimeResponse(const QByteArray &buf);
uint64_t NTPToLocal(uint32_t sec, uint32_t ticks);
static uint64_t NTPToLocal(uint32_t sec, uint32_t ticks);

// incoming data packet
bool GetPacketType(const QByteArray &buf, uint8_t &type,
static bool GetPacketType(const QByteArray &buf, uint8_t &type,
uint16_t &seq, uint64_t &timestamp);

// utility functions
int64_t AudioCardLatency(void);
QStringList splitLines(const QByteArray &lines);
QString stringFromSeconds(int timeInSeconds);
static QStringList splitLines(const QByteArray &lines);
static QString stringFromSeconds(int timeInSeconds);
uint64_t framesToMs(uint64_t frames);

// notification functions
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/Bluray/bdringbuffer.cpp
Expand Up @@ -1481,7 +1481,7 @@ bool BDRingBuffer::IsInStillFrame(void) const
* \param streamCount Number of streams in the array
* \return Pointer to the matching stream if found, otherwise nullptr.
*/
const BLURAY_STREAM_INFO* BDRingBuffer::FindStream(int streamid, BLURAY_STREAM_INFO* streams, int streamCount) const
const BLURAY_STREAM_INFO* BDRingBuffer::FindStream(int streamid, BLURAY_STREAM_INFO* streams, int streamCount)
{
const BLURAY_STREAM_INFO* stream = nullptr;

Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/Bluray/bdringbuffer.h
Expand Up @@ -161,7 +161,7 @@ class MTV_PUBLIC BDRingBuffer : public RingBuffer
bool HandleBDEvents(void);
void HandleBDEvent(BD_EVENT &event);

const BLURAY_STREAM_INFO* FindStream(int streamid, BLURAY_STREAM_INFO* streams, int streamCount) const;
static const BLURAY_STREAM_INFO* FindStream(int streamid, BLURAY_STREAM_INFO* streams, int streamCount);


typedef enum
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/DVD/avformatdecoderdvd.h
Expand Up @@ -36,7 +36,7 @@ class AvFormatDecoderDVD : public AvFormatDecoder

void CheckContext(int64_t pts);
void ReleaseLastVideoPkt();
void ReleaseContext(MythDVDContext *&context);
static void ReleaseContext(MythDVDContext *&context);

long long DVDFindPosition(long long desiredFrame);

Expand Down
12 changes: 6 additions & 6 deletions mythtv/libs/libmythtv/DVD/dvdringbuffer.h
Expand Up @@ -295,18 +295,18 @@ class MTV_PUBLIC DVDRingBuffer : public RingBuffer
long long Seek(long long time);

void ClearChapterCache(void);
uint ConvertLangCode(uint16_t code);
static uint ConvertLangCode(uint16_t code);
void SelectDefaultButton(void);
void WaitForPlayer(void);

int get_nibble(const uint8_t *buf, int nibble_offset);
int decode_rle(uint8_t *bitmap, int linesize, int w, int h,
static int get_nibble(const uint8_t *buf, int nibble_offset);
static int decode_rle(uint8_t *bitmap, int linesize, int w, int h,
const uint8_t *buf, int nibble_offset, int buf_size);
void guess_palette(uint32_t *rgba_palette,const uint8_t *palette,
const uint8_t *alpha);
int is_transp(const uint8_t *buf, int pitch, int n,
const uint8_t *transp_color);
int find_smallest_bounding_rectangle(AVSubtitle *s);
static int is_transp(const uint8_t *buf, int pitch, int n,
const uint8_t *transp_color);
static int find_smallest_bounding_rectangle(AVSubtitle *s);
};

#endif // DVD_RING_BUFFER_H_
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/HLS/httplivestream.h
Expand Up @@ -68,7 +68,7 @@ class MTV_PUBLIC HTTPLiveStream
bool UpdateStatusMessage(const QString& message);
bool UpdatePercentComplete(int percent);

QString StatusToString(HTTPLiveStreamStatus status);
static QString StatusToString(HTTPLiveStreamStatus status);

bool CheckStop(void);

Expand Down
22 changes: 11 additions & 11 deletions mythtv/libs/libmythtv/HLS/httplivestreambuffer.cpp
Expand Up @@ -1429,7 +1429,7 @@ class PlaylistWorker : public MThread
return RET_OK;
}

int UpdatePlaylist(HLSStream *hls_new, HLSStream *hls)
static int UpdatePlaylist(HLSStream *hls_new, HLSStream *hls)
{
int count = hls_new->NumSegments();

Expand Down Expand Up @@ -1749,7 +1749,7 @@ bool HLSRingBuffer::TestForHTTPLiveStreaming(const QString &filename)
}

/* Parsing */
QString HLSRingBuffer::ParseAttributes(const QString &line, const char *attr) const
QString HLSRingBuffer::ParseAttributes(const QString &line, const char *attr)
{
int p = line.indexOf(QLatin1String(":"));
if (p < 0)
Expand All @@ -1775,7 +1775,7 @@ QString HLSRingBuffer::ParseAttributes(const QString &line, const char *attr) co
* Return the decimal argument in a line of type: blah:\<decimal\>
* presence of value \<decimal\> is compulsory or it will return RET_ERROR
*/
int HLSRingBuffer::ParseDecimalValue(const QString &line, int &target) const
int HLSRingBuffer::ParseDecimalValue(const QString &line, int &target)
{
int p = line.indexOf(QLatin1String(":"));
if (p < 0)
Expand All @@ -1789,7 +1789,7 @@ int HLSRingBuffer::ParseDecimalValue(const QString &line, int &target) const
}

int HLSRingBuffer::ParseSegmentInformation(const HLSStream *hls, const QString &line,
int &duration, QString &title) const
int &duration, QString &title)
{
/*
* #EXTINF:<duration>,<title>
Expand Down Expand Up @@ -1846,7 +1846,7 @@ int HLSRingBuffer::ParseSegmentInformation(const HLSStream *hls, const QString &
return RET_OK;
}

int HLSRingBuffer::ParseTargetDuration(HLSStream *hls, const QString &line) const
int HLSRingBuffer::ParseTargetDuration(HLSStream *hls, const QString &line)
{
/*
* #EXT-X-TARGETDURATION:<s>
Expand Down Expand Up @@ -1908,7 +1908,7 @@ HLSStream *HLSRingBuffer::ParseStreamInformation(const QString &line, const QStr
return new HLSStream(id, bw, psz_uri);
}

int HLSRingBuffer::ParseMediaSequence(HLSStream *hls, const QString &line) const
int HLSRingBuffer::ParseMediaSequence(HLSStream *hls, const QString &line)
{
/*
* #EXT-X-MEDIA-SEQUENCE:<number>
Expand Down Expand Up @@ -2021,7 +2021,7 @@ int HLSRingBuffer::ParseKey(HLSStream *hls, const QString &line)
return err;
}

int HLSRingBuffer::ParseProgramDateTime(HLSStream */*hls*/, const QString &line) const
int HLSRingBuffer::ParseProgramDateTime(HLSStream */*hls*/, const QString &line)
{
/*
* #EXT-X-PROGRAM-DATE-TIME:<YYYY-MM-DDThh:mm:ssZ>
Expand All @@ -2032,7 +2032,7 @@ int HLSRingBuffer::ParseProgramDateTime(HLSStream */*hls*/, const QString &line)
return RET_OK;
}

int HLSRingBuffer::ParseAllowCache(HLSStream *hls, const QString &line) const
int HLSRingBuffer::ParseAllowCache(HLSStream *hls, const QString &line)
{
/*
* The EXT-X-ALLOW-CACHE tag indicates whether the client MAY or MUST
Expand All @@ -2056,7 +2056,7 @@ int HLSRingBuffer::ParseAllowCache(HLSStream *hls, const QString &line) const
return RET_OK;
}

int HLSRingBuffer::ParseVersion(const QString &line, int &version) const
int HLSRingBuffer::ParseVersion(const QString &line, int &version)
{
/*
* The EXT-X-VERSION tag indicates the compatibility version of the
Expand Down Expand Up @@ -2087,7 +2087,7 @@ int HLSRingBuffer::ParseVersion(const QString &line, int &version) const
return RET_OK;
}

int HLSRingBuffer::ParseEndList(HLSStream *hls) const
int HLSRingBuffer::ParseEndList(HLSStream *hls)
{
/*
* The EXT-X-ENDLIST tag indicates that no more media files will be
Expand All @@ -2099,7 +2099,7 @@ int HLSRingBuffer::ParseEndList(HLSStream *hls) const
return RET_OK;
}

int HLSRingBuffer::ParseDiscontinuity(HLSStream */*hls*/, const QString &line) const
int HLSRingBuffer::ParseDiscontinuity(HLSStream */*hls*/, const QString &line)
{
/* Not handled, never seen so far */
LOG(VB_PLAYBACK, LOG_DEBUG, LOC + QString("#EXT-X-DISCONTINUITY %1").arg(line));
Expand Down
22 changes: 11 additions & 11 deletions mythtv/libs/libmythtv/HLS/httplivestreambuffer.h
Expand Up @@ -76,19 +76,19 @@ class HLSRingBuffer : public RingBuffer
HLSStream *GetLastStream(const StreamsList *streams = nullptr) const;
HLSStream *FindStream(const HLSStream *hls_new, const StreamsList *streams = nullptr) const;
HLSStream *GetCurrentStream(void) const;
QString ParseAttributes(const QString &line, const char *attr) const;
int ParseDecimalValue(const QString &line, int &target) const;
int ParseSegmentInformation(const HLSStream *hls, const QString &line,
int &duration, QString &title) const;
int ParseTargetDuration(HLSStream *hls, const QString &line) const;
static QString ParseAttributes(const QString &line, const char *attr);
static int ParseDecimalValue(const QString &line, int &target);
static int ParseSegmentInformation(const HLSStream *hls, const QString &line,
int &duration, QString &title);
static int ParseTargetDuration(HLSStream *hls, const QString &line);
HLSStream *ParseStreamInformation(const QString &line, const QString &uri) const;
int ParseMediaSequence(HLSStream *hls, const QString &line) const;
static int ParseMediaSequence(HLSStream *hls, const QString &line);
int ParseKey(HLSStream *hls, const QString &line);
int ParseProgramDateTime(HLSStream *hls, const QString &line) const;
int ParseAllowCache(HLSStream *hls, const QString &line) const;
int ParseVersion(const QString &line, int &version) const;
int ParseEndList(HLSStream *hls) const;
int ParseDiscontinuity(HLSStream *hls, const QString &line) const;
static int ParseProgramDateTime(HLSStream *hls, const QString &line);
static int ParseAllowCache(HLSStream *hls, const QString &line);
static int ParseVersion(const QString &line, int &version);
static int ParseEndList(HLSStream *hls);
static int ParseDiscontinuity(HLSStream *hls, const QString &line);
int ParseM3U8(const QByteArray *buffer, StreamsList *streams = nullptr);
int Prefetch(int count);
void SanityCheck(const HLSStream *hls) const;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/avformatwriter.h
Expand Up @@ -40,7 +40,7 @@ class MTV_PUBLIC AVFormatWriter : public FileWriterBase
void Cleanup(void);

AVRational GetCodecTimeBase(void);
bool FindAudioFormat(AVCodecContext *ctx, AVCodec *c, AVSampleFormat format);
static bool FindAudioFormat(AVCodecContext *ctx, AVCodec *c, AVSampleFormat format);

AVFRingBuffer *m_avfRingBuffer {nullptr};
RingBuffer *m_ringBuffer {nullptr};
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/cc708window.cpp
Expand Up @@ -370,7 +370,7 @@ vector<CC708String*> CC708Window::GetStrings(void) const
return list;
}

void CC708Window::DisposeStrings(vector<CC708String*> &strings) const
void CC708Window::DisposeStrings(vector<CC708String*> &strings)
{
while (!strings.empty())
{
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/cc708window.h
Expand Up @@ -209,7 +209,7 @@ class MTV_PUBLIC CC708Window
}
CC708Character &GetCCChar(void) const;
vector<CC708String*> GetStrings(void) const;
void DisposeStrings(vector<CC708String*> &strings) const;
static void DisposeStrings(vector<CC708String*> &strings);
QColor GetFillColor(void) const
{
QColor fill = CC708CharacterAttribute::ConvertToQColor(m_fill_color);
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/channelscan/channelimporter.cpp
Expand Up @@ -885,7 +885,7 @@ void ChannelImporter::AddChanToCopy(
transport_copy.m_channels.push_back(chan);
}

void ChannelImporter::CleanupDuplicates(ScanDTVTransportList &transports) const
void ChannelImporter::CleanupDuplicates(ScanDTVTransportList &transports)
{
ScanDTVTransportList no_dups;

Expand Down Expand Up @@ -2147,4 +2147,4 @@ bool ChannelImporter::CheckChannelNumber(
ok = ok && !ChannelUtil::IsConflicting(
num, chan.m_source_id, chan.m_channel_id);
return ok;
}
}
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/channelscan/channelimporter.h
Expand Up @@ -138,9 +138,9 @@ class MTV_PUBLIC ChannelImporter
kChannelTypeLast = kChannelTypeConflictingLast,
} ChannelType;

QString toString(ChannelType type);
static QString toString(ChannelType type);

void CleanupDuplicates(ScanDTVTransportList &transports) const;
static void CleanupDuplicates(ScanDTVTransportList &transports);
void FilterServices(ScanDTVTransportList &transports) const;
ScanDTVTransportList GetDBTransports(
uint sourceid, ScanDTVTransportList&) const;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp
Expand Up @@ -357,7 +357,7 @@ bool ChannelScanSM::ScanExistingTransports(uint sourceid, bool follow_nit)
return m_scanning;
}

void ChannelScanSM::LogLines(const QString& string) const
void ChannelScanSM::LogLines(const QString& string)
{
QStringList lines = string.split('\n');
for (int i = 0; i < lines.size(); ++i)
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/channelscan/channelscan_sm.h
Expand Up @@ -172,7 +172,7 @@ class ChannelScanSM : public MPEGStreamListener,
bool Tune(const transport_scan_items_it_t &transport);
void ScanTransport(const transport_scan_items_it_t &transport);
DTVTunerType GuessDTVTunerType(DTVTunerType) const;
void LogLines(const QString& string) const;
static void LogLines(const QString& string);

/// \brief Updates Transport Scan progress bar
inline void UpdateScanPercentCompleted(void);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/channelsettings.h
Expand Up @@ -115,7 +115,7 @@ class MTV_PUBLIC ChannelOptionsCommon: public GroupSetting
uint default_sourceid, bool add_freqid);

public slots:
void onAirGuideChanged(bool);
static void onAirGuideChanged(bool);
void sourceChanged(const QString&);

protected:
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/decoders/avformatdecoder.h
Expand Up @@ -251,8 +251,8 @@ class AvFormatDecoder : public DecoderBase
bool GenerateDummyVideoFrames(void);
bool HasVideo(const AVFormatContext *ic);
float normalized_fps(AVStream *stream, AVCodecContext *enc);
void av_update_stream_timings_video(AVFormatContext *ic);
bool OpenAVCodec(AVCodecContext *avctx, const AVCodec *codec);
static void av_update_stream_timings_video(AVFormatContext *ic);
static bool OpenAVCodec(AVCodecContext *avctx, const AVCodec *codec);

void UpdateFramesPlayed(void) override; // DecoderBase
bool DoRewindSeek(long long desiredFrame) override; // DecoderBase
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/decoders/nuppeldecoder.h
Expand Up @@ -68,7 +68,7 @@ class NuppelDecoder : public DecoderBase

bool DecodeFrame(struct rtframeheader *frameheader,
unsigned char *lstrm, VideoFrame *frame);
bool isValidFrametype(char type);
static bool isValidFrametype(char type);

bool InitAVCodecVideo(int codec);
void CloseAVCodecVideo(void);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/deletemap.h
Expand Up @@ -32,7 +32,7 @@ class MTV_PUBLIC DeleteMap
void SetSeekAmount(float amount) { m_seekamount = amount; }

void UpdateOSD(uint64_t frame, double frame_rate, OSD *osd);
void UpdateOSD(int64_t timecode, OSD *osd);
static void UpdateOSD(int64_t timecode, OSD *osd);

bool IsEditing(void) const { return m_editing; }
void SetEditing(bool edit, OSD *osd = nullptr);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/diseqc.cpp
Expand Up @@ -2067,7 +2067,7 @@ bool DiSEqCDevRotor::ExecuteUSALS(const DiSEqCDevSettings& /*settings*/,
m_repeat, 2, cmd);
}

double DiSEqCDevRotor::CalculateAzimuth(double angle) const
double DiSEqCDevRotor::CalculateAzimuth(double angle)
{
// Azimuth Calculation references:
// http://engr.nmsu.edu/~etti/3_2/3_2e.html
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/diseqc.h
Expand Up @@ -50,8 +50,8 @@ class DiSEqCDevSettings
class DiSEqCDev
{
public:
DiSEqCDevTree* FindTree(uint cardid);
void InvalidateTrees(void);
static DiSEqCDevTree* FindTree(uint cardid);
static void InvalidateTrees(void);

protected:
static DiSEqCDevTrees s_trees;
Expand Down Expand Up @@ -345,7 +345,7 @@ class DiSEqCDevRotor : public DiSEqCDevDevice
double angle);
void StartRotorPositionTracking(double azimuth);

double CalculateAzimuth(double angle) const;
static double CalculateAzimuth(double angle);
double GetApproxAzimuth(void) const;

private:
Expand Down

0 comments on commit ba243e2

Please sign in to comment.