From 4fb9a3d353a87fec4f60b2e21d934b507b0019fa Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 11 Feb 2017 16:21:21 +0000 Subject: [PATCH] Compilation fixes for newer compiler, readdir_r to readdir --- Makefile | 2 +- config.c | 7 ++++--- mediafile.c | 10 ++++++++-- picturereader.c | 7 +++---- vompclient.c | 15 ++------------- vompclientrrproc.c | 1 - 6 files changed, 18 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 3bca88f..b6a0d99 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ SOFILE = libvdr-$(PLUGIN).so INCLUDES += -DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' +DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -D__STL_CONFIG_H # VOMP-INSERT DEFINES += -DVOMPSERVER diff --git a/config.c b/config.c index 3866abc..f4a5e01 100644 --- a/config.c +++ b/config.c @@ -137,7 +137,7 @@ FILE* Config::copyToHere(long position) while (newPos < position) { - fgets(buffer, BUFFER_LENGTH-1, file); + if (!fgets(buffer, BUFFER_LENGTH-1, file)) break; fputs(buffer, newFile); newPos += strlen(buffer); } @@ -183,7 +183,8 @@ int Config::deleteValue(const char* section, char* key) } FILE* newFile = copyToHere(ftell(file) - lastLineLength); - fgets(buffer, BUFFER_LENGTH-1, file); + + if ( fgets(buffer, BUFFER_LENGTH-1, file) ); return copyRest(newFile); } @@ -226,7 +227,7 @@ int Config::setValueString(const char* section, const char* key, const char* new return 0; } - fgets(buffer, BUFFER_LENGTH-1, file); + if ( fgets(buffer, BUFFER_LENGTH-1, file) ); fprintf(newFile, "%s = %s\n", key, newValue); return copyRest(newFile); } diff --git a/mediafile.c b/mediafile.c index 93bbfca..a148e5d 100644 --- a/mediafile.c +++ b/mediafile.c @@ -121,13 +121,19 @@ MediaList* MediaFile::getMediaList(const MediaURI * parent){ const char *dirname=parent->getName(); //open the directory and read out the entries DIR *d=opendir(dirname); + if (d == NULL) return rt; struct dirent *e; + + /* readdir_r is now deprecated in favour of readdir (which is effectively thread safe) union { // according to "The GNU C Library Reference Manual" struct dirent d; char b[offsetof(struct dirent, d_name) + NAME_MAX + 1]; } u; while (d != NULL && (readdir_r(d,&u.d,&e) == 0) && e != NULL) { + */ + + while (e = readdir(d)) { const char * fname=e->d_name; if ( fname == NULL) continue; if (strcmp(fname,".") == 0) continue; @@ -141,9 +147,9 @@ MediaList* MediaFile::getMediaList(const MediaURI * parent){ if (m) delete m; } } - if (d != NULL) closedir(d); + closedir(d); return rt; - } +} int MediaFile::openMedium(ULONG channel, const MediaURI * uri, ULLONG * size, ULONG xsize, ULONG ysize) { diff --git a/picturereader.c b/picturereader.c index d2a7a66..53e3d11 100644 --- a/picturereader.c +++ b/picturereader.c @@ -83,8 +83,8 @@ std::string PictureReader::getPictName(TVMediaRequest & req) switch (req.type) { case 0: { //serie - if (series.seriesId != req.primary_id || - series.episodeId != req.secondary_id) { + if (series.seriesId != (int)req.primary_id || + series.episodeId != (int)req.secondary_id) { series.actors.clear(); series.posters.clear(); series.banners.clear(); @@ -147,7 +147,7 @@ std::string PictureReader::getPictName(TVMediaRequest & req) return std::string(""); } break; case 1: { //movie - if (movie.movieId != req.primary_id ) { + if (movie.movieId != (int)req.primary_id ) { movie.actors.clear(); movie.movieId = req.primary_id; x->scraper->Service("GetMovie",&movie); @@ -295,7 +295,6 @@ void PictureReader::threadMethod() ULONG *p; ULONG headerLength = sizeof(ULONG) * 4; UCHAR buffer[headerLength]; - int amountReceived; // threadSetKillable(); ?? diff --git a/vompclient.c b/vompclient.c index 6724231..118eb5c 100644 --- a/vompclient.c +++ b/vompclient.c @@ -417,19 +417,8 @@ cChannel* VompClient::channelFromNumber(ULONG channelNumber) { if (!channel->GroupSep()) { -// log->log("Client", Log::DEBUG, "Looking for channel %lu::: number: %i name: '%s'", channelNumber, channel->Number(), channel->Name()); - - if (channel->Number() == (int)channelNumber) - { - int vpid = channel->Vpid(); -#if VDRVERSNUM < 10300 - int apid1 = channel->Apid1(); -#else - int apid1 = channel->Apid(0); -#endif -// log->log("Client", Log::DEBUG, "Found channel number %lu, vpid = %i, apid1 = %i", channelNumber, vpid, apid1); - return channel; - } +// log->log("Client", Log::DEBUG, "Looking for channel %lu::: number: %i name: '%s'", channelNumber, channel->Number(), channel->Name()); + if (channel->Number() == (int)channelNumber) return channel; } } diff --git a/vompclientrrproc.c b/vompclientrrproc.c index 1de40e2..8cea99a 100644 --- a/vompclientrrproc.c +++ b/vompclientrrproc.c @@ -2070,7 +2070,6 @@ int VompClientRRProc::processGetEventScraperEventType() cSchedulesLock MutexLock; const cSchedules *Schedules = cSchedules::Schedules(MutexLock); #endif - const cSchedule * Schedule; if (Schedules && channel) { const cSchedule *Schedule = Schedules->GetSchedule(channel->GetChannelID()); -- 2.39.2