Skip to content

Commit

Permalink
Code cleanup: Fix several compiler warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
ksooo committed Nov 22, 2024
1 parent e8cefd2 commit 10a0a84
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 29 deletions.
2 changes: 1 addition & 1 deletion pvr.hts/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.hts"
version="22.6.0"
version="22.6.1"
name="Tvheadend HTSP Client"
provider-name="Adam Sutton, Sam Stenvall, Lars Op den Kamp, Kai Sommerfeld">
<requires>@ADDON_DEPENDS@</requires>
Expand Down
3 changes: 3 additions & 0 deletions pvr.hts/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v22.6.1
- Code cleanup: Fix several compiler warnings

v22.6.0
- Add support for Autorec properties "Start after" and "Start before"

Expand Down
21 changes: 11 additions & 10 deletions src/Tvheadend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ PVR_ERROR CTvheadend::GetProvidersAmount(int& amount)
return PVR_ERROR_FAILED;

std::lock_guard<std::recursive_mutex> lock(m_mutex);
amount = m_providers.size();
amount = static_cast<int>(m_providers.size());
return PVR_ERROR_NO_ERROR;
}

Expand Down Expand Up @@ -325,7 +325,7 @@ PVR_ERROR CTvheadend::GetChannelGroupsAmount(int& amount)
return PVR_ERROR_FAILED;

std::lock_guard<std::recursive_mutex> lock(m_mutex);
amount = m_tags.size();
amount = static_cast<int>(m_tags.size());
return PVR_ERROR_NO_ERROR;
}

Expand Down Expand Up @@ -422,7 +422,7 @@ PVR_ERROR CTvheadend::GetChannelsAmount(int& amount)
return PVR_ERROR_FAILED;

std::lock_guard<std::recursive_mutex> lock(m_mutex);
amount = m_channels.size();
amount = static_cast<int>(m_channels.size());
return PVR_ERROR_NO_ERROR;
}

Expand Down Expand Up @@ -557,8 +557,9 @@ PVR_ERROR CTvheadend::GetRecordingsAmount(bool deleted, int& amount)

std::lock_guard<std::recursive_mutex> lock(m_mutex);

amount = std::count_if(m_recordings.cbegin(), m_recordings.cend(),
[](const RecordingMapEntry& entry) { return entry.second.IsRecording(); });
amount = static_cast<int>(std::count_if(m_recordings.cbegin(), m_recordings.cend(),
[](const RecordingMapEntry& entry)
{ return entry.second.IsRecording(); }));
return PVR_ERROR_NO_ERROR;
}

