From 3bd2658c85f00269583259d5912c88f031b9599f Mon Sep 17 00:00:00 2001 From: Christian Wieninger Date: Fri, 6 Apr 2012 20:27:04 +0200 Subject: bugtracker #929, bunch of warning fixes, thanks to Joe_D for providing this patch --- afuzzy.c | 6 +++--- blacklist.c | 30 ++++++++++++++++-------------- conflictcheck.c | 3 +++ conflictcheck.h | 2 +- conflictcheck_thread.c | 6 +++--- createcats.c | 23 ++++++++++++++++++----- epgsearchcats.c | 8 ++++++-- epgsearchcfg.c | 3 +++ epgsearchext.c | 2 +- epgsearchext.h | 2 +- epgsearchsetup.c | 12 +++++++----- epgsearchtools.c | 8 ++++---- epgsearchtools.h | 2 +- mainmenushortcut.c | 1 + md5.h | 2 +- menu_conflictcheck.c | 7 +++++-- menu_dirselect.h | 2 +- menu_event.c | 2 -- menu_myedittimer.c | 18 ++++++++++++------ menu_searchedit.c | 22 +++++++++++++--------- menu_searchresults.c | 15 +++++++++++++-- menu_switchtimers.c | 1 - menu_whatson.c | 17 ++++++++++------- pending_notifications.h | 1 + recdone.c | 12 +++++++++--- recdone.h | 2 +- searchtimer_thread.c | 15 ++++++++------- switchtimer_thread.c | 8 +++++--- templatefile.c | 3 ++- timer_thread.c | 5 +++++ uservars.c | 4 +++- varparser.h | 2 +- 32 files changed, 158 insertions(+), 88 deletions(-) diff --git a/afuzzy.c b/afuzzy.c index 5684335..83fda9b 100644 --- a/afuzzy.c +++ b/afuzzy.c @@ -52,7 +52,7 @@ ALGORITHM ******************************************************************************/ void afuzzy_init(const char *p, int kerr, int UseFilter, AFUZZY *fuzzy) { - int cnt, p_len, i, j, l, d, m, dd; + int cnt, p_len, i, l, d, m; char PatFilter[sizeof(Uint)*8 + 1]; fuzzy->k = kerr; @@ -112,11 +112,11 @@ void afuzzy_init(const char *p, int kerr, int UseFilter, AFUZZY *fuzzy) fuzzy->FilterS = (Uint *)calloc(m + 1, sizeof(Uint)); /* Not let's fill the interleaved pattern */ - dd = p_len / (fuzzy->k + 1); + int dd = p_len / (fuzzy->k + 1); p_len = dd * (fuzzy->k + 1); for (i = 0, cnt = 0; i < dd; i++) - for (j = 0; j < fuzzy->k + 1; j++, cnt++) + for (int j = 0; j < fuzzy->k + 1; j++, cnt++) PatFilter[cnt] = (unsigned char)p[j*dd + i]; PatFilter[p_len] = 0; diff --git a/blacklist.c b/blacklist.c index 62979ed..eadaa85 100644 --- a/blacklist.c +++ b/blacklist.c @@ -216,20 +216,22 @@ const char *cBlacklist::ToText(void) while (SearchExtCat) { char* catvalue = NULL; - msprintf(&catvalue, "%s", catvalues[index]); - while(strstr(catvalue, ":")) - catvalue = strreplace(catvalue, ":", "!^colon^!"); // ugly: replace with something, that should not happen to be part ofa category value - while(strstr(catvalue, "|")) - catvalue = strreplace(catvalue, "|", "!^pipe^!"); // ugly: replace with something, that should not happen to be part of a regular expression - - if (index == 0) - msprintf(&tmp_catvalues, "%d#%s", SearchExtCat->id, catvalue); - else - { - char* temp = tmp_catvalues; - msprintf(&tmp_catvalues, "%s|%d#%s", tmp_catvalues, SearchExtCat->id, catvalue); - free(temp); - } + if (msprintf(&catvalue, "%s", catvalues[index])!=-1) + { + while(strstr(catvalue, ":")) + catvalue = strreplace(catvalue, ":", "!^colon^!"); // ugly: replace with something, that should not happen to be part ofa category value + while(strstr(catvalue, "|")) + catvalue = strreplace(catvalue, "|", "!^pipe^!"); // ugly: replace with something, that should not happen to be part of a regular expression + + if (index == 0) + msprintf(&tmp_catvalues, "%d#%s", SearchExtCat->id, catvalue); + else + { + char* temp = tmp_catvalues; + msprintf(&tmp_catvalues, "%s|%d#%s", tmp_catvalues, SearchExtCat->id, catvalue); + free(temp); + } + } SearchExtCat = SearchExtCats.Next(SearchExtCat); index++; free(catvalue); diff --git a/conflictcheck.c b/conflictcheck.c index 1d46fa5..28a8cfa 100644 --- a/conflictcheck.c +++ b/conflictcheck.c @@ -188,6 +188,9 @@ cConflictCheck::~cConflictCheck() void cConflictCheck::InitDevicesInfo() { + if (devices) + delete [] devices; + devices = new cConflictCheckDevice[MAXDEVICES]; #ifdef DEBUG_CONFL numDevices = 4; diff --git a/conflictcheck.h b/conflictcheck.h index 7e6fb7a..2de6fc0 100644 --- a/conflictcheck.h +++ b/conflictcheck.h @@ -100,7 +100,7 @@ class cConflictCheckDevice cDevice* device; int devicenr; - cConflictCheckDevice() {} + cConflictCheckDevice() { device = NULL; devicenr = 0; } int Priority() const { int prio = -1; diff --git a/conflictcheck_thread.c b/conflictcheck_thread.c index c7398db..d3a9c5f 100644 --- a/conflictcheck_thread.c +++ b/conflictcheck_thread.c @@ -96,7 +96,7 @@ void cConflictCheckThread::Action(void) } time_t nextUpdate = time(NULL); - while (m_Active) + while (m_Active && Running()) { time_t now = time(NULL); if (now >= nextUpdate || m_forceUpdate) @@ -149,10 +149,10 @@ void cConflictCheckThread::Action(void) nextUpdate = long(m_lastUpdate/60)*60 + (Intervall * 60); } - if (m_Active) + if (m_Active && Running()) Wait.Wait(2000); // to avoid high system load if time%30==0 ????????????????????? // no waiting in the while loop if m_runOnce is true - while (m_Active && time(NULL)%30 != 0 && !m_runOnce) // sync heart beat to a multiple of 5secs + while (Running() && m_Active && time(NULL)%30 != 0 && !m_runOnce) // sync heart beat to a multiple of 5secs Wait.Wait(1000); }; diff --git a/createcats.c b/createcats.c index c83866c..e252e35 100644 --- a/createcats.c +++ b/createcats.c @@ -59,6 +59,7 @@ class cReadLine { private: char buffer[MAXPARSEBUFFER]; public: + cReadLine() { buffer[0]=0; } char *Read(FILE *f); }; @@ -106,8 +107,13 @@ class cCat { return; char* newvalue = (char*) malloc(sizeof(char) * (strlen(value)+1)); strcpy(newvalue, value); - values = (char**) realloc(values, sizeof(char*)*(numvalues+1)); - values[numvalues++] = newvalue; + char **tmp = (char**) realloc(values, sizeof(char*)*(numvalues+1)); + if (tmp) { + values=tmp; + values[numvalues++] = newvalue; + } else { + free(newvalue); + } } bool valueexists(char* value) { @@ -143,9 +149,16 @@ class cCats { cCat* add(char* name) { cCat* newCat = new cCat(name); - cats = (cCat**) realloc(cats, sizeof(cCat*)*(numcats+1)); - cats[numcats++] = newCat; - return newCat; + cCat **tmp = (cCat**) realloc(cats, sizeof(cCat*)*(numcats+1)); + if (tmp) + { + cats=tmp; + cats[numcats++] = newCat; + return newCat; + } else { + delete newCat; + return NULL; + } } cCat* get(int i) diff --git a/epgsearchcats.c b/epgsearchcats.c index 3c628ec..5458369 100644 --- a/epgsearchcats.c +++ b/epgsearchcats.c @@ -94,8 +94,12 @@ bool cSearchExtCat::Parse(const char *s) while(pstrToken) { nvalues++; - values = (char**) realloc(values, nvalues * sizeof(char*)); - values[nvalues-1] = strdup(pstrToken); + char **tmp = (char**) realloc(values, nvalues * sizeof(char*)); + if (tmp) + { + values=tmp; + values[nvalues-1] = strdup(pstrToken); + } pstrToken=strtok_r(NULL, ",", &pptr); } free(szBuffer); diff --git a/epgsearchcfg.c b/epgsearchcfg.c index fffd60b..c28352e 100644 --- a/epgsearchcfg.c +++ b/epgsearchcfg.c @@ -93,6 +93,9 @@ cEPGSearchConfig::cEPGSearchConfig(void) checkEPGWarnByMail = 0; checkEPGchannelGroupNr = -1; strcpy(conflCheckCmd, ""); + ReplaceOrgSchedule = 0; + sendMailOnSearchtimers = 0; + sendMailOnConflicts = 0; } int cShowMode::Compare(const cListObject &ListObject) const diff --git a/epgsearchext.c b/epgsearchext.c index b1ecb56..455ac93 100644 --- a/epgsearchext.c +++ b/epgsearchext.c @@ -313,7 +313,7 @@ const char *cSearchExt::ToText() while (SearchExtCat) { char* catvalue = NULL; - msprintf(&catvalue, "%s", catvalues[index]); + if (msprintf(&catvalue, "%s", catvalues[index])==-1) break; while(strstr(catvalue, ":")) catvalue = strreplace(catvalue, ":", "!^colon^!"); // ugly: replace with something, that should not happen to be part ofa category value while(strstr(catvalue, "|")) diff --git a/epgsearchext.h b/epgsearchext.h index cfdd131..dab424d 100644 --- a/epgsearchext.h +++ b/epgsearchext.h @@ -221,7 +221,7 @@ class cSearchExts : public cList, public cMutex { cList::Clear(); } public: - cSearchExts(void) { fileName = NULL; } + cSearchExts(void) { fileName = NULL; allowComments = false; } virtual ~cSearchExts() { Clear(); free(fileName); } public: diff --git a/epgsearchsetup.c b/epgsearchsetup.c index dac35fe..f2c394a 100644 --- a/epgsearchsetup.c +++ b/epgsearchsetup.c @@ -86,11 +86,13 @@ eOSState cMenuSetupSubMenu::Help() if(Current() < (int) helpTexts.size()) { char* title = NULL; - msprintf(&title, "%s - %s", tr("Button$Help"), ItemText); - if (strchr(title, ':')) - *strchr(title, ':') = 0; - state = AddSubMenu(new cMenuText(title, helpTexts[Current()])); - free(title); + if (msprintf(&title, "%s - %s", tr("Button$Help"), ItemText)!=-1) + { + if (strchr(title, ':')) + *strchr(title, ':') = 0; + state = AddSubMenu(new cMenuText(title, helpTexts[Current()])); + free(title); + } } return state; } diff --git a/epgsearchtools.c b/epgsearchtools.c index e1b7fd7..c744a6e 100644 --- a/epgsearchtools.c +++ b/epgsearchtools.c @@ -226,7 +226,7 @@ char* GetExtEPGValue(const char* description, const char* catname) char* tmp = NULL; // search the category, must be at beginnig of a line - msprintf(&tmp, "\n%s: ", catname); + if (msprintf(&tmp, "\n%s: ", catname)==-1) return NULL; char* descr = strdup(description); char* cat = NULL; if ((cat = strstr(descr, tmp)) == NULL) @@ -912,9 +912,9 @@ ssize_t Readline(int sockd, char *vptr, size_t maxlen) { } /* Write a line to a socket */ -ssize_t Writeline(int sockd, const char *vptr, size_t n) { - size_t nleft; - size_t nwritten; +ssize_t Writeline(int sockd, const char *vptr, ssize_t n) { + ssize_t nleft; + ssize_t nwritten; const char *buffer; buffer = vptr; diff --git a/epgsearchtools.h b/epgsearchtools.h index b984e94..27ba968 100644 --- a/epgsearchtools.h +++ b/epgsearchtools.h @@ -175,7 +175,7 @@ void SetAux(cTimer* timer, string aux); int msprintf(char **strp, const char *fmt, ...); std::string GetCodeset(); ssize_t Readline(int sockd, char *vptr, size_t maxlen); -ssize_t Writeline(int sockd, const char *vptr, size_t n); +ssize_t Writeline(int sockd, const char *vptr, ssize_t n); long getAddrFromString(const char* hostnameOrIp, struct sockaddr_in* addr); // --- cTimerObj -------------------------------------------------------- diff --git a/mainmenushortcut.c b/mainmenushortcut.c index 9ff5314..a106519 100644 --- a/mainmenushortcut.c +++ b/mainmenushortcut.c @@ -36,6 +36,7 @@ cMainMenuShortcutSetupPage::cMainMenuShortcutSetupPage(const char *setupText, int *const setupValue) :_setupEntry(setupEntry), _setupValue(setupValue) { + dummy=0; Add(new cMenuEditBoolItem(setupText, _setupValue, trVDR("no"), trVDR("yes"))); } diff --git a/md5.h b/md5.h index 107e91c..43a7ec8 100644 --- a/md5.h +++ b/md5.h @@ -67,7 +67,7 @@ class md5 { // Methods public: - md5() { Init(); } + md5() { Init(); m_Buffer[0]=0; m_Digest[0]=0; m_Finalized=0; } void Init(); void Update(uchar* chInput, uint4 nInputLen); void Finalize(); diff --git a/menu_conflictcheck.c b/menu_conflictcheck.c index e901da8..45fa0c4 100644 --- a/menu_conflictcheck.c +++ b/menu_conflictcheck.c @@ -227,9 +227,12 @@ void cMenuConflictCheckDetails::SetHelpKeys() { cConflictCheckTimerObj* curTimerObj = CurrentTimerObj(); bool hasTimer = true; - if (curTimerObj) + bool hasEvent = false; + if (curTimerObj) + { hasTimer = curTimerObj->timer->HasFlags(tfActive); - bool hasEvent = curTimerObj->Event(); + hasEvent = curTimerObj->Event(); + } SetHelp(hasEvent?tr("Button$Repeats"):NULL, trVDR("Button$On/Off"), hasTimer?trVDR("Button$Delete"):NULL, tr("Button$Commands")); } diff --git a/menu_dirselect.h b/menu_dirselect.h index b8f7cbc..71af34a 100644 --- a/menu_dirselect.h +++ b/menu_dirselect.h @@ -36,7 +36,7 @@ class cDirExt : public cListObject { private: char name[MaxFileName]; public: - cDirExt(void){} + cDirExt(void){ name[0]=0; } bool Parse(const char *s) {strcpy(name,s); return true;} char* Name() {return name;} }; diff --git a/menu_event.c b/menu_event.c index 6e7c034..2ad0803 100644 --- a/menu_event.c +++ b/menu_event.c @@ -234,11 +234,9 @@ void cMenuEventSearchSimple::Set() if (event) { cChannel *channel = Channels.GetByChannelID(event->ChannelID(), true, true); - bool canSwitch = false; if (channel) { SetTitle(channel->Name()); - canSwitch = channel->Number() != cDevice::CurrentChannel(); } cEventObj* eventObjPrev = GetPrev(event); diff --git a/menu_myedittimer.c b/menu_myedittimer.c index d3b1e86..5f4391f 100644 --- a/menu_myedittimer.c +++ b/menu_myedittimer.c @@ -333,7 +333,6 @@ eOSState cMenuMyEditTimer::ProcessKey(eKeys Key) if (timer && timer->Aux()) fullaux = timer->Aux(); - int bstart = 0, bstop = 0; // calculate margins if (event && IsSingleEvent()) { time_t startTime = 0, stopTime = 0;; @@ -343,8 +342,9 @@ eOSState cMenuMyEditTimer::ProcessKey(eKeys Key) length += SECSINDAY; startTime = cTimer::SetTime(day, begin); stopTime = startTime + length; - bstart = event->StartTime() - startTime; - bstop = stopTime - event->EndTime(); + // calculate margins + int bstart = event->StartTime() - startTime; + int bstop = stopTime - event->EndTime(); char* epgsearchaux = GetAuxValue(timer, "epgsearch"); if (epgsearchaux) @@ -372,11 +372,14 @@ eOSState cMenuMyEditTimer::ProcessKey(eKeys Key) #endif char* tmpFile = strdup(file); - tmpFile = strreplace(tmpFile, ':', '|'); + strreplace(tmpFile, ':', '|'); char* tmpDir = strdup(directory); - tmpDir = strreplace(tmpDir, ':', '|'); + strreplace(tmpDir, ':', '|'); if (strlen(tmpFile) == 0) + { + free(tmpFile); tmpFile = strdup(CHANNELNAME(ch)); + } if (timer) { @@ -406,7 +409,10 @@ eOSState cMenuMyEditTimer::ProcessKey(eKeys Key) gl_timerStatusMonitor->SetConflictCheckAdvised(); Timers.SetModified(); addIfConfirmed = false; - } + } else { + free(tmpFile); + free(tmpDir); + } } return osBack; case kRed: diff --git a/menu_searchedit.c b/menu_searchedit.c index 88208d2..994d6a9 100644 --- a/menu_searchedit.c +++ b/menu_searchedit.c @@ -461,11 +461,13 @@ eOSState cMenuEditSearchExt::Help() if(Current() < (int) helpTexts.size()) { char* title = NULL; - msprintf(&title, "%s - %s", tr("Button$Help"), ItemText); - if (strchr(title, ':')) - *strchr(title, ':') = 0; - state = AddSubMenu(new cMenuText(title, helpTexts[Current()])); - free(title); + if (msprintf(&title, "%s - %s", tr("Button$Help"), ItemText)!=-1) + { + if (strchr(title, ':')) + *strchr(title, ':') = 0; + state = AddSubMenu(new cMenuText(title, helpTexts[Current()])); + free(title); + } } return state; } @@ -840,7 +842,6 @@ cMenuEditDaysOfWeek::cMenuEditDaysOfWeek(int* DaysOfWeek, int Offset, bool Negat eOSState cMenuEditDaysOfWeek::ProcessKey(eKeys Key) { - int i=0; if (Key == kBack && negate) *pDaysOfWeek = -*pDaysOfWeek; @@ -850,7 +851,7 @@ eOSState cMenuEditDaysOfWeek::ProcessKey(eKeys Key) switch (Key) { case kOk: *pDaysOfWeek = 0; - for(i=0; i<7; i++) + for(int i=0; i<7; i++) *pDaysOfWeek += Days[i]?(int)pow(2,(i+7-offset)%7):0; if (negate) *pDaysOfWeek = -*pDaysOfWeek; @@ -1124,8 +1125,11 @@ void cMenuCatValuesSelect::Set() } } SetCurrent(Get(current)); - cString title = cString::sprintf("%s (%d/%d)", tr("Values for EPG category"), selCount, SearchExtCat->nvalues); - SetTitle(title); + if (SearchExtCat) + { + cString title = cString::sprintf("%s (%d/%d)", tr("Values for EPG category"), selCount, SearchExtCat->nvalues); + if (*title) SetTitle(title); + } Display(); } diff --git a/menu_searchresults.c b/menu_searchresults.c index 3344da5..8be6ffd 100644 --- a/menu_searchresults.c +++ b/menu_searchresults.c @@ -173,6 +173,11 @@ bool cMenuSearchResultsItem::Update(bool Force) cMenuSearchResultsItem::cMenuSearchResultsItem(cRecording *Recording) { + previewTimer = false; + episodeOnly = false; + menuTemplate = NULL; + timerMatch = 0; + inSwitchList = false; event = NULL; search = NULL; fileName = strdup(Recording->FileName()); @@ -189,6 +194,8 @@ cMenuSearchResults::cMenuSearchResults(cMenuTemplate* MenuTemplate) helpKeys = -1; menuTemplate = MenuTemplate; modeYellow = showTitleEpisode; + modeBlue = showAll; + m_bSort = false; ignoreRunning = false; } @@ -783,8 +790,12 @@ bool cMenuSearchResultsForRecs::BuildList() } if (match) { - pArray = (cRecording **)realloc(pArray, (num + 1) * sizeof(cRecording *)); - pArray[num++] = recording; + cRecording **tmp = (cRecording **)realloc(pArray, (num + 1) * sizeof(cRecording *)); + if (tmp) + { + pArray=tmp; + pArray[num++] = recording; + } } } diff --git a/menu_switchtimers.c b/menu_switchtimers.c index d94fbe6..a619f1f 100644 --- a/menu_switchtimers.c +++ b/menu_switchtimers.c @@ -105,7 +105,6 @@ eOSState cMenuEditSwitchTimer::ProcessKey(eKeys Key) } addIfConfirmed = false; return osBack; - break; } default: break; } diff --git a/menu_whatson.c b/menu_whatson.c index 45e8e63..24a520e 100644 --- a/menu_whatson.c +++ b/menu_whatson.c @@ -749,7 +749,7 @@ eOSState cMenuWhatsOnSearch::ProcessKey(eKeys Key) else { cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current()); - if (mi) { + if (mi && mi->Selectable()) { if (mi->event) return AddSubMenu(new cMenuSearchCommands(tr("EPG Commands"),mi->event)); else @@ -774,7 +774,7 @@ eOSState cMenuWhatsOnSearch::ProcessKey(eKeys Key) if (toggleKeys == 0 || (toggleKeys == 1 && EPGSearchConfig.toggleGreenYellow == 0)) { cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current()); - if (mi && mi->channel) + if (mi && mi->Selectable() && mi->channel) { const cSchedule *Schedule = schedules->GetSchedule(mi->channel); if (Schedule) @@ -809,7 +809,7 @@ eOSState cMenuWhatsOnSearch::ProcessKey(eKeys Key) else currentShowMode = GetNextMode(); cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current()); - if (mi) + if (mi && mi->Selectable()) { currentChannel = mi->channel->Number(); scheduleChannel = Channels.GetByNumber(currentChannel); @@ -833,10 +833,13 @@ eOSState cMenuWhatsOnSearch::ProcessKey(eKeys Key) case kOk: { cMenuMyScheduleItem *mi = (cMenuMyScheduleItem *)Get(Current()); - if (!mi->event) // no EPG, so simply switch to channel - return Switch(); - else - return EPGSearchConfig.useOkForSwitch?Switch():ShowSummary(); + if (mi && mi->Selectable()) + { + if (!mi->event) // no EPG, so simply switch to channel + return Switch(); + else + return EPGSearchConfig.useOkForSwitch?Switch():ShowSummary(); + } } break; case kInfo: diff --git a/pending_notifications.h b/pending_notifications.h index c3e2131..66d8913 100644 --- a/pending_notifications.h +++ b/pending_notifications.h @@ -61,6 +61,7 @@ class cPendingNotifications : public cList { private: char *fileName; public: + cPendingNotifications() { fileName = NULL; } void Clear(void) { free(fileName); diff --git a/recdone.c b/recdone.c index 04d7085..84387e1 100644 --- a/recdone.c +++ b/recdone.c @@ -68,9 +68,15 @@ cRecDone::cRecDone(cTimer* Timer, const cEvent* Event, cSearchExt* Search) description = strdup(Event->Description()); startTime = Event->StartTime(); duration = Event->Duration(); - channelID = Timer->Channel()->GetChannelID(); - if (Timer && !isempty(Timer->Aux())) - aux = strdup(Timer->Aux()); + if (Timer) + { + channelID = Timer->Channel()->GetChannelID(); + if (!isempty(Timer->Aux())) + aux = strdup(Timer->Aux()); + } else { + channelID = tChannelID::InvalidID; + aux = NULL; + } } } diff --git a/recdone.h b/recdone.h index 7921c14..a5dc61c 100644 --- a/recdone.h +++ b/recdone.h @@ -67,7 +67,7 @@ class cRecsDone : public cList, public cMutex { fileName = NULL; cList::Clear(); } - cRecsDone(void) {} + cRecsDone(void) { fileName = NULL; } int GetCountRecordings(const cEvent* event, cSearchExt* search, cRecDone** first = NULL, int matchLimit = 90); int GetCountRecordings(const cEvent*, bool compareTitle, int compareSubtitle, bool compareSummary, int compareDate, unsigned long, cRecDone** first = NULL, int matchLimit = 90); int GetTotalCountRecordings(cSearchExt* search, cRecDone** first); diff --git a/searchtimer_thread.c b/searchtimer_thread.c index af67988..71a8ea1 100644 --- a/searchtimer_thread.c +++ b/searchtimer_thread.c @@ -205,11 +205,11 @@ void cSearchTimerThread::Action(void) // let VDR do its startup if (!cPluginEpgsearch::VDR_readyafterStartup) LogFile.Log(2, "SearchTimerThread: waiting for VDR to become ready..."); - while(m_Active && !cPluginEpgsearch::VDR_readyafterStartup) + while(Running() && m_Active && !cPluginEpgsearch::VDR_readyafterStartup) Wait.Wait(1000); time_t nextUpdate = time(NULL); - while (m_Active) + while (m_Active && Running()) { time_t now = time(NULL); bool needUpdate = NeedUpdate(); @@ -225,7 +225,7 @@ void cSearchTimerThread::Action(void) { Wait.Wait(1000); } - while(EITScanner.Active() && m_Active); + while(EITScanner.Active() && m_Active && Running()); LogFile.Log(1,"EPG scan finished"); } if (Timers.BeingEdited()) @@ -245,7 +245,7 @@ void cSearchTimerThread::Action(void) cSearchExt *searchExt = localSearchExts->First(); // reset announcelist announceList.Clear(); - while (searchExt && m_Active) + while (searchExt && m_Active && Running()) { if (!searchExt->IsActiveAt(now)) { @@ -269,6 +269,7 @@ void cSearchTimerThread::Action(void) pResultObj; pResultObj = pSearchResults->Next(pResultObj)) { + if (!Running()) break; const cEvent* pEvent = pResultObj->event; if (!pEvent) continue; @@ -534,7 +535,7 @@ void cSearchTimerThread::Action(void) LogFile.iSysLog("search timer update finished"); // check for conflicts - if (EPGSearchConfig.checkTimerConflictsAfterUpdate && m_Active) + if (EPGSearchConfig.checkTimerConflictsAfterUpdate && m_Active && Running()) { LogFile.iSysLog("check for timer conflicts"); cConflictCheck conflictCheck; @@ -586,9 +587,9 @@ void cSearchTimerThread::Action(void) nextUpdate = long(m_lastUpdate/60)*60 + (EPGSearchConfig.UpdateIntervall * 60); justRunning = false; } - if (m_Active) + if (m_Active && Running()) Wait.Wait(2000); // to avoid high system load if time%30==0 - while (m_Active && !NeedUpdate() && time(NULL)%30 != 0) // sync heart beat to a multiple of 5secs + while (Running() && m_Active && !NeedUpdate() && time(NULL)%30 != 0) // sync heart beat to a multiple of 5secs Wait.Wait(1000); }; LogFile.iSysLog("Leaving search timer thread"); diff --git a/switchtimer_thread.c b/switchtimer_thread.c index bc7db11..d13f9a0 100644 --- a/switchtimer_thread.c +++ b/switchtimer_thread.c @@ -84,7 +84,7 @@ void cSwitchTimerThread::Action(void) SwitchTimers.Lock(); LogFile.Log(3,"switch timer check started"); cSwitchTimer* switchTimer = SwitchTimers.First(); - while (switchTimer && m_Active) + while (switchTimer && m_Active && Running()) { if (switchTimer->startTime - now < switchTimer->switchMinsBefore*60 + MSG_DELAY + 1) { @@ -128,7 +128,7 @@ void cSwitchTimerThread::Action(void) } } - if (m_Active) + if (m_Active && Running()) Wait.Wait(1000 * MSG_DELAY); } SwitchTimers.Save(); @@ -138,12 +138,14 @@ void cSwitchTimerThread::Action(void) } SwitchTimers.Unlock(); LogFile.Log(3,"switch timer check finished"); - if (m_Active) + if (m_Active && Running()) Wait.Wait(1000 * MSG_DELAY); m_lastUpdate = time(NULL); nextUpdate = long(m_lastUpdate/60)*60+ 60 - MSG_DELAY ; // check at each full minute minus 5sec if (SwitchTimers.Count() == 0) m_Active = false; + if (!Running()) + m_Active = false; } while (m_Active && time(NULL)%MSG_DELAY != 0) // sync heart beat to MSG_DELAY Wait.Wait(1000); diff --git a/templatefile.c b/templatefile.c index 166f7bd..686043c 100644 --- a/templatefile.c +++ b/templatefile.c @@ -104,7 +104,8 @@ cTemplLine::~cTemplLine() bool cTemplLine::Parse(char *s) { - if (s && s[0] == '#') + if (!s) return false; + if (s[0] == '#') return true; char *p = strchr(s, '='); if (p) diff --git a/timer_thread.c b/timer_thread.c index d38122b..5a22c49 100644 --- a/timer_thread.c +++ b/timer_thread.c @@ -84,6 +84,11 @@ void cTimerThread::Action(void) } while (m_Active) { + if (!Running()) + { + m_Active=false; + break; + } if (Timers.BeingEdited()) { sleepSec(1); diff --git a/uservars.c b/uservars.c index 1a15706..965c6d6 100644 --- a/uservars.c +++ b/uservars.c @@ -41,6 +41,7 @@ string cPlugconfdirVar::dir = ""; cUserVar::cUserVar() { oldEvent = NULL; + oldescapeStrings = false; } string cUserVar::Evaluate(const cEvent* e, bool escapeStrings) @@ -315,7 +316,8 @@ void cUserVar::ResetCache() // cUserVarLine bool cUserVarLine::Parse(char *s) { - if (s && s[0] == '#') + if (!s) return false; + if (s[0] == '#') return true; char *p = strchr(s, '='); if (p) diff --git a/varparser.h b/varparser.h index a8dfccd..a93f6c7 100644 --- a/varparser.h +++ b/varparser.h @@ -65,7 +65,7 @@ class cVarParser int connectPort; exprType type; - cVarParser() : cmd(NULL), connectPort(-1), type(composed) {} + cVarParser() : cmd(NULL), connectPort(-1), type(composed) { condOp=condEq; } bool Parse(const string& input); bool ParseExp(const string& input); bool IsCondExpr(); -- cgit v1.2.3