followscreenings.cpp: Fix format issues for time_t portability

- Added <inttypes.h> for correct format specifiers.
- Used PRIuMAX or time_t handling to resolve [-Wformat=] warnings.
- Updated sscanf and snprintf calls in exec and show functions.
This commit is contained in:
2024-07-04 16:08:36 +02:00
parent f0671d734b
commit 742fc42d0f

View File

@@ -50,6 +50,8 @@
#include <global.h>
#include <neutrino.h>
#include <inttypes.h>
CFollowScreenings::~CFollowScreenings()
{
followlist.clear();
@@ -78,12 +80,12 @@ CChannelEventList *CFollowScreenings::getFollowScreenings(void)
int CFollowScreenings::exec(CMenuTarget* /*parent*/, const std::string & actionKey)
{
unsigned long a;
if (1 == sscanf(actionKey.c_str(), "%lu", &a)) {
uintmax_t a;
if (1 == sscanf(actionKey.c_str(), "%" SCNuMAX, &a)) {
int ix = 0;
CChannelEventList::iterator e;
for (e = followlist.begin(); e != followlist.end(); e++, ix++)
if ((time_t)a == e->startTime) {
if (static_cast<time_t>(a) == e->startTime) {
time_t start = e->startTime - (ANNOUNCETIME + 120);
time_t stop = e->startTime + e->duration;
CTimerd::TimerList overlappingTimers = Timer.getOverlappingTimers(start, stop);
@@ -155,7 +157,7 @@ void CFollowScreenings::show()
if (followlist.size() == 1 && g_settings.timer_followscreenings != FOLLOWSCREENINGS_ALWAYS)
{
snprintf(actionstr, sizeof(actionstr), "%lu", followlist.front().startTime);
snprintf(actionstr, sizeof(actionstr), "%" PRIuMAX, static_cast<uintmax_t>(followlist.front().startTime));
exec(NULL, actionstr);
}
else if (followlist.size() > 1 || g_settings.timer_followscreenings == FOLLOWSCREENINGS_ALWAYS)
@@ -173,7 +175,7 @@ void CFollowScreenings::show()
screening_date += strftime(" %d.", tmStartZeit);
screening_date += g_Locale->getText(CLocaleManager::getMonth(tmStartZeit));
screening_date += strftime(". %H:%M", tmStartZeit );
snprintf(actionstr, sizeof(actionstr), "%lu", e->startTime);
snprintf(actionstr, sizeof(actionstr), "%" PRIuMAX, static_cast<uintmax_t>(e->startTime));
forwarders.push_back(new CMenuForwarder(screening_date, true, NULL, this, actionstr, directKey, icon));
updateRightIcon(i, e->startTime, e->duration);
m.addItem(forwarders[i]);