Expand All @@ -570,7 +571,6 @@ PVR_ERROR CTvheadend::GetRecordings(bool deleted, kodi::addon::PVRRecordingsResu
std::vector<kodi::addon::PVRRecording> recs;
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
char buf[128];

recs.reserve(m_recordings.size());
for (const auto& entry : m_recordings)
Expand Down Expand Up @@ -1174,8 +1174,9 @@ PVR_ERROR CTvheadend::GetTimersAmount(int& amount)
std::lock_guard<std::recursive_mutex> lock(m_mutex);

// Normal timers
amount = std::count_if(m_recordings.cbegin(), m_recordings.cend(),
[](const RecordingMapEntry& entry) { return entry.second.IsTimer(); });
amount = static_cast<int>(std::count_if(m_recordings.cbegin(), m_recordings.cend(),
[](const RecordingMapEntry& entry)
{ return entry.second.IsTimer(); }));

// Repeating timers
amount += m_timeRecordings.GetTimerecTimerCount();
Expand Down Expand Up @@ -1715,7 +1716,7 @@ PVR_ERROR CTvheadend::OnSystemWake()
bool CTvheadend::OpenRecordedStream(const kodi::addon::PVRRecording& recording, int64_t& streamId)
{
if (!m_asyncState.WaitForState(ASYNC_EPG))
return PVR_ERROR_SERVER_TIMEOUT;
return false;

const auto vfs{std::make_shared<HTSPVFS>(m_settings, *m_conn)};
if (!vfs->Open(recording))
Expand Down Expand Up @@ -1765,7 +1766,7 @@ int CTvheadend::ReadRecordedStream(int64_t streamId, unsigned char* buffer, unsi
isRecordingInProgress = ((*it2).second.GetState() == PVR_TIMER_STATE_RECORDING);
}

const int bytesRead = vfs->Read(buffer, size, isRecordingInProgress);
const int bytesRead = static_cast<int>(vfs->Read(buffer, size, isRecordingInProgress));
return bytesRead < 0 ? 0 : bytesRead;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Tvheadend.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class ATTR_DLL_LOCAL CTvheadend : public kodi::addon::CInstancePVRClient,
std::vector<tvheadend::HTSPDemuxer*> m_dmx;
tvheadend::HTSPDemuxer* m_dmx_active;
bool m_streamchange;
std::map<uint32_t, std::shared_ptr<tvheadend::HTSPVFS>> m_vfs;
std::map<int64_t, std::shared_ptr<tvheadend::HTSPVFS>> m_vfs;
bool m_stateRebuilt{false};

HTSPMessageQueue m_queue;
Expand Down
2 changes: 1 addition & 1 deletion src/tvheadend/AutoRecordings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void AutoRecordings::SyncDvrCompleted()

int AutoRecordings::GetAutorecTimerCount() const
{
return m_autoRecordings.size();
return static_cast<int>(m_autoRecordings.size());
}

void AutoRecordings::GetAutorecTimers(std::vector<kodi::addon::PVRTimer>& timers)
Expand Down
10 changes: 6 additions & 4 deletions src/tvheadend/HTSPConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ bool HTSPConnection::ReadMessage()
{
/* Read 4 byte len */
uint8_t lb[4];
size_t len = m_socket->Read(&lb, sizeof(lb));
size_t len = static_cast<size_t>(m_socket->Read(&lb, sizeof(lb)));
if (len != sizeof(lb))
return false;

Expand All @@ -311,7 +311,8 @@ bool HTSPConnection::ReadMessage()
size_t cnt = 0;
while (cnt < len)
{
int64_t r = m_socket->Read(buf + cnt, len - cnt, m_settings->GetResponseTimeout());
size_t r =
static_cast<size_t>(m_socket->Read(buf + cnt, len - cnt, m_settings->GetResponseTimeout()));
if (r < 0)
{
Logger::Log(LogLevel::LEVEL_ERROR, "failed to read packet from socket");
Expand Down Expand Up @@ -523,7 +524,7 @@ bool HTSPConnection::SendHello(std::unique_lock<std::recursive_mutex>& lock)
if (chal && chal_len)
{
m_challenge = malloc(chal_len);
m_challengeLen = chal_len;
m_challengeLen = static_cast<int>(chal_len);
std::memcpy(m_challenge, chal, chal_len);
}

Expand All @@ -543,7 +544,8 @@ bool HTSPConnection::SendAuth(std::unique_lock<std::recursive_mutex>& lock,
struct HTSSHA1* sha = static_cast<struct HTSSHA1*>(malloc(hts_sha1_size));
uint8_t d[20];
hts_sha1_init(sha);
hts_sha1_update(sha, reinterpret_cast<const uint8_t*>(pass.c_str()), pass.length());
hts_sha1_update(sha, reinterpret_cast<const uint8_t*>(pass.c_str()),
static_cast<unsigned int>(pass.length()));
if (m_challenge)
hts_sha1_update(sha, static_cast<const uint8_t*>(m_challenge), m_challengeLen);
hts_sha1_final(sha, d);
Expand Down
18 changes: 9 additions & 9 deletions src/tvheadend/HTSPDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,11 @@ PVR_ERROR HTSPDemuxer::CurrentDescrambleInfo(kodi::addon::PVRDescrambleInfo& inf
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);

info.SetPID(m_descrambleInfo.GetPid());
info.SetCAID(m_descrambleInfo.GetCaid());
info.SetProviderID(m_descrambleInfo.GetProvid());
info.SetECMTime(m_descrambleInfo.GetEcmTime());
info.SetHops(m_descrambleInfo.GetHops());
info.SetPID(static_cast<int>(m_descrambleInfo.GetPid()));
info.SetCAID(static_cast<int>(m_descrambleInfo.GetCaid()));
info.SetProviderID(static_cast<int>(m_descrambleInfo.GetProvid()));
info.SetECMTime(static_cast<int>(m_descrambleInfo.GetEcmTime()));
info.SetHops(static_cast<int>(m_descrambleInfo.GetHops()));

info.SetCardSystem(m_descrambleInfo.GetCardSystem());
info.SetReader(m_descrambleInfo.GetReader());
Expand Down Expand Up @@ -382,8 +382,8 @@ PVR_ERROR HTSPDemuxer::GetStreamTimes(kodi::addon::PVRStreamTimes& times) const

times.SetStartTime(m_startTime);
times.SetPTSStart(0);
times.SetPTSBegin(TVH_TO_DVD_TIME(m_timeshiftStatus.start));
times.SetPTSEnd(TVH_TO_DVD_TIME(m_timeshiftStatus.end));
times.SetPTSBegin(static_cast<int64_t>(TVH_TO_DVD_TIME(m_timeshiftStatus.start)));
times.SetPTSEnd(static_cast<int64_t>(TVH_TO_DVD_TIME(m_timeshiftStatus.end)));

return PVR_ERROR_NO_ERROR;
}
Expand Down Expand Up @@ -551,12 +551,12 @@ void HTSPDemuxer::ParseMuxPacket(htsmsg_t* m)
m_streamStat[idx]++;

/* Allocate buffer */
DEMUX_PACKET* pkt = m_demuxPktHdl.AllocateDemuxPacket(binlen);
DEMUX_PACKET* pkt = m_demuxPktHdl.AllocateDemuxPacket(static_cast<int>(binlen));
if (!pkt)
return;

std::memcpy(pkt->pData, bin, binlen);
pkt->iSize = binlen;
pkt->iSize = static_cast<int64_t>(binlen);
pkt->iStreamId = idx;

/* Duration */
Expand Down
2 changes: 1 addition & 1 deletion src/tvheadend/InstanceSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const int DEFAULT_DVR_DUPDETECT = DVR_AUTOREC_RECORD_ALL;
const bool DEFAULT_DVR_PLAYSTATUS = true;
const int DEFAULT_STREAM_CHUNKSIZE = 64; // KB
const bool DEFAULT_DVR_IGNORE_DUPLICATE_SCHEDULES = true;
const bool DEFAULT_STREAM_STALLED_THRESHOLD = 10; // seconds
const int DEFAULT_STREAM_STALLED_THRESHOLD = 10; // seconds

} // namespace

Expand Down
2 changes: 1 addition & 1 deletion src/tvheadend/TimeRecordings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void TimeRecordings::SyncDvrCompleted()

int TimeRecordings::GetTimerecTimerCount() const
{
return m_timeRecordings.size();
return static_cast<int>(m_timeRecordings.size());
}

void TimeRecordings::GetTimerecTimers(std::vector<kodi::addon::PVRTimer>& timers)
Expand Down
2 changes: 1 addition & 1 deletion src/tvheadend/utilities/RDSExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ uint8_t RDSExtractorAAC::Decode(const uint8_t* data, size_t len)

try
{
aac::Decoder decoder(data, len);
aac::Decoder decoder(data, static_cast<unsigned int>(len));
m_rdsLen = decoder.DecodeRDS(m_rdsData);
}
catch (std::exception& e)
Expand Down

0 comments on commit 10a0a84

Please sign in to comment.