Fixed some lint warnings.

This commit is contained in:
Rolf Ahrenberg 2009-03-20 17:43:31 +02:00
parent 74761da04a
commit 30abbc3e80
11 changed files with 31 additions and 30 deletions

View File

@ -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.

View File

@ -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) { \

View File

@ -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;
}

View File

@ -16,6 +16,7 @@
cIptvProtocolFile::cIptvProtocolFile()
: fileDelay(0),
fileStream(NULL),
isActive(false)
{
debug("cIptvProtocolFile::cIptvProtocolFile()\n");

View File

@ -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;

View File

@ -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:

View File

@ -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;
}

View File

@ -433,14 +433,14 @@ void cIptvMenuChannels::Setup(void)
cChannel *cIptvMenuChannels::GetChannel(int Index)
{
cIptvMenuChannelItem *p = (cIptvMenuChannelItem *)Get(Index);
cIptvMenuChannelItem *p = dynamic_cast<cIptvMenuChannelItem *>(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<cIptvMenuChannelItem *>(First()); ci; ci = dynamic_cast<cIptvMenuChannelItem *>(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())

View File

@ -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;

View File

@ -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);
}
}

View File

@ -31,6 +31,7 @@ cIptvStreamer::~cIptvStreamer()
debug("cIptvStreamer::~cIptvStreamer()\n");
// Close the protocol
Close();
protocol = NULL;
// Free allocated memory
free(packetBuffer);
}