From 30abbc3e800659158199be4789c8cfd25a744fdd Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Fri, 20 Mar 2009 17:43:31 +0200 Subject: [PATCH] Fixed some lint warnings. --- HISTORY | 3 ++- common.h | 2 -- config.c | 2 +- protocolfile.c | 1 + protocolhttp.c | 5 ++--- protocolhttp.h | 3 +-- sectionfilter.c | 32 +++++++++++++++++--------------- setup.c | 6 +++--- socket.c | 4 ++-- statistics.c | 2 +- streamer.c | 1 + 11 files changed, 31 insertions(+), 30 deletions(-) diff --git a/HISTORY b/HISTORY index 7a68504..0836178 100644 --- a/HISTORY +++ b/HISTORY @@ -95,7 +95,8 @@ VDR Plugin 'iptv' Revision History (Thanks to ua0lnj for reporting this one). - Added optional patches to disable CA updates. -2009-xx-xx: Version 0.2.6 +2009-03-22: Version 0.2.6 - Added a note about recommended frequencies into README. - Fixed a locking bug with section filters. +- Fixed some lint warnings. diff --git a/common.h b/common.h index 2659ce5..9b2c5fe 100644 --- a/common.h +++ b/common.h @@ -41,8 +41,6 @@ #define SECTION_FILTER_TABLE_SIZE 7 -#define TS_SYNC_BYTE 0x47 - #define ERROR_IF_FUNC(exp, errstr, func, ret) \ do { \ if (exp) { \ diff --git a/config.c b/config.c index 11b0956..081901e 100644 --- a/config.c +++ b/config.c @@ -24,7 +24,7 @@ cIptvConfig::cIptvConfig(void) unsigned int cIptvConfig::GetDisabledFiltersCount(void) const { unsigned int n = 0; - while ((disabledFilters[n] != -1) && (n < ARRAY_SIZE(disabledFilters))) + while ((n < ARRAY_SIZE(disabledFilters) && (disabledFilters[n] != -1))) n++; return n; } diff --git a/protocolfile.c b/protocolfile.c index a61d5aa..c29827d 100644 --- a/protocolfile.c +++ b/protocolfile.c @@ -16,6 +16,7 @@ cIptvProtocolFile::cIptvProtocolFile() : fileDelay(0), + fileStream(NULL), isActive(false) { debug("cIptvProtocolFile::cIptvProtocolFile()\n"); diff --git a/protocolhttp.c b/protocolhttp.c index 1d91cbc..e903e87 100644 --- a/protocolhttp.c +++ b/protocolhttp.c @@ -62,8 +62,7 @@ bool cIptvProtocolHttp::Connect(void) sockAddr.sin_addr.s_addr = inet_addr(*host->h_addr_list); } - int err = connect(socketDesc, (struct sockaddr*)&sockAddr, - sizeof(sockAddr)); + int err = connect(socketDesc, (struct sockaddr *)&sockAddr, sizeof(sockAddr)); // Non-blocking sockets always report in-progress error when connected ERROR_IF_FUNC(err < 0 && errno != EINPROGRESS, "connect()", CloseSocket(), return false); // Select with 800ms timeout on the socket completion, check if it is writable @@ -123,7 +122,7 @@ bool cIptvProtocolHttp::Disconnect(void) } bool cIptvProtocolHttp::GetHeaderLine(char* dest, unsigned int destLen, - unsigned int &recvLen) + unsigned int &recvLen) { debug("cIptvProtocolHttp::GetHeaderLine()\n"); bool linefeed = false; diff --git a/protocolhttp.h b/protocolhttp.h index 8410f92..392bb0b 100644 --- a/protocolhttp.h +++ b/protocolhttp.h @@ -20,8 +20,7 @@ private: private: bool Connect(void); bool Disconnect(void); - bool GetHeaderLine(char* dest, unsigned int destLen, - unsigned int &recvLen); + bool GetHeaderLine(char* dest, unsigned int destLen, unsigned int &recvLen); bool ProcessHeaders(void); public: diff --git a/sectionfilter.c b/sectionfilter.c index 4bdd5fb..80155d0 100644 --- a/sectionfilter.c +++ b/sectionfilter.c @@ -68,6 +68,7 @@ cIptvSectionFilter::~cIptvSectionFilter() unlink(pipeName); fifoDescriptor = -1; readDescriptor = -1; + secbuf = NULL; } int cIptvSectionFilter::GetReadDesc(void) @@ -91,24 +92,25 @@ int cIptvSectionFilter::Filter(void) uint8_t neq = 0; int i; - for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i) { - uint8_t local_xor = filter_value[i] ^ secbuf[i]; - if (maskandmode[i] & local_xor) - return 0; - neq |= maskandnotmode[i] & local_xor; - } + if (secbuf) { + for (i = 0; i < DMX_MAX_FILTER_SIZE; ++i) { + uint8_t local_xor = filter_value[i] ^ secbuf[i]; + if (maskandmode[i] & local_xor) + return 0; + neq |= maskandnotmode[i] & local_xor; + } - if (doneq && !neq) - return 0; + if (doneq && !neq) + return 0; - // There is no data in the fifo, more can be written - if (!select_single_desc(fifoDescriptor, 0, false)) { - i = write(fifoDescriptor, secbuf, seclen); - ERROR_IF(i < 0, "write()"); - // Update statistics - AddSectionStatistic(i, 1); + // There is no data in the fifo, more can be written + if (!select_single_desc(fifoDescriptor, 0, false)) { + i = write(fifoDescriptor, secbuf, seclen); + ERROR_IF(i < 0, "write()"); + // Update statistics + AddSectionStatistic(i, 1); + } } - return 0; } diff --git a/setup.c b/setup.c index 47a3116..bcbbdab 100644 --- a/setup.c +++ b/setup.c @@ -433,14 +433,14 @@ void cIptvMenuChannels::Setup(void) cChannel *cIptvMenuChannels::GetChannel(int Index) { - cIptvMenuChannelItem *p = (cIptvMenuChannelItem *)Get(Index); + cIptvMenuChannelItem *p = dynamic_cast(Get(Index)); return p ? (cChannel *)p->Channel() : NULL; } void cIptvMenuChannels::Propagate(void) { Channels.ReNumber(); - for (cIptvMenuChannelItem *ci = (cIptvMenuChannelItem *)First(); ci; ci = (cIptvMenuChannelItem *)ci->Next()) + for (cIptvMenuChannelItem *ci = dynamic_cast(First()); ci; ci = dynamic_cast(ci->Next())) ci->Set(); Display(); Channels.SetModified(true); @@ -618,7 +618,7 @@ eOSState cIptvMenuInfo::ProcessKey(eKeys Key) case kYellow: page = IPTV_DEVICE_INFO_FILTERS; UpdateInfo(); break; - case kBlue: IptvConfig.SetUseBytes(!IptvConfig.GetUseBytes()); + case kBlue: IptvConfig.SetUseBytes(IptvConfig.GetUseBytes() ? 0 : 1); UpdateInfo(); break; default: if (timeout.TimedOut()) diff --git a/socket.c b/socket.c index 5478eb4..652f35f 100644 --- a/socket.c +++ b/socket.c @@ -109,7 +109,7 @@ int cIptvUdpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen) socklen_t addrlen = sizeof(sockAddr); int len = 0; // Read data from socket - if (isActive) + if (isActive && socketDesc && BufferAddr && (BufferLen > 0)) len = recvfrom(socketDesc, BufferAddr, BufferLen, MSG_DONTWAIT, (struct sockaddr *)&sockAddr, &addrlen); if ((len > 0) && (BufferAddr[0] == TS_SYNC_BYTE)) { @@ -173,7 +173,7 @@ int cIptvTcpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen) } socklen_t addrlen = sizeof(sockAddr); // Read data from socket - if (isActive) + if (isActive && socketDesc && BufferAddr && (BufferLen > 0)) return recvfrom(socketDesc, BufferAddr, BufferLen, MSG_DONTWAIT, (struct sockaddr *)&sockAddr, &addrlen); return 0; diff --git a/statistics.c b/statistics.c index 97692e1..e743328 100644 --- a/statistics.c +++ b/statistics.c @@ -119,7 +119,7 @@ void cIptvPidStatistics::AddPidStatistic(u_short Pid, long Payload) mostActivePids[numberOfElements - 1].pid = Pid; mostActivePids[numberOfElements - 1].DataAmount = Payload; // Re-sort - qsort(&mostActivePids, numberOfElements, sizeof(pidStruct), SortPids); + qsort(mostActivePids, numberOfElements, sizeof(pidStruct), SortPids); } } diff --git a/streamer.c b/streamer.c index 39b97cb..86d1aef 100644 --- a/streamer.c +++ b/streamer.c @@ -31,6 +31,7 @@ cIptvStreamer::~cIptvStreamer() debug("cIptvStreamer::~cIptvStreamer()\n"); // Close the protocol Close(); + protocol = NULL; // Free allocated memory free(packetBuffer); }