diff options
author | Jochen Dolze <vdr@dolze.de> | 2012-04-04 13:05:15 +0200 |
---|---|---|
committer | Jochen Dolze <vdr@dolze.de> | 2012-04-04 13:05:15 +0200 |
commit | 4d5bfc7c68db5776711b21fbcef70d02f22b5789 (patch) | |
tree | 07c2cde08530a8a48dcc79f7342528e7c7c231dc | |
parent | 3033eb15a2e29abe3e30ed89a44179069e0b06a2 (diff) | |
download | vdr-plugin-xmltv2vdr-4d5bfc7c68db5776711b21fbcef70d02f22b5789.tar.gz vdr-plugin-xmltv2vdr-4d5bfc7c68db5776711b21fbcef70d02f22b5789.tar.bz2 |
Added cppcheck 1.53 suggestions
-rw-r--r-- | dist/epgdata2xmltv/epgdata2xmltv.cpp | 17 | ||||
-rw-r--r-- | import.cpp | 8 | ||||
-rw-r--r-- | maps.cpp | 31 | ||||
-rw-r--r-- | maps.h | 2 | ||||
-rw-r--r-- | parse.cpp | 2 | ||||
-rw-r--r-- | setup.cpp | 6 | ||||
-rw-r--r-- | source.cpp | 40 | ||||
-rw-r--r-- | xmltv2vdr.cpp | 5 |
8 files changed, 75 insertions, 36 deletions
diff --git a/dist/epgdata2xmltv/epgdata2xmltv.cpp b/dist/epgdata2xmltv/epgdata2xmltv.cpp index fcef073..b463274 100644 --- a/dist/epgdata2xmltv/epgdata2xmltv.cpp +++ b/dist/epgdata2xmltv/epgdata2xmltv.cpp @@ -115,7 +115,7 @@ int cepgdata2xmltv::DownloadData(const char *url) curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 0); // don't follow redirects curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); // Send all data to this function curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &data); // Pass our 'data' struct to the callback function - curl_easy_setopt(curl_handle, CURLOPT_MAXFILESIZE, 45971520); // Set maximum file size to get (bytes) + curl_easy_setopt(curl_handle, CURLOPT_MAXFILESIZE, 85971520); // Set maximum file size to get (bytes) curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1); // No progress meter curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1); // No signaling curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, 240); // Set timeout to 240 seconds @@ -247,8 +247,19 @@ int cepgdata2xmltv::Process(int argc, char *argv[]) } char *line=NULL,*lptr=NULL; size_t size; - getline(&line,&size,f); - getline(&line,&size,f); + if (getline(&line,&size,f)==(ssize_t) -1) + { + fclose(f); + esyslog("failed to read epgdata2xmltv config"); + return 1; + } + if (getline(&line,&size,f)==(ssize_t) -1) + { + fclose(f); + if (line) free(line); + esyslog("failed to read epgdata2xmltv config"); + return 1; + } char *sc=strchr(line,';'); if (sc) { @@ -1075,25 +1075,25 @@ int cImport::Process(cEPGExecutor &myExecutor) time_t endoneday=begin+86400; #endif const cSchedules *schedules=NULL; - cSchedulesLock *schedulesLock; + cSchedulesLock *schedulesLock=NULL; int l=0; while (l<300) { + if (schedulesLock) delete schedulesLock; schedulesLock = new cSchedulesLock(true,200); // wait up to 60 secs for lock! schedules = cSchedules::Schedules(*schedulesLock); + if (schedules) break; if (!myExecutor.StillRunning()) { delete schedulesLock; source->Ilog("request to stop from vdr"); return 0; } - if (schedules) break; - delete schedulesLock; l++; } sqlite3 *db=NULL; - if (sqlite3_open_v2(source->EPGFile(),&db,SQLITE_OPEN_READWRITE,NULL)) + if (sqlite3_open_v2(source->EPGFile(),&db,SQLITE_OPEN_READWRITE,NULL)!=SQLITE_OK) { source->Elog("failed to open %s",source->EPGFile()); delete schedulesLock; @@ -213,12 +213,13 @@ void cEPGMapping::addchannels(const char *channels) tChannelID ChannelID=tChannelID::FromString(token); if (!(ChannelID==tChannelID::InvalidID)) { - channelids=(tChannelID *) realloc(channelids,(numchannelids+1)*sizeof(struct tChannelID)); - if (!channelids) + tChannelID *tmp_channelids=(tChannelID *) realloc(channelids,(numchannelids+1)*sizeof(struct tChannelID)); + if (!tmp_channelids) { free(tmp); return; } + channelids=tmp_channelids; channelids[numchannelids]=ChannelID; numchannelids++; } @@ -243,11 +244,14 @@ void cEPGMapping::AddChannel(int ChannelNumber) } if (!found) { - channelids=(tChannelID *) realloc(channelids,(numchannelids+1)*sizeof(struct tChannelID)); - if (!channelids) return; - channelids[numchannelids]=chan->GetChannelID(); - numchannelids++; - qsort(channelids,numchannelids,sizeof(tChannelID),compare); + tChannelID *tmp_channelids=(tChannelID *) realloc(channelids,(numchannelids+1)*sizeof(struct tChannelID)); + if (tmp_channelids) + { + channelids=tmp_channelids; + channelids[numchannelids]=chan->GetChannelID(); + numchannelids++; + qsort(channelids,numchannelids,sizeof(tChannelID),compare); + } } } } @@ -263,11 +267,14 @@ void cEPGMapping::ReplaceChannels(int NumChannelIDs, tChannelID *ChannelIDs) for (int i=0; i<NumChannelIDs; i++) { - channelids=(tChannelID *) realloc(channelids,(numchannelids+1)*sizeof(tChannelID)); - if (!channelids) return; - channelids[numchannelids]=ChannelIDs[i]; - numchannelids++; - qsort(channelids,numchannelids,sizeof(tChannelID),compare); + tChannelID *tmp_channelids=(tChannelID *) realloc(channelids,(numchannelids+1)*sizeof(tChannelID)); + if (tmp_channelids) + { + channelids=tmp_channelids; + channelids[numchannelids]=ChannelIDs[i]; + numchannelids++; + qsort(channelids,numchannelids,sizeof(tChannelID),compare); + } } } @@ -78,8 +78,8 @@ private: void addchannels(const char *channels); public: cEPGMapping(const char *ChannelName, const char *Flags_and_Mappings); - ~cEPGMapping(); cEPGMapping(cEPGMapping©); + ~cEPGMapping(); void ChangeFlags(int NewFlags) { flags=NewFlags; @@ -207,7 +207,7 @@ bool cParse::FetchSeasonEpisode(iconv_t Conv, const char *EPDir, const char *Tit if (line[0]=='#') continue; char epshorttext[256]=""; char depshorttext[1024]=""; - if (sscanf(line,"%d\t%d\t%*d\t%255c",&Season,&Episode,epshorttext)==3) + if (sscanf(line,"%3d\t%3d\t%*3d\t%255c",&Season,&Episode,epshorttext)==3) { char *lf=strchr(epshorttext,'\n'); if (lf) *lf=0; @@ -247,11 +247,11 @@ eOSState cMenuSetupXmltv2vdr::ProcessKey(eKeys Key) switch (state) { case osContinue: - if ((Key==kLeft) || (Key==kRight) || (Key==kLeft|k_Repeat) || (Key==kRight|k_Repeat)) + if ((Key==kLeft) || (Key==kRight) || (Key==(kLeft|k_Repeat)) || (Key==(kRight|k_Repeat))) { if ((epEntry) && (Current()==epEntry)) Output(); } - if ((Key==kDown) || (Key==kUp) || (Key==kDown|k_Repeat) || (Key==kUp|k_Repeat)) + if ((Key==kDown) || (Key==kUp) || (Key==(kDown|k_Repeat)) || (Key==(kUp|k_Repeat))) { if ((Current()>=sourcesBegin) && (Current()<=sourcesEnd)) { @@ -789,7 +789,7 @@ eOSState cMenuSetupXmltv2vdrChannelSource::ProcessKey(eKeys Key) switch (state) { case osContinue: - if ((Key==kLeft) || (Key==kRight) || (Key==kLeft|k_Repeat) || (Key==kRight|k_Repeat)) + if ((Key==kLeft) || (Key==kRight) || (Key==(kLeft|k_Repeat)) || (Key==(kRight|k_Repeat))) { if (Current()==updateEntry) output(); } @@ -324,7 +324,7 @@ bool cEPGSource::ReadConfig() } if (linenr==2) { - sscanf(line,"%d;%d;%d;%d",&daysinadvance,&exec_upstart,&exec_weekday,&exec_time); + sscanf(line,"%2d;%1d;%3d;%10d",&daysinadvance,&exec_upstart,&exec_weekday,&exec_time); Dlog("daysinadvance=%i",daysinadvance); Dlog("upstart=%i",exec_upstart); if (!exec_upstart) @@ -519,11 +519,22 @@ int cEPGSource::Execute(cEPGExecutor &myExecutor) { n=1; } - r_out=(char *) realloc(r_out, l_out+n+1); - int l=read(p.Out(),r_out+l_out,n); - if (l>0) + char *tmp=(char *) realloc(r_out, l_out+n+1); + if (tmp) { - l_out+=l; + r_out=tmp; + int l=read(p.Out(),r_out+l_out,n); + if (l>0) + { + l_out+=l; + } + } + else + { + free(r_out); + r_out=NULL; + l_out=0; + break; } } if (fds[1].revents & POLLIN) @@ -533,11 +544,22 @@ int cEPGSource::Execute(cEPGExecutor &myExecutor) { n=1; } - r_err=(char *) realloc(r_err, l_err+n+1); - int l=read(p.Err(),r_err+l_err,n); - if (l>0) + char *tmp=(char *) realloc(r_err, l_err+n+1); + if (tmp) { - l_err+=l; + r_err=tmp; + int l=read(p.Err(),r_err+l_err,n); + if (l>0) + { + l_err+=l; + } + } + else + { + free(r_err); + r_err=NULL; + l_err=0; + break; } } if (fds[0].revents & POLLHUP) diff --git a/xmltv2vdr.cpp b/xmltv2vdr.cpp index 1ef897a..6e00925 100644 --- a/xmltv2vdr.cpp +++ b/xmltv2vdr.cpp @@ -197,13 +197,11 @@ void cEPGTimer::Action() if (!xevent) continue; } - int Flags=USE_SEASON; - cSchedule* schedule = (cSchedule *) schedules->GetSchedule(chan,false); if (schedule) { import->PutEvent(sources->GetSource(EITSOURCE),NULL,schedule, - (cEvent *) event,xevent,Flags,IMPORT_DESCRIPTION); + (cEvent *) event,xevent,USE_SEASON,IMPORT_DESCRIPTION); } delete xevent; } @@ -349,6 +347,7 @@ bool cPluginXmltv2vdr::Initialize(void) bool cPluginXmltv2vdr::Start(void) { // Start any background activities the plugin shall perform. + if (confdir) free(confdir); confdir=strdup(ConfigDirectory(PLUGIN_NAME_I18N)); // creates internally the confdir! if (!epgfile) { |