From 15dead15435d82f01c1a0c56a4af9faaa6c0a86c Mon Sep 17 00:00:00 2001 From: leslie Date: Wed, 1 Jul 2009 11:45:17 +0200 Subject: [PATCH] fix GCC warnings --- FFdecsa/FFdecsa.c | 2 ++ cam.c | 4 ++-- data.c | 2 +- filter.c | 4 ++-- log.c | 3 +-- misc.c | 10 ++++++++++ misc.h | 2 ++ network.c | 3 +-- sc.c | 7 +++---- systems/nagra/nagra1.c | 6 +++--- systems/seca/seca.c | 2 +- 11 files changed, 28 insertions(+), 17 deletions(-) diff --git a/FFdecsa/FFdecsa.c b/FFdecsa/FFdecsa.c index dbc9e53..f272b05 100644 --- a/FFdecsa/FFdecsa.c +++ b/FFdecsa/FFdecsa.c @@ -115,6 +115,7 @@ //// debug tool +#ifdef DEBUG static void dump_mem(const char *string, const unsigned char *p, int len, int linelen){ int i; for(i=0;itype=Type; pk->id=Id; pk->keynr=Keynr; - asprintf(&s,"%c %.*X %s",Type,pk->IdSize(),Id,*pk->PrintKeyNr()); + s=bprintf("%c %.*X %s",Type,pk->IdSize(),Id,*pk->PrintKeyNr()); delete pk; } else s=strdup("unknown"); diff --git a/filter.c b/filter.c index 0eb03d5..36eae04 100644 --- a/filter.c +++ b/filter.c @@ -40,7 +40,7 @@ cPidFilter::cPidFilter(const char *Id, int Num, int DvbNum, unsigned int IdleTim dvbNum=DvbNum; idleTime=IdleTime; id=0; fd=-1; active=false; forceRun=false; userData=0; - asprintf(&id,"%s/%d",Id,Num); + id=bprintf("%s/%d",Id,Num); PRINTF(L_CORE_ACTION,"new filter '%s' on card %d (%d ms)",id,dvbNum,idleTime); } @@ -150,7 +150,7 @@ int cPidFilter::Pid(void) cAction::cAction(const char *Id, int DvbNum) { - asprintf(&id,"%s %d",Id,DvbNum); + id=bprintf("%s %d",Id,DvbNum); dvbNum=DvbNum; unique=0; pri=-1; SetDescription("%s filter",id); diff --git a/log.c b/log.c index ef193d4..ec1c356 100644 --- a/log.c +++ b/log.c @@ -172,8 +172,7 @@ void cLogging::PrivateLogPrint(const struct LogHeader *lh, const char *txt) fprintf(logfile,"%s [%s] %s\n",lh->stamp,lh->tag,"logfile closed, filesize limit reached"); fclose(logfile); logfile=0; logfileShutup=false; - char *name; - asprintf(&name,"%s.old",logcfg.logFilename); + char *name=bprintf("%s.old",logcfg.logFilename); if(rename(logcfg.logFilename,name)) { logfileShutup=true; PRINTF(L_GEN_ERROR,"failed to rotate logfile: %s",strerror(errno)); diff --git a/misc.c b/misc.c index fa9965a..d63825e 100644 --- a/misc.c +++ b/misc.c @@ -133,6 +133,16 @@ unsigned char XorSum(const unsigned char *mem, int len) return cs; } +char *bprintf(const char *fmt, ...) +{ + va_list ap; + va_start(ap,fmt); + char *str=0; + if(vasprintf(&str,fmt,ap)<0); + va_end(ap); + return str; +} + // crc stuff taken from linux-2.6.0/lib/crc32.c /* * There are multiple 16-bit CRC polynomials in common use, but this is diff --git a/misc.h b/misc.h index dc5868f..9fcafd3 100644 --- a/misc.h +++ b/misc.h @@ -61,6 +61,8 @@ bool CheckFF(const unsigned char *data, int len); unsigned char XorSum(const unsigned char *mem, int len); unsigned int crc32_le(unsigned int crc, unsigned char const *p, int len); +char *bprintf(const char *fmt, ...) __attribute__ ((format (printf,1,2))); + // ---------------------------------------------------------------- class cLineBuff { diff --git a/network.c b/network.c index c4b968e..702d9a6 100644 --- a/network.c +++ b/network.c @@ -135,8 +135,7 @@ void cNetWatcher::Action(void) int cNetWatcher::RunCommand(const char *cmd, const char *state) { - char *tmp; - asprintf(&tmp,"%s %s",cmd,state); + char *tmp=bprintf("%s %s",cmd,state); PRINTF(L_CORE_NET,"netwatch cmd exec '%s'",tmp); int res=SystemExec(tmp); free(tmp); diff --git a/sc.c b/sc.c index b2051af..c2ebf65 100644 --- a/sc.c +++ b/sc.c @@ -253,8 +253,7 @@ cScInfoItem::cScInfoItem(const char *Name, const char *Value, eOSState State) void cScInfoItem::SetValue(const char *Name, const char *Value) { - char *buff; - asprintf(&buff,Value ? "%s:\t%s":"%s",Name,Value); + char *buff=bprintf(Value ? "%s:\t%s":"%s",Name,Value); SetText(buff,false); cStatus::MsgOsdCurrentItem(buff); ident=-1; @@ -277,7 +276,7 @@ const char *cOpt::FullName(const char *PreStr) { if(PreStr) { free(fullname); - asprintf(&fullname,"%s.%s",PreStr,name); + fullname=bprintf("%s.%s",PreStr,name); return fullname; } else return name; @@ -1347,7 +1346,7 @@ const char *cScPlugin::CommandLineHelp(void) static char *help_str=0; free(help_str); // for easier orientation, this is column 80| - asprintf(&help_str," -B N --budget=N forces DVB device N to budget mode (using FFdecsa)\n" + help_str=bprintf( " -B N --budget=N forces DVB device N to budget mode (using FFdecsa)\n" " -d CMD --dialup=CMD call CMD to start/stop dialup-network\n" " (default: %s)\n" " -t SECS --timeout=SECS shutdown timeout for dialup-network\n" diff --git a/systems/nagra/nagra1.c b/systems/nagra/nagra1.c index 0a509e0..9413199 100644 --- a/systems/nagra/nagra1.c +++ b/systems/nagra/nagra1.c @@ -97,9 +97,9 @@ bool cEmu::Matches(int RomNr, int Id) bool cEmu::Init(int RomNr, int Id) { romNr=RomNr; id=Id; - asprintf(&romName,"ROM%d.bin",romNr); - asprintf(&romExtName,"ROM%dext.bin",romNr); - asprintf(&eepromName,"eep%i_%02x.bin",romNr,(id&0xff00)>>8); + romName=bprintf("ROM%d.bin",romNr); + romExtName=bprintf("ROM%dext.bin",romNr); + eepromName=bprintf("eep%i_%02x.bin",romNr,(id&0xff00)>>8); if(InitSetup()) { ForceSet(EnsIrdChk, 0x81,true); ForceSet(Cmd83Chk+0,0x98,true); diff --git a/systems/seca/seca.c b/systems/seca/seca.c index 5723032..0c131e4 100644 --- a/systems/seca/seca.c +++ b/systems/seca/seca.c @@ -1327,7 +1327,7 @@ bool cSystemSeca::Process0FNano(int count, unsigned char *hashDW, unsigned char int off=WORD(hashDW,0,0x3FFF); xxor(buffE,8,&MT[off],&MT[0x3FFF-off]); xxor(buffE,8,&MT[( ((buffE[0] ^ hashDW[6])<<8) - + buffE[7] ^ hashDW[7] )&0x3FFF],buffE); + + (buffE[7] ^ hashDW[7]) )&0x3FFF],buffE); LDUMP(L_SYS_VERBOSE,buffE,8,"0f: buffE:"); unsigned char buffC[16]; -- 2.39.5