Skip to content

Commit

Permalink
tidy: Remove redundant casting.
Browse files Browse the repository at this point in the history
This test "detects explicit type casting operations that involve the
same source and destination types, and subsequently recommend their
removal".

These changes were made by the clang-tidy program.

https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-casting.html
  • Loading branch information
linuxdude42 committed Mar 26, 2024
1 parent d04cc8a commit c2b1ece
Show file tree
Hide file tree
Showing 19 changed files with 55 additions and 55 deletions.
4 changes: 2 additions & 2 deletions mythplugins/mythmusic/mythmusic/musiccommon.cpp
Expand Up @@ -1144,7 +1144,7 @@ void MusicCommon::seek(std::chrono::seconds pos)
QString lcd_time_string = getTimeString(pos, m_maxTime);

// if the string is longer than the LCD width, remove all spaces
if (lcd_time_string.length() > (int)lcd->getLCDWidth())
if (lcd_time_string.length() > lcd->getLCDWidth())
lcd_time_string.remove(' ');

lcd->setMusicProgress(lcd_time_string, percent_heard);
Expand Down Expand Up @@ -1276,7 +1276,7 @@ void MusicCommon::customEvent(QEvent *event)
QString lcd_time_string = time_string;

// if the string is longer than the LCD width, remove all spaces
if (time_string.length() > (int)lcd->getLCDWidth())
if (time_string.length() > lcd->getLCDWidth())
lcd_time_string.remove(' ');

lcd->setMusicProgress(lcd_time_string, percent_heard);
Expand Down
10 changes: 5 additions & 5 deletions mythplugins/mythmusic/mythmusic/visualize.cpp
Expand Up @@ -1090,7 +1090,7 @@ bool Spectrogram::process(VisualNode */*node*/)
{
painter.drawText(m_scale.pixel(i) - 20, half - 220,
40, 40, Qt::AlignCenter,
QString("%1").arg(int(i / 12)));
QString("%1").arg((i / 12)));
}
}
painter.rotate(90); // frequency in Hz draws down
Expand All @@ -1109,7 +1109,7 @@ bool Spectrogram::process(VisualNode */*node*/)
painter.drawText(half + 100, -1 * now - 40,
80, 80, Qt::AlignVCenter|Qt::AlignLeft,
QString("%1%2").arg(m_scale.note(i))
.arg(int(i / 12)));
.arg((i / 12)));
}
prev = now;
}
Expand Down Expand Up @@ -1212,7 +1212,7 @@ bool Spectrogram::processUndisplayed(VisualNode *node)

left *= gain;
int mag = clamp(left, 255, 0);
int z = (int)(mag * 6);
int z = (mag * 6);
left > 255 ? painter.setPen(Qt::white) :
painter.setPen(qRgb(m_red[z], m_green[z], m_blue[z]));
if (m_history)
Expand All @@ -1237,7 +1237,7 @@ bool Spectrogram::processUndisplayed(VisualNode *node)

right *= gain; // copy of above, s/left/right/g
mag = clamp(right, 255, 0);
z = (int)(mag * 6);
z = (mag * 6);
right > 255 ? painter.setPen(Qt::white) :
painter.setPen(qRgb(m_red[z], m_green[z], m_blue[z]));
if (m_history)
Expand Down Expand Up @@ -1485,7 +1485,7 @@ bool Spectrum::processUndisplayed(VisualNode *node)
int prev = 0; // frequency index of previous pixel
float adjHeight = m_size.height() / 2.0;

