From d533372aa8ae82d145de57b2ad63c5cd8e341eb4 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Thu, 4 Jul 2024 16:08:36 +0200 Subject: [PATCH] CLastChannel: fix narrowing conversion warnings in lastchannel.cpp - Changed _LastCh.timestamp to int64_t for compatibility with tv.tv_sec. - Updated store method to cast tv.tv_sec to int64_t, preventing warnings. - Ensured timestamp calculations use int64_t for consistency. This shoold resolve compilation warnings and improve platform independence. --- src/system/lastchannel.cpp | 19 ++++++++++--------- src/system/lastchannel.h | 3 +-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/system/lastchannel.cpp b/src/system/lastchannel.cpp index 2451d9943..2867494dd 100644 --- a/src/system/lastchannel.cpp +++ b/src/system/lastchannel.cpp @@ -39,35 +39,36 @@ void CLastChannel::clear (void) // -- Store only if channel != last channel and time store delay is large enough // forceStoreToLastChannels default to false -void CLastChannel::store (t_channel_id channel_id) +void CLastChannel::store(t_channel_id channel_id) { struct timeval tv; - unsigned long lastTimestamp(0); - unsigned long timeDiff; + int64_t lastTimestamp(0); + int64_t timeDiff; std::list<_LastCh>::iterator It; - gettimeofday (&tv, NULL); + gettimeofday(&tv, NULL); if (!this->lastChannels.empty()) lastTimestamp = this->lastChannels.front().timestamp; timeDiff = tv.tv_sec - lastTimestamp; - /* prev zap time was less than treshhold, remove prev channel */ - if(!this->lastChannels.empty() && (timeDiff <= secs_diff_before_store)) + /* prev zap time was less than threshold, remove prev channel */ + if (!this->lastChannels.empty() && (timeDiff <= secs_diff_before_store)) this->lastChannels.pop_front(); /* push new channel to the head */ - _LastCh newChannel = {/*channel,*/ channel_id, tv.tv_sec, CNeutrinoApp::getInstance()->GetChannelMode()}; + _LastCh newChannel = {/*channel,*/ channel_id, static_cast(tv.tv_sec), CNeutrinoApp::getInstance()->GetChannelMode()}; this->lastChannels.push_front(newChannel); - /* this zap time was more than treshhold, it will stay, remove last in the list */ + /* this zap time was more than threshold, it will stay, remove last in the list */ if ((timeDiff > secs_diff_before_store) && (this->lastChannels.size() > this->maxSize)) this->lastChannels.pop_back(); /* remove this channel at other than 0 position */ - if(this->lastChannels.size() > 1) { + if (this->lastChannels.size() > 1) + { It = this->lastChannels.begin(); ++It; for (; It != this->lastChannels.end(); ++It) diff --git a/src/system/lastchannel.h b/src/system/lastchannel.h index 07ff80542..dac9eca3b 100644 --- a/src/system/lastchannel.h +++ b/src/system/lastchannel.h @@ -27,12 +27,11 @@ nicht gespeichert werden. class CLastChannel { - private: struct _LastCh { t_channel_id channel_id; - long int timestamp; + int64_t timestamp; int channel_mode; };