summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2010-03-23 15:32:37 +0100
committerJochen Dolze <vdr@dolze.de>2010-03-23 15:32:37 +0100
commitfc4a9599ab36029c94949cf6faeb21d63d79ed51 (patch)
tree310dadf189b647ab0ea7cc0d075c1fed48fe403a
parent44b6d66ecd254cd82c1b37b1937479e5a895f57c (diff)
downloadvdr-plugin-markad-fc4a9599ab36029c94949cf6faeb21d63d79ed51.tar.gz
vdr-plugin-markad-fc4a9599ab36029c94949cf6faeb21d63d79ed51.tar.bz2
Fixed most warnings from -Wextra and -pedantic
-rw-r--r--markad-standalone.cpp37
-rw-r--r--markad.cpp12
-rw-r--r--queue.cpp14
-rw-r--r--status.cpp2
-rw-r--r--status.h2
-rw-r--r--streaminfo.cpp12
-rw-r--r--streaminfo.h1
-rw-r--r--vdr2pkt.cpp3
8 files changed, 48 insertions, 35 deletions
diff --git a/markad-standalone.cpp b/markad-standalone.cpp
index 34235f3..3bd71bb 100644
--- a/markad-standalone.cpp
+++ b/markad-standalone.cpp
@@ -169,7 +169,7 @@ bool cMarkAdStandalone::ProcessFile(const char *Directory, int Number)
CheckIndex(Directory);
if (abort) return false;
- int datalen=385024;
+ const int datalen=385024;
uchar data[datalen];
char *fbuf;
@@ -784,21 +784,6 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, bool BackupMarks, in
isyslog("starting v%s",VERSION);
isyslog("on %s",Directory);
- if (!noPid)
- {
- CreatePidfile(Directory);
- if (abort)
- {
- video_demux=NULL;
- ac3_demux=NULL;
- mp2_demux=NULL;
- decoder=NULL;
- video=NULL;
- audio=NULL;
- return;
- }
- }
-
if (!bDecodeAudio)
{
isyslog("audio decoding disabled by user");
@@ -827,6 +812,21 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, bool BackupMarks, in
return;
}
+ if (!noPid)
+ {
+ CreatePidfile(Directory);
+ if (abort)
+ {
+ video_demux=NULL;
+ ac3_demux=NULL;
+ mp2_demux=NULL;
+ decoder=NULL;
+ video=NULL;
+ audio=NULL;
+ return;
+ }
+ }
+
if (isTS)
{
if (!CheckPATPMT(Directory))
@@ -1362,8 +1362,9 @@ int main(int argc, char *argv[])
pid_t pid = fork();
if (pid < 0)
{
- fprintf(stderr, "%m\n");
- esyslog("fork ERROR: %m");
+ char *err=strerror(errno);
+ fprintf(stderr, "%s\n",err);
+ esyslog("fork ERROR: %s",err);
return 2;
}
if (pid != 0)
diff --git a/markad.cpp b/markad.cpp
index 6142131..4f68b56 100644
--- a/markad.cpp
+++ b/markad.cpp
@@ -44,7 +44,7 @@ bool cPluginMarkAd::ProcessArgs(int argc, char *argv[])
{ "bindir", required_argument, NULL, 'b'
},
{ "logocachedir", required_argument, NULL, 'l'},
- { NULL }
+ { NULL, 0, NULL, 0 }
};
int c;
@@ -144,13 +144,13 @@ cMenuSetupPage *cPluginMarkAd::SetupMenu(void)
return NULL;
}
-bool cPluginMarkAd::SetupParse(const char *Name, const char *Value)
+bool cPluginMarkAd::SetupParse(const char *UNUSED(Name), const char *UNUSED(Value))
{
// Parse your own setup parameters and store their values.
return false;
}
-bool cPluginMarkAd::Service(const char *Id, void *Data)
+bool cPluginMarkAd::Service(const char *UNUSED(Id), void *UNUSED(Data))
{
// Handle custom service requests from other plugins
return false;
@@ -162,10 +162,12 @@ const char **cPluginMarkAd::SVDRPHelpPages(void)
return NULL;
}
-cString cPluginMarkAd::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode)
+cString cPluginMarkAd::SVDRPCommand(const char *UNUSED(Command), const char *UNUSED(Option),
+ int &UNUSED(ReplyCode))
{
// Process SVDRP commands this plugin implements
return NULL;
}
-VDRPLUGINCREATOR(cPluginMarkAd); // Don't touch this!
+
+VDRPLUGINCREATOR(cPluginMarkAd) // Don't touch this! \ No newline at end of file
diff --git a/queue.cpp b/queue.cpp
index 611606d..3f5684f 100644
--- a/queue.cpp
+++ b/queue.cpp
@@ -33,7 +33,8 @@ bool cMarkAdPaketQueue::Inject(uchar *Data, int Size)
if (!buffer) return false;
if (outptr>Size)
{
- uchar temp[Size+1];
+ uchar *temp=(uchar *) alloca(Size+1);
+ if (!temp) return false;
memcpy(temp,Data,Size);
outptr-=Size;
memcpy(&buffer[outptr],temp,Size);
@@ -42,12 +43,13 @@ bool cMarkAdPaketQueue::Inject(uchar *Data, int Size)
else
{
int oldSize=Length();
- uchar tempold[oldSize+1];
- memcpy(tempold,&buffer[outptr],oldSize);
+ uchar *tempold=(uchar *) alloca(oldSize+1);
+ if (!tempold) return false;
+ uchar *temp=(uchar *) alloca(Size+1);
+ if (!temp) return false;
- uchar temp[Size+1];
+ memcpy(tempold,&buffer[outptr],oldSize);
memcpy(temp,Data,Size);
-
memcpy(buffer,temp,Size);
memcpy(buffer+Size,tempold,oldSize);
@@ -72,7 +74,7 @@ bool cMarkAdPaketQueue::Put(uchar *Data, int Size)
memcpy(&buffer[inptr],Data,Size);
inptr+=Size;
- int npercent=(int) ((double) inptr/(double) maxqueue)*100;
+ int npercent=(int) ((inptr*100)/maxqueue);
if ((npercent>90) && (name) && (npercent!=percent))
{
diff --git a/status.cpp b/status.cpp
index 6394fa8..0029813 100644
--- a/status.cpp
+++ b/status.cpp
@@ -7,7 +7,7 @@
#include "status.h"
-void cStatusMarkAd::Recording(const cDevice *Device, const char *Name, const char *FileName, bool On)
+void cStatusMarkAd::Recording(const cDevice *Device, const char *UNUSED(Name), const char *FileName, bool On)
{
if (!Device) return; // just to be safe
if (!FileName) return; // we cannot operate without a filename
diff --git a/status.h b/status.h
index 3ac4b9c..ddf6ab5 100644
--- a/status.h
+++ b/status.h
@@ -9,6 +9,8 @@
#include <vdr/status.h>
+#define UNUSED(v) UNUSED_ ## v __attribute__((unused))
+
// --- cStatusMarkAd
class cStatusMarkAd : public cStatus
{
diff --git a/streaminfo.cpp b/streaminfo.cpp
index f21e693..10321c9 100644
--- a/streaminfo.cpp
+++ b/streaminfo.cpp
@@ -15,8 +15,6 @@ cMarkAdStreamInfo::cMarkAdStreamInfo()
bool cMarkAdStreamInfo::FindAC3AudioInfos(MarkAdContext *maContext, uchar *espkt, int eslen)
{
- if ((!maContext) || (!espkt)) return false;
-
#pragma pack(1)
struct AC3HDR
{
@@ -42,6 +40,8 @@ unsigned AcMod:
3;
};
#pragma pack()
+ if ((!maContext) || (!espkt)) return false;
+ if (eslen<(int) sizeof(struct AC3HDR)) return false;
struct AC3HDR *ac3hdr = (struct AC3HDR *) espkt;
@@ -131,7 +131,8 @@ bool cMarkAdStreamInfo::FindH264VideoInfos(MarkAdContext *maContext, uchar *pkt,
if (nalu==NAL_SPS)
{
- uint8_t nal_data[len];
+ uint8_t *nal_data=(uint8_t*) alloca(len);
+ if (!nal_data) return false;
int nal_len = nalUnescape(nal_data, pkt + 5, len - 5);
cBitStream bs(nal_data, nal_len);
@@ -166,7 +167,7 @@ bool cMarkAdStreamInfo::FindH264VideoInfos(MarkAdContext *maContext, uchar *pkt,
{
if (next)
next = (last + bs.getSeGolomb()) & 0xff;
- last = next ?: last;
+ last = next ? next : last;
}
}
}
@@ -408,7 +409,8 @@ bool cMarkAdStreamInfo::FindH264VideoInfos(MarkAdContext *maContext, uchar *pkt,
if ((nalu==NAL_SLICE) || (nalu==NAL_IDR_SLICE))
{
- uint8_t nal_data[len];
+ uint8_t *nal_data=(uint8_t*) alloca(len);
+ if (!nal_data) return false;
int nal_len = nalUnescape(nal_data, pkt + 5, len - 5);
cBitStream bs(nal_data, nal_len);
diff --git a/streaminfo.h b/streaminfo.h
index c2f5a70..e08ac7f 100644
--- a/streaminfo.h
+++ b/streaminfo.h
@@ -10,6 +10,7 @@
#include <stdint.h>
#include <string.h>
+#include <stdlib.h>
#include "global.h"
diff --git a/vdr2pkt.cpp b/vdr2pkt.cpp
index 1c4e898..d6ef906 100644
--- a/vdr2pkt.cpp
+++ b/vdr2pkt.cpp
@@ -20,6 +20,9 @@ cMarkAdVDR2Pkt::~cMarkAdVDR2Pkt()
void cMarkAdVDR2Pkt::Process(MarkAdPid Pid, uchar *VDRData, int VDRSize, uchar **PktData, int *PktSize)
{
if ((!PktData) || (!PktSize) || (!queue)) return;
+ if ((Pid.Type!=MARKAD_PIDTYPE_VIDEO_H262) &&
+ (Pid.Type!=MARKAD_PIDTYPE_VIDEO_H264)) return;
+
*PktData=NULL;
*PktSize=0;