for (int i = 0; (int)i < m_rectsL.size(); i++, w += m_analyzerBarWidth)
for (int i = 0; i < m_rectsL.size(); i++, w += m_analyzerBarWidth)
{
float magL = 0; // modified from Spectrogram
float magR = 0;
Expand Down
2 changes: 1 addition & 1 deletion mythplugins/mythnews/mythnews/mythnews.cpp
Expand Up @@ -718,7 +718,7 @@ QString MythNews::cleanText(const QString &text)
result.replace( kStartingSpaceRE, "\n");
// Remove any remaining HTML tags
static const QRegularExpression kRemoveHtmlRE(QRegularExpression("</?.+>"));
result.remove((const QRegularExpression&) kRemoveHtmlRE);
result.remove(kRemoveHtmlRE);
result = result.trimmed();

return result;
Expand Down
28 changes: 14 additions & 14 deletions mythtv/libs/libmythbase/test/test_logging/test_logging.cpp
Expand Up @@ -32,9 +32,9 @@ void TestLogging::test_syslogGetFacility_data (void)
#ifdef _WIN32
#elif defined(Q_OS_ANDROID)
#else
QTest::newRow("auth") << "auth" << static_cast<int>(LOG_AUTH);
QTest::newRow("user") << "user" << static_cast<int>(LOG_USER);
QTest::newRow("local7") << "local7" << static_cast<int>(LOG_LOCAL7);
QTest::newRow("auth") << "auth" << (LOG_AUTH);
QTest::newRow("user") << "user" << (LOG_USER);
QTest::newRow("local7") << "local7" << (LOG_LOCAL7);
QTest::newRow("random") << "random" << -1;
QTest::newRow("empty") << "" << -1;
#endif
Expand Down Expand Up @@ -213,18 +213,18 @@ void TestLogging::test_verboseArgParse_level_data (void)
// program even though they should produce identical output.
QTest::newRow("general") << "general"
<< static_cast<uint64_t>(VB_GENERAL)
<< static_cast<uint64_t>(0) << static_cast<int>(0)
<< static_cast<uint64_t>(0) << static_cast<int>(0)
<< static_cast<uint64_t>(0) << 0
<< static_cast<uint64_t>(0) << 0
<< "general";
QTest::newRow("general:info") << "general:info"
<< static_cast<uint64_t>(VB_GENERAL)
<< static_cast<uint64_t>(VB_GENERAL) << static_cast<int>(LOG_INFO)
<< static_cast<uint64_t>(0) << static_cast<int>(0)
<< static_cast<uint64_t>(0) << 0
<< "general";
QTest::newRow("general:notice") << "general:notice"
<< static_cast<uint64_t>(VB_GENERAL)
<< static_cast<uint64_t>(VB_GENERAL) << static_cast<int>(LOG_NOTICE)
<< static_cast<uint64_t>(0) << static_cast<int>(0)
<< static_cast<uint64_t>(0) << 0
<< "general";
QTest::newRow("general:notice,file:debug")
<< "general:notice,file:debug"
Expand Down Expand Up @@ -280,35 +280,35 @@ void TestLogging::test_logPropagateCalc_data (void)
QTest::addColumn<QString>("expectedArgs");

QTest::newRow("plain") << "general"
<< static_cast<int>(0) << static_cast<int>(-1)
<< 0 << (-1)
<< false
<< "--verbose general --loglevel info";
QTest::newRow("path") << "general"
<< static_cast<int>(0) << static_cast<int>(-1)
<< 0 << (-1)
<< true
<< "--verbose general --logpath /tmp --loglevel info";
QTest::newRow("quiet") << "general"
<< static_cast<int>(2) << static_cast<int>(-1)
<< 2 << (-1)
<< false
<< "--verbose general --loglevel info --quiet --quiet";
#if !defined(_WIN32) && !defined(Q_OS_ANDROID)
QTest::newRow("syslog") << "general"
<< static_cast<int>(0) << static_cast<int>(LOG_DAEMON)
<< 0 << (LOG_DAEMON)
<< false
<< "--verbose general --loglevel info --syslog daemon";
#if CONFIG_SYSTEMD_JOURNAL
QTest::newRow("systemd") << "general"
<< static_cast<int>(0) << SYSTEMD_JOURNAL_FACILITY
<< 0 << SYSTEMD_JOURNAL_FACILITY
<< false
<< "--verbose general --loglevel info --systemd-journal";
#endif
#endif
QTest::newRow("muddle") << "general,schedule"
<< static_cast<int>(2) << static_cast<int>(LOG_LOCAL0)
<< 2 << (LOG_LOCAL0)
<< true
<< "--verbose general,schedule --logpath /tmp --loglevel info --quiet --quiet --syslog local0";
QTest::newRow("muddle2") << "schedule:debug,general:warn"
<< static_cast<int>(2) << static_cast<int>(LOG_LOCAL0)
<< 2 << (LOG_LOCAL0)
<< true
<< "--verbose general,schedule --logpath /tmp --loglevel info --quiet --quiet --syslog local0";
}
Expand Down
Expand Up @@ -39,17 +39,17 @@ void TestCommandLineParser::test_getOpt_data (void)
QTest::addColumn<QString>("expectedOpt");
QTest::addColumn<QString>("expectedVal");

