Skip to content

Commit

Permalink
big cleanup & bugfix for all warnings for gcc 7.2+
Browse files Browse the repository at this point in the history
git-svn-id: http://www.streamboard.tv/svn/oscam/trunk@11472 4b0bc96b-bc66-0410-9d44-ebda105a78c1
  • Loading branch information
gorgone.impertinence committed Jan 17, 2019
1 parent 3d8fbae commit 7d68eed
Show file tree
Hide file tree
Showing 57 changed files with 1,448 additions and 1,263 deletions.
70 changes: 35 additions & 35 deletions cardlist.h
Expand Up @@ -4,7 +4,7 @@
struct known_cards
{
char providername[32];
//max atrsize incl. spaces
//max atrsize incl. spaces
char atr[80];
int atrsize;
}
Expand Down Expand Up @@ -42,114 +42,114 @@ struct atrlist

void findatr(struct s_reader *reader)
{
current.found = 0;
current.found = 0;
current.ishd03 = 0;
current.ishd04 = 0;

memset(current.providername, 0, 32);
if ( strncmp(current.atr, hdplus01.atr, hdplus01.atrsize) == 0 )
if (strncmp(current.atr, hdplus01.atr, hdplus01.atrsize) == 0)
{
memcpy(current.providername, hdplus01.providername, strlen(hdplus01.providername));
current.found = 1;
return;
}
else if ( strncmp(current.atr, hdplus02.atr, hdplus02.atrsize) == 0 )
else if (strncmp(current.atr, hdplus02.atr, hdplus02.atrsize) == 0)
{
memcpy(current.providername, hdplus02.providername, strlen(hdplus02.providername));
current.found = 1;
return;
}
else if ( strncmp(current.atr, hdplus03.atr, hdplus03.atrsize) == 0 )
else if (strncmp(current.atr, hdplus03.atr, hdplus03.atrsize) == 0)
{
current.ishd03=1;
current.ishd03 = 1;
memcpy(current.providername, hdplus03.providername, strlen(hdplus03.providername));
current.found = 1;
return;
}
else if ( strncmp(current.atr, hdplus03a.atr, hdplus03a.atrsize) == 0 )
else if (strncmp(current.atr, hdplus03a.atr, hdplus03a.atrsize) == 0)
{
current.ishd03=1;
current.badcard=1;
current.ishd03 = 1;
current.badcard = 1;
memcpy(current.providername, hdplus03a.providername, strlen(hdplus03a.providername));
current.found = 1;
return;
}
else if ( strncmp(current.atr, hdplus03b.atr, hdplus03b.atrsize) == 0 )
else if (strncmp(current.atr, hdplus03b.atr, hdplus03b.atrsize) == 0)
{
current.ishd03=1;
current.ishd03 = 1;
memcpy(current.providername, hdplus03b.providername, strlen(hdplus03b.providername));
current.found = 1;
return;
}
else if ( strncmp(current.atr, hdplus04.atr, hdplus04.atrsize) == 0 )
else if (strncmp(current.atr, hdplus04.atr, hdplus04.atrsize) == 0)
{
current.ishd04=1;
current.ishd04 = 1;
memcpy(current.providername, hdplus04.providername, strlen(hdplus04.providername));
current.found = 1;
return;
}
else if ( strncmp(current.atr, hdplus04a.atr, hdplus04a.atrsize) == 0 )
else if (strncmp(current.atr, hdplus04a.atr, hdplus04a.atrsize) == 0)
{
current.ishd04=1;
current.ishd04 = 1;
memcpy(current.providername, hdplus04a.providername, strlen(hdplus04a.providername));
current.found = 1;
return;
}
else if ( strncmp(current.atr, unity_01.atr, unity_01.atrsize) == 0 )
else if (strncmp(current.atr, unity_01.atr, unity_01.atrsize) == 0)
{
memcpy(current.providername, unity_01.providername, strlen(unity_01.providername));
current.found = 1;
return;
}
else if ( strncmp(current.atr, unity_02.atr, unity_02.atrsize) == 0 )
else if (strncmp(current.atr, unity_02.atr, unity_02.atrsize) == 0)
{
memcpy(current.providername, unity_02.providername, strlen(unity_02.providername));
current.found = 1;
return;
}
else if ( strncmp(current.atr, kdg_02.atr, kdg_02.atrsize) == 0 )
else if (strncmp(current.atr, kdg_02.atr, kdg_02.atrsize) == 0)
{
memcpy(current.providername, kdg_02.providername, strlen(kdg_02.providername));
current.found = 1;
return;
}
else if ( strncmp(current.atr, rlmega.atr, rlmega.atrsize) == 0 )
else if (strncmp(current.atr, rlmega.atr, rlmega.atrsize) == 0)
{
memcpy(current.providername, rlmega.providername, strlen(rlmega.providername));
current.found = 1;
return;
}
else if ( strncmp(current.atr, mtv.atr, mtv.atrsize) == 0 )
else if (strncmp(current.atr, mtv.atr, mtv.atrsize) == 0)
{
memcpy(current.providername, mtv.providername, strlen(mtv.providername));
current.found = 1;
return;
}
else if ( strncmp(current.atr, orfice.atr, orfice.atrsize) == 0 )
else if (strncmp(current.atr, orfice.atr, orfice.atrsize) == 0)
{
memcpy(current.providername, orfice.providername, strlen(orfice.providername));
current.found = 1;
return;
}
else if ( strncmp(current.atr, cdnl.atr, cdnl.atrsize) == 0 )
else if (strncmp(current.atr, cdnl.atr, cdnl.atrsize) == 0)
{
memcpy(current.providername, cdnl.providername, strlen(cdnl.providername));
current.found = 1;
return;
}
else if ( strncmp(current.atr, tivusatd.atr, tivusatd.atrsize) == 0 )
else if (strncmp(current.atr, tivusatd.atr, tivusatd.atrsize) == 0)
{
memcpy(current.providername, tivusatd.providername, strlen(tivusatd.providername));
current.found = 1;
return;
}
else if ( strncmp(current.atr, tivusate.atr, tivusate.atrsize) == 0 )
else if (strncmp(current.atr, tivusate.atr, tivusate.atrsize) == 0)
{
memcpy(current.providername, tivusate.providername, strlen(tivusate.providername));
current.found = 1;
return;
}
else if ( strncmp(current.atr, srg.atr, srg.atrsize) == 0 )
else if (strncmp(current.atr, srg.atr, srg.atrsize) == 0)
{
memcpy(current.providername, srg.providername, strlen(srg.providername));
reader->read_old_classes = 0;
Expand All @@ -158,37 +158,37 @@ void findatr(struct s_reader *reader)
}

/* test ATR for ins7e11 12,13,14,15 */
if ( current.found == 0 )
if (current.found == 0)
{
int i;
char buf[66];
for( i = 11; i < 16; i++ )
for(i = 11; i < 16; i++)
{
snprintf(buf, skyDEv13.atrsize+1, "3F FF %i 25 03 10 80 41 B0 07 69 FF 4A 50 70 00 00 50 31 01 00 %i", i, i);
if ( strncmp(current.atr, buf, skyDEv13.atrsize) == 0 )
snprintf(buf, skyDEv13.atrsize + 1, "3F FF %i 25 03 10 80 41 B0 07 69 FF 4A 50 70 00 00 50 31 01 00 %i", i, i);
if (strncmp(current.atr, buf, skyDEv13.atrsize) == 0)
{
memcpy(current.providername, skyDEv13.providername, strlen(skyDEv13.providername));
reader->caid = 0x09C4;
current.found = 1;
break;
}
snprintf(buf, skyDEv14.atrsize+1, "3F FD %i 25 02 50 80 0F 41 B0 0A 69 FF 4A 50 F0 00 00 50 31 03", i);
if ( strncmp(current.atr, buf, skyDEv14.atrsize) == 0 )
snprintf(buf, skyDEv14.atrsize + 1, "3F FD %i 25 02 50 80 0F 41 B0 0A 69 FF 4A 50 F0 00 00 50 31 03", i);
if (strncmp(current.atr, buf, skyDEv14.atrsize) == 0)
{
memcpy(current.providername, skyDEv14.providername, strlen(skyDEv14.providername));
reader->caid = 0x098C;
current.found = 1;
break;
}
snprintf(buf, kbw_v23.atrsize+1, "3F FF %i 25 03 10 80 54 B0 01 69 FF 4A 50 70 00 00 4B 57 01 00 00", i);
if ( strncmp(current.atr, buf, kbw_v23.atrsize) == 0 )
snprintf(buf, kbw_v23.atrsize + 1, "3F FF %i 25 03 10 80 54 B0 01 69 FF 4A 50 70 00 00 4B 57 01 00 00", i);
if (strncmp(current.atr, buf, kbw_v23.atrsize) == 0)
{
memcpy(current.providername, kbw_v23.providername, strlen(kbw_v23.providername));
current.found = 1;
break;
}
snprintf(buf, kdg9.atrsize+1, "3F FD %i 25 02 50 00 03 33 B0 15 69 FF 4A 50 F0 80 03 4B 4C 03", i);
if ( strncmp(current.atr, buf, kdg9.atrsize) == 0 )
snprintf(buf, kdg9.atrsize + 1, "3F FD %i 25 02 50 00 03 33 B0 15 69 FF 4A 50 F0 80 03 4B 4C 03", i);
if (strncmp(current.atr, buf, kdg9.atrsize) == 0)
{
memcpy(current.providername, kdg9.providername, strlen(kdg9.providername));
current.found = 1;
Expand Down
2 changes: 1 addition & 1 deletion csctapi/atr.c
Expand Up @@ -191,7 +191,7 @@ int32_t ATR_InitFromArray(ATR *atr, const unsigned char atr_buffer[ATR_MAX_SIZE]
// check that TA1, if pn==1 , has a valid value for FI
if(atr->pn == 1 && atr->ib[pn][ATR_INTERFACE_BYTE_TA].present == 1)
{
uchar FI;
uint8_t FI;
cs_log_dbg(D_ATR, "TA1 = %02x", atr->ib[pn][ATR_INTERFACE_BYTE_TA].value);
FI = (atr->ib[pn][ATR_INTERFACE_BYTE_TA].value & 0xF0) >> 4;
cs_log_dbg(D_ATR, "FI = %02x", FI);
Expand Down
10 changes: 5 additions & 5 deletions csctapi/ifd_drecas.c
Expand Up @@ -45,9 +45,9 @@ int32_t DreCas_Reset(struct s_reader *reader, ATR *atr)
int32_t ret;
uint8_t buf[ATR_MAX_SIZE];
uint8_t reset_cmd[5] = { 0xDB ,0x03 ,0x00 ,0xC1 ,0xC1 };

if(IO_Serial_SetParams(reader, DEFAULT_BAUDRATE, 8, PARITY_NONE, 2, NULL, NULL)) { return ERROR; }

const struct s_cardreader *crdr_ops = reader->crdr;
if (!crdr_ops) return ERROR;

Expand All @@ -57,19 +57,19 @@ int32_t DreCas_Reset(struct s_reader *reader, ATR *atr)
ret = ERROR;

IO_Serial_Ioctl_Lock(reader, 1);

/* Module soft reset */

IO_Serial_Write(reader, 0, 0, (uint32_t)sizeof(reset_cmd), reset_cmd);
cs_sleepms(50);

IO_Serial_Ioctl_Lock(reader, 0);

int32_t n = 0;

while(n < ATR_MAX_SIZE && !IO_Serial_Read(reader, 50, ATR_TIMEOUT, 1, buf + n))
{ n++; }

if(ATR_InitFromArray(atr, buf, n) != ERROR)
{ ret = OK; }

Expand Down
6 changes: 3 additions & 3 deletions csctapi/ifd_pcsc.c
Expand Up @@ -153,7 +153,7 @@ static int32_t pcsc_init(struct s_reader *pcsc_reader)
return OK;
}

static int32_t pcsc_do_api(struct s_reader *pcsc_reader, const uchar *buf, uchar *cta_res, uint16_t *cta_lr, int32_t l)
static int32_t pcsc_do_api(struct s_reader *pcsc_reader, const uint8_t *buf, uint8_t *cta_res, uint16_t *cta_lr, int32_t l)
{
LONG rv;
DWORD dwSendLength, dwRecvLength;
Expand Down Expand Up @@ -214,7 +214,7 @@ static int32_t pcsc_do_api(struct s_reader *pcsc_reader, const uchar *buf, uchar

}

static int32_t pcsc_activate_card(struct s_reader *pcsc_reader, uchar *atr, uint16_t *atr_size)
static int32_t pcsc_activate_card(struct s_reader *pcsc_reader, uint8_t *atr, uint16_t *atr_size)
{
struct pcsc_data *crdr_data = pcsc_reader->crdr_data;
LONG rv;
Expand Down Expand Up @@ -246,7 +246,7 @@ static int32_t pcsc_activate_card(struct s_reader *pcsc_reader, uchar *atr, uint
memcpy(atr, pbAtr, dwAtrLen);
*atr_size = dwAtrLen;

rdr_log(pcsc_reader, "ATR: %s", cs_hexdump(1, (uchar *)pbAtr, dwAtrLen, tmp, sizeof(tmp)));
rdr_log(pcsc_reader, "ATR: %s", cs_hexdump(1, (uint8_t *)pbAtr, dwAtrLen, tmp, sizeof(tmp)));
memcpy(pcsc_reader->card_atr, pbAtr, dwAtrLen);
pcsc_reader->card_atr_length = dwAtrLen;
return OK;
Expand Down
40 changes: 20 additions & 20 deletions csctapi/ifd_sci.c
Expand Up @@ -22,13 +22,13 @@ struct sr_data
{
uint8_t old_reset;
unsigned char T;
uint32_t fs;
uint32_t fs;
uint32_t ETU;
uint32_t WWT;
uint32_t CWT;
uint32_t BWT;
uint32_t EGT;
unsigned char P;
uint32_t WWT;
uint32_t CWT;
uint32_t BWT;
uint32_t EGT;
unsigned char P;
unsigned char I;
};

Expand Down Expand Up @@ -58,9 +58,9 @@ static int32_t Sci_Deactivate(struct s_reader *reader)
}
}
else {return ERROR;}

return OK;

}

static int32_t Sci_Activate(struct s_reader *reader)
Expand Down Expand Up @@ -93,7 +93,7 @@ static int32_t Sci_Read_ATR(struct s_reader *reader, ATR *atr) // reads ATR on
uint32_t timeout = ATR_TIMEOUT;
unsigned char buf[SCI_MAX_ATR_SIZE];
int32_t n = 0, statusreturn = 0;

if(IO_Serial_Read(reader, 0, timeout, 1, buf + n)) //read first char of atr
{
rdr_log(reader, "ERROR: no characters found in ATR!");
Expand Down Expand Up @@ -121,7 +121,7 @@ static int32_t Sci_Read_ATR(struct s_reader *reader, ATR *atr) // reads ATR on
int32_t TDi = T0; // place T0 char into TDi for looped parsing.
while(n < SCI_MAX_ATR_SIZE)
{
if(TDi & 0x10) //TA Present: //The value of TA(i) is always interpreted as XI || UI if i > 2 and T = 15 ='F'in TD(i1)
if(TDi & 0x10) //TA Present: //The value of TA(i) is always interpreted as XI || UI if i > 2 and T = 15 ='F'in TD(i1)
{
if(IO_Serial_Read(reader, 0, timeout, 1, buf + n)) { break; } //In this case, TA(i) contains the clock stop indicator XI, which indicates the logical
//state the clockline must assume when the clock is stopped, and the class indicator UI,
Expand Down Expand Up @@ -308,7 +308,7 @@ static int32_t Sci_Reset(struct s_reader *reader, ATR *atr)
int32_t tries = 0;
int32_t max_tries = 0;
int32_t pll_start_fs = 0;
if (reader->cardmhz > 2000 && reader->cardmhz != 8300)
if (reader->cardmhz > 2000 && reader->cardmhz != 8300)
{
max_tries = (((double)(reader->cardmhz/900)) * 2 ) + 1 ; // the higher the maxpll the higher tries needed, to have 9 Mhz or first avb below.
pll_start_fs = ((double)(reader->cardmhz/300)) + 1.5 ; // first avbl reader Mhz equal or above 3.0 Mhz
Expand Down Expand Up @@ -341,8 +341,8 @@ static int32_t Sci_Reset(struct s_reader *reader, ATR *atr)
else
{
ret = Sci_Read_ATR(reader, atr);
if(ret == ERROR)
{
if(ret == ERROR)
{
Sci_Deactivate(reader);
Sci_Activate(reader);
if (reader->cardmhz > 2000 && reader->cardmhz != 8300)
Expand All @@ -357,12 +357,12 @@ static int32_t Sci_Reset(struct s_reader *reader, ATR *atr)
params.fs = (11 - tries); // if 1 Mhz init failed retry with 3.19 Mhz up to 5.188 Mhz
rdr_log(reader, "Read ATR fail, attempt %d/5 fs = %d", tries, params.fs);
}
else
else
{
tries++; // increase fs
params.fs = (2 + tries); // if 1 Mhz init failed retry with 3.0 Mhz up to 7.0 Mhz
rdr_log(reader, "Read ATR fail, attempt %d/5 fs = %d", tries, params.fs);
}
}
}
else // ATR fetched successfully!
{
Expand Down Expand Up @@ -435,7 +435,7 @@ static int32_t Sci_FastReset(struct s_reader *reader, ATR *atr)
}
else
{
atr_len = reader->card_atr_length + 2; // data buffer has atr lenght + 2 bytes
atr_len = reader->card_atr_length + 2; // data buffer has atr lenght + 2 bytes
}

Sci_Activate(reader);
Expand Down Expand Up @@ -467,7 +467,7 @@ static int32_t Sci_FastReset(struct s_reader *reader, ATR *atr)
rdr_log(reader,"Error reading ATR");
atr_ok= ERROR;
}

cs_sleepms(150);
Sci_WriteSettings(reader, crdr_data->T,crdr_data->fs,crdr_data->ETU, crdr_data->WWT,crdr_data->CWT,crdr_data->BWT,crdr_data->EGT,crdr_data->P,crdr_data->I);
cs_sleepms(150);
Expand All @@ -485,7 +485,7 @@ static int32_t Sci_Init(struct s_reader *reader)
rdr_log(reader," Wait On closing before restart %u", i);
cs_sleepms(1000);
}

int flags = O_RDWR | O_NOCTTY;
#if defined(__SH4__) || defined(STB04SCI)
flags |= O_NONBLOCK;
Expand All @@ -501,7 +501,7 @@ static int32_t Sci_Init(struct s_reader *reader)
if(!reader->crdr_data && !cs_malloc(&reader->crdr_data, sizeof(struct sr_data)))
{ return ERROR; }
struct sr_data *crdr_data = reader->crdr_data;
crdr_data->old_reset = 1;
crdr_data->old_reset = 1;
reader->handle_nr = reader->handle + 1;
return OK;
}
Expand Down Expand Up @@ -534,7 +534,7 @@ static int32_t Sci_Close(struct s_reader *reader)

static int32_t sci_write_settings(struct s_reader *reader, struct s_cardreader_settings *s)
{
if(reader->cardmhz > 2000) // only for dreambox internal pll readers clockspeed can be set precise others like vu ignore it and work always at 4.5 Mhz
if(reader->cardmhz > 2000) // only for dreambox internal pll readers clockspeed can be set precise others like vu ignore it and work always at 4.5 Mhz
{
// P fixed at 5V since this is default class A card, and TB is deprecated
if(reader->protocol_type != ATR_PROTOCOL_TYPE_T14) // fix VU+ internal reader slow responses on T0/T1
Expand Down

0 comments on commit 7d68eed

Please sign in to comment.