QTest::newRow("end") << static_cast<int>(99) << MythCommandLineParser::Result::kEnd << "" << "";
QTest::newRow("empty") << static_cast<int>(1) << MythCommandLineParser::Result::kEmpty << "" << "";
QTest::newRow("first") << static_cast<int>(0) << MythCommandLineParser::Result::kOptOnly << "-h" << "";
QTest::newRow("combo") << static_cast<int>(2) << MythCommandLineParser::Result::kCombOptVal << "-zed" << "100";
QTest::newRow("badcombo") << static_cast<int>(3) << MythCommandLineParser::Result::kInvalid << "-bad=100=101" << "";
QTest::newRow("passthru") << static_cast<int>(4) << MythCommandLineParser::Result::kPassthrough << "" << "";
QTest::newRow("argument") << static_cast<int>(5) << MythCommandLineParser::Result::kArg << "" << "foo";
QTest::newRow("arg val1") << static_cast<int>(6) << MythCommandLineParser::Result::kOptVal << "-x" << "xray";
QTest::newRow("arg val2") << static_cast<int>(8) << MythCommandLineParser::Result::kOptVal << "-y" << "-";
QTest::newRow("arg noval")<< static_cast<int>(10) << MythCommandLineParser::Result::kOptOnly << "-z" << "";
QTest::newRow("arg noval")<< static_cast<int>(11) << MythCommandLineParser::Result::kOptOnly << "-a" << "";
QTest::newRow("end") << 99 << MythCommandLineParser::Result::kEnd << "" << "";
QTest::newRow("empty") << 1 << MythCommandLineParser::Result::kEmpty << "" << "";
QTest::newRow("first") << 0 << MythCommandLineParser::Result::kOptOnly << "-h" << "";
QTest::newRow("combo") << 2 << MythCommandLineParser::Result::kCombOptVal << "-zed" << "100";
QTest::newRow("badcombo") << 3 << MythCommandLineParser::Result::kInvalid << "-bad=100=101" << "";
QTest::newRow("passthru") << 4 << MythCommandLineParser::Result::kPassthrough << "" << "";
QTest::newRow("argument") << 5 << MythCommandLineParser::Result::kArg << "" << "foo";
QTest::newRow("arg val1") << 6 << MythCommandLineParser::Result::kOptVal << "-x" << "xray";
QTest::newRow("arg val2") << 8 << MythCommandLineParser::Result::kOptVal << "-y" << "-";
QTest::newRow("arg noval")<< 10 << MythCommandLineParser::Result::kOptOnly << "-z" << "";
QTest::newRow("arg noval")<< 11 << MythCommandLineParser::Result::kOptOnly << "-a" << "";
}

// \brief Parse individual arguments. Reset the parser each time.
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythfreesurround/el_processor.cpp
Expand Up @@ -183,7 +183,7 @@ class fsurround_decoder::Impl {

private:
// polar <-> cartesian coodinates conversion
static cfloat polar(float a, float p) { return {static_cast<float>(a*std::cos(p)),static_cast<float>(a*std::sin(p))}; }
static cfloat polar(float a, float p) { return {(a*std::cos(p)),(a*std::sin(p))}; }
static float amplitude(FFTComplex z) { return std::hypot(z.re, z.im); }
static float phase(FFTComplex z) { return std::atan2(z.im, z.re); }

Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/DVD/mythdvdplayer.cpp
Expand Up @@ -489,7 +489,7 @@ void MythDVDPlayer::SetTrack(uint Type, uint TrackNo)
{
if (kTrackTypeAudio == Type)
{
StreamInfo stream = m_decoder->GetTrackInfo(Type, static_cast<uint>(TrackNo));
StreamInfo stream = m_decoder->GetTrackInfo(Type, TrackNo);
m_playerCtx->m_buffer->DVD()->SetTrack(Type, stream.m_stream_id);
}

Expand Down
10 changes: 5 additions & 5 deletions mythtv/libs/libmythtv/decoders/avformatdecoder.cpp
Expand Up @@ -1516,7 +1516,7 @@ void AvFormatDecoder::InitVideoCodec(AVStream *stream, AVCodecContext *enc,
QString codecName;
if (codec2)
codecName = codec2->name;
m_parent->SetVideoParams(width, height, static_cast<double>(m_fps),
m_parent->SetVideoParams(width, height, m_fps,
m_currentAspect, false, GetMaxReferenceFrames(enc),
kScan_Detect, codecName);
if (LCD *lcd = LCD::Get())
Expand Down Expand Up @@ -3200,8 +3200,8 @@ int AvFormatDecoder::H264PreProcessPkt(AVStream *stream, AVPacket *pkt)
double seqFPS = m_avcParser->frameRate();

bool res_changed = ((width != m_currentWidth) || (height != m_currentHeight));
bool fps_changed = (seqFPS > 0.0) && ((seqFPS > static_cast<double>(m_fps) + 0.01) ||
(seqFPS < static_cast<double>(m_fps) - 0.01));
bool fps_changed = (seqFPS > 0.0) && ((seqFPS > m_fps + 0.01) ||
(seqFPS < m_fps - 0.01));
bool forcechange = !qFuzzyCompare(aspect + 10.0F, m_currentAspect) &&
m_mythCodecCtx && m_mythCodecCtx->DecoderWillResetOnAspect();
m_currentAspect = aspect;
Expand Down Expand Up @@ -3659,14 +3659,14 @@ bool AvFormatDecoder::ProcessVideoFrame(AVStream *Stream, AVFrame *AvFrame)
{
// If fps has doubled due to frame-doubling deinterlace
// Set fps to double value.
double fpschange = calcfps / static_cast<double>(m_fps);
double fpschange = calcfps / m_fps;
int prior = m_fpsMultiplier;
if (fpschange > 1.9 && fpschange < 2.1)
m_fpsMultiplier = 2;
if (fpschange > 0.9 && fpschange < 1.1)
m_fpsMultiplier = 1;
if (m_fpsMultiplier != prior)
m_parent->SetFrameRate(static_cast<double>(m_fps));
m_parent->SetFrameRate(m_fps);
}

LOG(VB_PLAYBACK | VB_TIMESTAMP, LOG_INFO, LOC +
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/mythplayerui.cpp
Expand Up @@ -458,7 +458,7 @@ void MythPlayerUI::VideoStart()
}
}
if (hasForcedTextTrack)
SetTrack(kTrackTypeRawText, static_cast<uint>(forcedTrackNumber));
SetTrack(kTrackTypeRawText, forcedTrackNumber);
else
SetCaptionsEnabled(m_captionsEnabledbyDefault, false);

Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/remoteencoder.cpp
Expand Up @@ -495,7 +495,7 @@ std::chrono::milliseconds RemoteEncoder::SetSignalMonitoringRate(std::chrono::mi
QStringList strlist( QString("QUERY_RECORDER %1").arg(m_recordernum) );
strlist << "SET_SIGNAL_MONITORING_RATE";
strlist << QString::number(rate.count());
strlist << QString::number((int)notifyFrontend);
strlist << QString::number(notifyFrontend);

if (SendReceiveStringList(strlist, 1))
return std::chrono::milliseconds(strlist[0].toInt());
Expand Down
Expand Up @@ -166,7 +166,7 @@ void TestEITFixups::printEvent(const DBEventEIT& event)
}
if (!event.m_items.isEmpty())
{
printf("Items %3d\n", static_cast<int>(event.m_items.count()));
printf("Items %3d\n", event.m_items.count());
}
printf("Category %3u\n", event.m_categoryType);
printf("\n");
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/visualisations/goom/filters.cpp
Expand Up @@ -391,9 +391,9 @@ getPixelRGB_ (const Uint * buffer, Uint x, Color * c)

#else
/* ATTENTION AU PETIT INDIEN */
c->b = *(unsigned char *) (tmp8 = (unsigned char *) (buffer + x));
c->v = *(unsigned char *) (++tmp8);
c->r = *(unsigned char *) (++tmp8);
c->b = *(tmp8 = (unsigned char *) (buffer + x));
c->v = *(++tmp8);
c->r = *(++tmp8);
// *c = (Color) buffer[x+y*WIDTH] ;
#endif
}
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/visualisations/goom/ifs.cpp
Expand Up @@ -144,11 +144,11 @@ static void
free_ifs_buffers (FRACTAL * Fractal)
{
if (Fractal->m_buffer1 != nullptr) {
(void) free ((void *) Fractal->m_buffer1);
free ((void *) Fractal->m_buffer1);
Fractal->m_buffer1 = (IFSPoint *) nullptr;
}
if (Fractal->m_buffer2 != nullptr) {
(void) free ((void *) Fractal->m_buffer2);
free ((void *) Fractal->m_buffer2);
Fractal->m_buffer2 = (IFSPoint *) nullptr;
}
}
Expand Down Expand Up @@ -486,7 +486,7 @@ release_ifs ()
{
if (Root != nullptr) {
free_ifs(Root);
(void) free ((void *) Root);
free ((void *) Root);
Root = (FRACTAL *) nullptr;
}
}
2 changes: 1 addition & 1 deletion mythtv/libs/libmythui/opengl/mythopenglperf.cpp
Expand Up @@ -19,7 +19,7 @@ MythOpenGLPerf::MythOpenGLPerf(QString Name,
while (m_timerData.size() < m_timerNames.size())
m_timerData.append(0);

setSampleCount(static_cast<int>(m_timerNames.size()) + 1);
setSampleCount(m_timerNames.size() + 1);
if (!create())
{
LOG(VB_GENERAL, LOG_WARNING, m_name + "Failed to initialise OpenGL timers");
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythui/vulkan/mythrendervulkan.cpp
Expand Up @@ -194,7 +194,7 @@ void MythRenderVulkan::DebugVulkan(void)
.arg(VK_VERSION_PATCH(Version));
};

const auto * props = reinterpret_cast<const VkPhysicalDeviceProperties*>(m_window->physicalDeviceProperties());
const auto * props = m_window->physicalDeviceProperties();
if (!props)
return;
const auto & limits = props->limits;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/mythbackend/recordingextender.cpp
Expand Up @@ -1221,7 +1221,7 @@ static bool parseProgramString (const QString& string, int limit,
{
QString lString = string;
QStringList parts = lString.replace("vs.", "vs").split(kSentencePattern);
for (int i = 0; i < std::min(limit,static_cast<int>(parts.size())); i++)
for (int i = 0; i < std::min(limit,parts.size()); i++)
{
QStringList words = parts[i].split(kVersusPattern);
if (words.size() == 2)
Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/mythbackend/services/music.cpp
Expand Up @@ -43,7 +43,7 @@ DTC::MusicMetadataInfoList* Music::GetTrackList(int nStartIndex,

auto *pMusicMetadataInfos = new DTC::MusicMetadataInfoList();

auto musicListCount = static_cast<int>(musicList->count());
int musicListCount = musicList->count();
nStartIndex = (nStartIndex > 0) ? std::min( nStartIndex, musicListCount ) : 0;
nCount = (nCount > 0) ? std::min( nCount, musicListCount ) : musicListCount;
int nEndIndex = std::min((nStartIndex + nCount), musicListCount );
Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/mythbackend/servicesv2/v2music.cpp
Expand Up @@ -59,7 +59,7 @@ V2MusicMetadataInfoList* V2Music::GetTrackList(int nStartIndex,

auto *pMusicMetadataInfos = new V2MusicMetadataInfoList();

auto musicListCount = static_cast<int>(musicList->count());
int musicListCount = musicList->count();
nStartIndex = (nStartIndex > 0) ? std::min( nStartIndex, musicListCount ) : 0;
nCount = (nCount > 0) ? std::min( nCount, musicListCount ) : musicListCount;
int nEndIndex = std::min((nStartIndex + nCount), musicListCount );
Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/mythtranscode/external/replex/element.cpp
Expand Up @@ -211,7 +211,7 @@ int get_video_info(ringbuffer *rbuf, sequence_t *s, int off, int le)
s->h_size = ((headr[1] &0xF0) >> 4) | (headr[0] << 4);
s->v_size = ((headr[1] &0x0F) << 8) | (headr[2]);

int sw = (int)((headr[3]&0xF0) >> 4) ;
int sw = ((headr[3]&0xF0) >> 4) ;

if (DEBUG){
switch( sw ){
Expand Down

0 comments on commit c2b1ece

Please sign in to comment.