astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60 --brackets=linux --pad-oper

This commit is contained in:
Philippe Teuwen 2012-05-29 15:54:00 +00:00
parent 67522bae65
commit 562205cc14
23 changed files with 196 additions and 196 deletions

View file

@ -349,18 +349,18 @@ uart_list_ports (void)
const char **p = serial_ports_device_radix;
while (*p) {
if (!strncmp(pdDirEnt->d_name, *p, strlen (*p))) {
char **res2 = realloc (res, (szRes+1) * sizeof (char *));
char **res2 = realloc (res, (szRes + 1) * sizeof (char *));
if (!res2)
goto oom;
res = res2;
if (!(res[szRes-1] = malloc (6 + strlen (pdDirEnt->d_name))))
if (!(res[szRes - 1] = malloc (6 + strlen (pdDirEnt->d_name))))
goto oom;
sprintf (res[szRes-1], "/dev/%s", pdDirEnt->d_name);
sprintf (res[szRes - 1], "/dev/%s", pdDirEnt->d_name);
szRes++;
res[szRes-1] = NULL;
res[szRes - 1] = NULL;
}
p++;
}

View file

@ -144,49 +144,49 @@ typedef enum {
static const pn53x_command pn53x_commands[] = {
// Miscellaneous
PNCMD( Diagnose, PN531|PN532|PN533|RCS360 ),
PNCMD( GetFirmwareVersion, PN531|PN532|PN533|RCS360 ),
PNCMD( GetGeneralStatus, PN531|PN532|PN533|RCS360 ),
PNCMD( ReadRegister, PN531|PN532|PN533|RCS360 ),
PNCMD( WriteRegister, PN531|PN532|PN533|RCS360 ),
PNCMD( ReadGPIO, PN531|PN532|PN533 ),
PNCMD( WriteGPIO, PN531|PN532|PN533 ),
PNCMD( SetSerialBaudRate, PN531|PN532|PN533 ),
PNCMD( SetParameters, PN531|PN532|PN533|RCS360 ),
PNCMD( SAMConfiguration, PN531|PN532 ),
PNCMD( PowerDown, PN531|PN532 ),
PNCMD( AlparCommandForTDA, PN533|RCS360 ), // Has another usage on RC-S360...
PNCMD( Diagnose, PN531 | PN532 | PN533 | RCS360 ),
PNCMD( GetFirmwareVersion, PN531 | PN532 | PN533 | RCS360 ),
PNCMD( GetGeneralStatus, PN531 | PN532 | PN533 | RCS360 ),
PNCMD( ReadRegister, PN531 | PN532 | PN533 | RCS360 ),
PNCMD( WriteRegister, PN531 | PN532 | PN533 | RCS360 ),
PNCMD( ReadGPIO, PN531 | PN532 | PN533 ),
PNCMD( WriteGPIO, PN531 | PN532 | PN533 ),
PNCMD( SetSerialBaudRate, PN531 | PN532 | PN533 ),
PNCMD( SetParameters, PN531 | PN532 | PN533 | RCS360 ),
PNCMD( SAMConfiguration, PN531 | PN532 ),
PNCMD( PowerDown, PN531 | PN532 ),
PNCMD( AlparCommandForTDA, PN533 | RCS360 ), // Has another usage on RC-S360...
// RF communication
PNCMD( RFConfiguration, PN531|PN532|PN533|RCS360 ),
PNCMD( RFRegulationTest, PN531|PN532|PN533 ),
PNCMD( RFConfiguration, PN531 | PN532 | PN533 | RCS360 ),
PNCMD( RFRegulationTest, PN531 | PN532 | PN533 ),
// Initiator
PNCMD( InJumpForDEP, PN531|PN532|PN533|RCS360 ),
PNCMD( InJumpForPSL, PN531|PN532|PN533 ),
PNCMD( InListPassiveTarget, PN531|PN532|PN533|RCS360 ),
PNCMD( InATR, PN531|PN532|PN533 ),
PNCMD( InPSL, PN531|PN532|PN533 ),
PNCMD( InDataExchange, PN531|PN532|PN533 ),
PNCMD( InCommunicateThru, PN531|PN532|PN533|RCS360 ),
PNCMD( InJumpForDEP, PN531 | PN532 | PN533 | RCS360 ),
PNCMD( InJumpForPSL, PN531 | PN532 | PN533 ),
PNCMD( InListPassiveTarget, PN531 | PN532 | PN533 | RCS360 ),
PNCMD( InATR, PN531 | PN532 | PN533 ),
PNCMD( InPSL, PN531 | PN532 | PN533 ),
PNCMD( InDataExchange, PN531 | PN532 | PN533 ),
PNCMD( InCommunicateThru, PN531 | PN532 | PN533 | RCS360 ),
PNCMD( InQuartetByteExchange, PN533 ),
PNCMD( InDeselect, PN531|PN532|PN533|RCS360 ),
PNCMD( InRelease, PN531|PN532|PN533|RCS360 ),
PNCMD( InSelect, PN531|PN532|PN533 ),
PNCMD( InDeselect, PN531 | PN532 | PN533 | RCS360 ),
PNCMD( InRelease, PN531 | PN532 | PN533 | RCS360 ),
PNCMD( InSelect, PN531 | PN532 | PN533 ),
PNCMD( InAutoPoll, PN532 ),
PNCMD( InActivateDeactivatePaypass, PN533 ),
// Target
PNCMD( TgInitAsTarget, PN531|PN532|PN533 ),
PNCMD( TgSetGeneralBytes, PN531|PN532|PN533 ),
PNCMD( TgGetData, PN531|PN532|PN533 ),
PNCMD( TgSetData, PN531|PN532|PN533 ),
PNCMD( TgInitAsTarget, PN531 | PN532 | PN533 ),
PNCMD( TgSetGeneralBytes, PN531 | PN532 | PN533 ),
PNCMD( TgGetData, PN531 | PN532 | PN533 ),
PNCMD( TgSetData, PN531 | PN532 | PN533 ),
PNCMD( TgSetDataSecure, PN533 ),
PNCMD( TgSetMetaData, PN531|PN532|PN533 ),
PNCMD( TgSetMetaData, PN531 | PN532 | PN533 ),
PNCMD( TgSetMetaDataSecure, PN533 ),
PNCMD( TgGetInitiatorCommand, PN531|PN532|PN533 ),
PNCMD( TgResponseToInitiator, PN531|PN532|PN533 ),
PNCMD( TgGetTargetStatus, PN531|PN532|PN533 ),
PNCMD( TgGetInitiatorCommand, PN531 | PN532 | PN533 ),
PNCMD( TgResponseToInitiator, PN531 | PN532 | PN533 ),
PNCMD( TgGetTargetStatus, PN531 | PN532 | PN533 ),
};
// SFR part

View file

@ -520,7 +520,7 @@ pn53x_decode_target_data (const uint8_t *pbtRawData, size_t szRawData, pn53x_typ
pnti->nci.btProdCode = *(pbtRawData++);
pnti->nci.btFabCode = *(pbtRawData++);
// Store UID MSB
memcpy (pnti->nci.abtUID+2, pbtRawData, 2);
memcpy (pnti->nci.abtUID + 2, pbtRawData, 2);
pbtRawData += 2;
break;
@ -748,7 +748,7 @@ pn53x_int_to_timeout (const int ms)
uint8_t res = 0;
if (ms) {
res = 0x10;
for (int i=3280; i>1; i/=2) {
for (int i = 3280; i > 1; i /= 2) {
if (ms > i)
break;
res--;
@ -1030,7 +1030,7 @@ pn53x_initiator_select_passive_target_ext (struct nfc_device *pnd,
pnd->bEasyFraming = false;
if (nm.nmt == NMT_ISO14443B2SR) {
// Some work to do before getting the UID...
uint8_t abtInitiate[]="\x06\x00";
uint8_t abtInitiate[] = "\x06\x00";
size_t szInitiateLen = 2;
uint8_t abtSelect[] = { 0x0e, 0x00 };
uint8_t abtRx[1];
@ -1045,9 +1045,9 @@ pn53x_initiator_select_passive_target_ext (struct nfc_device *pnd,
szTargetsData = (size_t)res;
} else if (nm.nmt == NMT_ISO14443B2CT) {
// Some work to do before getting the UID...
const uint8_t abtReqt[]= { 0x10 };
const uint8_t abtReqt[] = { 0x10 };
// Getting product code / fab code & store it in output buffer after the serial nr we'll obtain later
if ((res = pn53x_initiator_transceive_bytes (pnd, abtReqt, sizeof(abtReqt), abtTargetsData+2, sizeof(abtTargetsData)-2, timeout)) < 0) {
if ((res = pn53x_initiator_transceive_bytes (pnd, abtReqt, sizeof(abtReqt), abtTargetsData + 2, sizeof(abtTargetsData) - 2, timeout)) < 0) {
return res;
}
szTargetsData = (size_t)res;
@ -1058,8 +1058,8 @@ pn53x_initiator_select_passive_target_ext (struct nfc_device *pnd,
if (nm.nmt == NMT_ISO14443B2CT) {
if (szTargetsData != 2)
return NFC_ECHIP; // FIXME: It should not return a NFC_ECHIP here!
uint8_t abtRead[]= { 0xC4 }; // Reading UID_MSB (Read address 4)
if ((res = pn53x_initiator_transceive_bytes (pnd, abtRead, sizeof(abtRead), abtTargetsData+4, sizeof(abtTargetsData)-4, timeout) < 0)) {
uint8_t abtRead[] = { 0xC4 }; // Reading UID_MSB (Read address 4)
if ((res = pn53x_initiator_transceive_bytes (pnd, abtRead, sizeof(abtRead), abtTargetsData + 4, sizeof(abtTargetsData) - 4, timeout) < 0)) {
return res;
}
szTargetsData = 6; // u16 UID_LSB, u8 prod code, u8 fab code, u16 UID_MSB
@ -1174,7 +1174,7 @@ pn53x_initiator_poll_target (struct nfc_device *pnd,
}
}
}
} while (uiPollNr==0xff); // uiPollNr==0xff means infinite polling
} while (uiPollNr == 0xff); // uiPollNr==0xff means infinite polling
// We reach this point when each listing give no result, we simply have to return 0
return 0;
}
@ -1344,7 +1344,7 @@ static void __pn53x_init_timer(struct nfc_device *pnd, const uint32_t max_cycles
// prescaler = 2 => precision: ~369ns timer saturates at ~25ms
// prescaler = 10 => precision: ~1.5us timer saturates at ~100ms
if (max_cycles > 0xFFFF) {
CHIP_DATA (pnd)->timer_prescaler = ((max_cycles/0xFFFF)-1)/2;
CHIP_DATA (pnd)->timer_prescaler = ((max_cycles / 0xFFFF) - 1) / 2;
} else {
CHIP_DATA (pnd)->timer_prescaler = 0;
}
@ -1381,7 +1381,7 @@ static uint32_t __pn53x_get_timer(struct nfc_device *pnd, const uint8_t last_cmd
return false;
}
counter_hi = abtRes[off];
counter_lo = abtRes[off+1];
counter_lo = abtRes[off + 1];
counter = counter_hi;
counter = (counter << 8) + counter_lo;
if (counter == 0) {
@ -1404,7 +1404,7 @@ static uint32_t __pn53x_get_timer(struct nfc_device *pnd, const uint8_t last_cmd
((last_cmd_byte >> 5) & 1) ^ ((last_cmd_byte >> 4) & 1) ^
((last_cmd_byte >> 3) & 1) ^ ((last_cmd_byte >> 2) & 1) ^
((last_cmd_byte >> 1) & 1) ^ (last_cmd_byte & 1);
parity = parity ? 0:1;
parity = parity ? 0 : 1;
// When sent ...YY (cmd ends with logical 1, so when last parity bit is 1):
if (parity) {
// it finishes 64us sooner than a ...ZY signal
@ -1478,7 +1478,7 @@ pn53x_initiator_transceive_bits_timed (struct nfc_device *pnd, const uint8_t *pb
// our PN53x timer saturates after 4.8ms so this function shouldn't be used for
// responses coming very late anyway.
// Ideally we should implement a real timer here too but looping a few times is good enough.
for (i = 0; i < (3 *(CHIP_DATA (pnd)->timer_prescaler * 2 + 1)); i++) {
for (i = 0; i < (3 * (CHIP_DATA (pnd)->timer_prescaler * 2 + 1)); i++) {
pn53x_read_register (pnd, PN53X_REG_CIU_FIFOLevel, &sz);
if (sz > 0)
break;
@ -1504,10 +1504,10 @@ pn53x_initiator_transceive_bits_timed (struct nfc_device *pnd, const uint8_t *pb
return res;
}
for (i = 0; i < sz; i++) {
pbtRx[i+szRxBits] = abtRes[i+off];
pbtRx[i + szRxBits] = abtRes[i + off];
}
szRxBits += (size_t) (sz & SYMBOL_FIFO_LEVEL);
sz = abtRes[sz+off];
sz = abtRes[sz + off];
if (sz == 0)
break;
}
@ -1573,7 +1573,7 @@ pn53x_initiator_transceive_bytes_timed (struct nfc_device *pnd, const uint8_t *p
// our PN53x timer saturates after 4.8ms so this function shouldn't be used for
// responses coming very late anyway.
// Ideally we should implement a real timer here too but looping a few times is good enough.
for (i = 0; i < (3 *(CHIP_DATA (pnd)->timer_prescaler * 2 + 1)); i++) {
for (i = 0; i < (3 * (CHIP_DATA (pnd)->timer_prescaler * 2 + 1)); i++) {
pn53x_read_register (pnd, PN53X_REG_CIU_FIFOLevel, &sz);
if (sz > 0)
break;
@ -1599,10 +1599,10 @@ pn53x_initiator_transceive_bytes_timed (struct nfc_device *pnd, const uint8_t *p
return res;
}
for (i = 0; i < sz; i++) {
pbtRx[i+szRx] = abtRes[i+off];
pbtRx[i + szRx] = abtRes[i + off];
}
szRx += (size_t) (sz & SYMBOL_FIFO_LEVEL);
sz = abtRes[sz+off];
sz = abtRes[sz + off];
if (sz == 0)
break;
}
@ -1611,13 +1611,13 @@ pn53x_initiator_transceive_bytes_timed (struct nfc_device *pnd, const uint8_t *p
if (pnd->bCrc) {
// We've to compute CRC ourselves to know last byte actually sent
uint8_t *pbtTxRaw;
pbtTxRaw = (uint8_t *) malloc(szTx+2);
pbtTxRaw = (uint8_t *) malloc(szTx + 2);
memcpy (pbtTxRaw, pbtTx, szTx);
iso14443a_crc_append (pbtTxRaw, szTx);
*cycles = __pn53x_get_timer (pnd, pbtTxRaw[szTx +1]);
*cycles = __pn53x_get_timer (pnd, pbtTxRaw[szTx + 1]);
free(pbtTxRaw);
} else {
*cycles = __pn53x_get_timer (pnd, pbtTx[szTx -1]);
*cycles = __pn53x_get_timer (pnd, pbtTx[szTx - 1]);
}
return szRx;
}
@ -1638,7 +1638,7 @@ pn53x_initiator_target_is_present (struct nfc_device *pnd, const nfc_target nt)
if ((res = pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), abtRx, sizeof (abtRx), -1)) < 0)
return res;
if (res==1) {
if (res == 1) {
return NFC_SUCCESS;
}
return NFC_ETGRELEASED;
@ -1734,9 +1734,9 @@ pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, cons
// Set NFCID2t
memcpy(abtFeliCaParams, pnt->nti.nfi.abtId, 8);
// Set PAD
memcpy(abtFeliCaParams+8, pnt->nti.nfi.abtPad, 8);
memcpy(abtFeliCaParams + 8, pnt->nti.nfi.abtPad, 8);
// Set SystemCode
memcpy(abtFeliCaParams+16, pnt->nti.nfi.abtSysCode, 2);
memcpy(abtFeliCaParams + 16, pnt->nti.nfi.abtSysCode, 2);
pbtFeliCaParams = abtFeliCaParams;
break;
@ -2356,7 +2356,7 @@ pn53x_InAutoPoll (struct nfc_device *pnd,
// InAutoPoll frame looks like this { 0xd4, 0x60, 0x0f, 0x01, 0x00 } => { direction, command, pollnr, period, types... }
size_t szTxInAutoPoll = 3 + szTargetTypes;
uint8_t abtCmd[3+15] = { InAutoPoll, btPollNr, btPeriod };
uint8_t abtCmd[3 + 15] = { InAutoPoll, btPollNr, btPeriod };
for (size_t n = 0; n < szTargetTypes; n++) {
abtCmd[3 + n] = ppttTargetTypes[n];
}
@ -2523,34 +2523,34 @@ pn53x_TgInitAsTarget (struct nfc_device *pnd, pn53x_target_mode ptm,
// MIFARE part
if (pbtMifareParams) {
memcpy (abtCmd+2, pbtMifareParams, 6);
memcpy (abtCmd + 2, pbtMifareParams, 6);
}
// FeliCa part
if (pbtFeliCaParams) {
memcpy (abtCmd+8, pbtFeliCaParams, 18);
memcpy (abtCmd + 8, pbtFeliCaParams, 18);
}
// DEP part
if (pbtNFCID3t) {
memcpy(abtCmd+26, pbtNFCID3t, 10);
memcpy(abtCmd + 26, pbtNFCID3t, 10);
}
// General Bytes (ISO/IEC 18092)
if ((CHIP_DATA(pnd)->type == PN531) || (CHIP_DATA(pnd)->type == RCS360)) {
if (szGBt) {
memcpy (abtCmd+36, pbtGBt, szGBt);
memcpy (abtCmd + 36, pbtGBt, szGBt);
szOptionalBytes = szGBt;
}
} else {
abtCmd[36] = (uint8_t)(szGBt);
if (szGBt) {
memcpy (abtCmd+37, pbtGBt, szGBt);
memcpy (abtCmd + 37, pbtGBt, szGBt);
}
szOptionalBytes = szGBt + 1;
}
// Historical bytes (ISO/IEC 14443-4)
if ((CHIP_DATA(pnd)->type != PN531) && (CHIP_DATA(pnd)->type != RCS360)) { // PN531 does not handle Historical Bytes
abtCmd[36+szOptionalBytes] = (uint8_t)(szTkt);
abtCmd[36 + szOptionalBytes] = (uint8_t)(szTkt);
if (szTkt) {
memcpy (abtCmd+37+szOptionalBytes, pbtTkt, szTkt);
memcpy (abtCmd + 37 + szOptionalBytes, pbtTkt, szTkt);
}
szOptionalBytes += szTkt + 1;
}
@ -2903,8 +2903,8 @@ pn53x_get_information_about (nfc_device *pnd, char *buf, size_t buflen)
return res;
}
for (int i=0; nmt[i]; i++) {
if ((res = snprintf (buf, buflen, "%s%s (", (i==0)?"":", ", str_nfc_modulation_type (nmt[i]))) < 0) {
for (int i = 0; nmt[i]; i++) {
if ((res = snprintf (buf, buflen, "%s%s (", (i == 0) ? "" : ", ", str_nfc_modulation_type (nmt[i]))) < 0) {
return NFC_ESOFT;
}
buf += res;
@ -2917,8 +2917,8 @@ pn53x_get_information_about (nfc_device *pnd, char *buf, size_t buflen)
return res;
}
for (int j=0; nbr[j]; j++) {
if ((res = snprintf (buf, buflen, "%s%s", (j==0)?"":", ", str_nfc_baud_rate (nbr[j]))) < 0) {
for (int j = 0; nbr[j]; j++) {
if ((res = snprintf (buf, buflen, "%s%s", (j == 0) ? "" : ", ", str_nfc_baud_rate (nbr[j]))) < 0) {
return NFC_ESOFT;
}
buf += res;
@ -2957,8 +2957,8 @@ pn53x_get_information_about (nfc_device *pnd, char *buf, size_t buflen)
return res;
}
for (int i=0; nmt[i]; i++) {
if ((res = snprintf (buf, buflen, "%s%s (", (i==0)?"":", ", str_nfc_modulation_type (nmt[i]))) < 0) {
for (int i = 0; nmt[i]; i++) {
if ((res = snprintf (buf, buflen, "%s%s (", (i == 0) ? "" : ", ", str_nfc_modulation_type (nmt[i]))) < 0) {
return NFC_ESOFT;
}
buf += res;
@ -2971,8 +2971,8 @@ pn53x_get_information_about (nfc_device *pnd, char *buf, size_t buflen)
return res;
}
for (int j=0; nbr[j]; j++) {
if ((res = snprintf (buf, buflen, "%s%s", (j==0)?"":", ", str_nfc_baud_rate (nbr[j]))) < 0) {
for (int j = 0; nbr[j]; j++) {
if ((res = snprintf (buf, buflen, "%s%s", (j == 0) ? "" : ", ", str_nfc_baud_rate (nbr[j]))) < 0) {
return NFC_ESOFT;
}
buf += res;

View file

@ -222,8 +222,8 @@ acr122_pcsc_connstring_decode (const nfc_connstring connstring, struct acr122_pc
free (cs);
return 1;
}
strncpy (desc->pcsc_device_name, device_name, sizeof(desc->pcsc_device_name)-1);
desc->pcsc_device_name[sizeof(desc->pcsc_device_name)-1] = '\0';
strncpy (desc->pcsc_device_name, device_name, sizeof(desc->pcsc_device_name) - 1);
desc->pcsc_device_name[sizeof(desc->pcsc_device_name) - 1] = '\0';
free (cs);
return 2;
@ -288,9 +288,9 @@ acr122_pcsc_open (const nfc_connstring connstring)
if (!(pscc = acr122_pcsc_get_scardcontext ()))
goto error;
// Test if we were able to connect to the "emulator" card
if (SCardConnect (*pscc, ndd.pcsc_device_name, SCARD_SHARE_EXCLUSIVE, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1, &(DRIVER_DATA (pnd)->hCard), (void *) &(DRIVER_DATA (pnd)->ioCard.dwProtocol)) != SCARD_S_SUCCESS) {
if (SCardConnect (*pscc, ndd.pcsc_device_name, SCARD_SHARE_EXCLUSIVE, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1, &(DRIVER_DATA (pnd)->hCard), (void *) & (DRIVER_DATA (pnd)->ioCard.dwProtocol)) != SCARD_S_SUCCESS) {
// Connect to ACR122 firmware version >2.0
if (SCardConnect (*pscc, ndd.pcsc_device_name, SCARD_SHARE_DIRECT, 0, &(DRIVER_DATA (pnd)->hCard), (void *) &(DRIVER_DATA (pnd)->ioCard.dwProtocol)) != SCARD_S_SUCCESS) {
if (SCardConnect (*pscc, ndd.pcsc_device_name, SCARD_SHARE_DIRECT, 0, &(DRIVER_DATA (pnd)->hCard), (void *) & (DRIVER_DATA (pnd)->ioCard.dwProtocol)) != SCARD_S_SUCCESS) {
// We can not connect to this device.
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "%s", "PCSC connect failed");
goto error;
@ -453,7 +453,7 @@ acr122_pcsc_firmware (nfc_device *pnd)
DWORD dwFwLen = sizeof (abtFw);
memset (abtFw, 0x00, sizeof (abtFw));
if (DRIVER_DATA (pnd)->ioCard.dwProtocol == SCARD_PROTOCOL_UNDEFINED) {
uiResult = SCardControl (DRIVER_DATA (pnd)->hCard, IOCTL_CCID_ESCAPE_SCARD_CTL_CODE, abtGetFw, sizeof (abtGetFw), (uint8_t *) abtFw, dwFwLen-1, &dwFwLen);
uiResult = SCardControl (DRIVER_DATA (pnd)->hCard, IOCTL_CCID_ESCAPE_SCARD_CTL_CODE, abtGetFw, sizeof (abtGetFw), (uint8_t *) abtFw, dwFwLen - 1, &dwFwLen);
} else {
uiResult = SCardTransmit (DRIVER_DATA (pnd)->hCard, &(DRIVER_DATA (pnd)->ioCard), abtGetFw, sizeof (abtGetFw), NULL, (uint8_t *) abtFw, &dwFwLen);
}

View file

@ -512,7 +512,7 @@ acr122_build_frame_from_apdu (uint8_t **frame, const uint8_t *apdu, const size_t
0x00, // len
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // padding
};
if ((apdu_len+10) > ACR122_USB_BUFFER_LEN)
if ((apdu_len + 10) > ACR122_USB_BUFFER_LEN)
return NFC_EINVARG;
abtFrame[1] = apdu_len;
@ -533,7 +533,7 @@ acr122_build_frame_from_tama (uint8_t **frame, const uint8_t *tama, const size_t
0x00, // PN532 command length
0xd4, // PN532 direction
};
if ((tama_len+16) > ACR122_USB_BUFFER_LEN)
if ((tama_len + 16) > ACR122_USB_BUFFER_LEN)
return NFC_EINVARG;
abtFrame[1] = tama_len + 6;

View file

@ -445,8 +445,8 @@ acr122s_connstring_decode (const nfc_connstring connstring, struct acr122s_descr
free (cs);
return 1;
}
strncpy (desc->port, port, sizeof(desc->port)-1);
desc->port[sizeof(desc->port)-1] = '\0';
strncpy (desc->port, port, sizeof(desc->port) - 1);
desc->port[sizeof(desc->port) - 1] = '\0';
const char *speed_s = strtok (NULL, ":");
if (!speed_s) {

View file

@ -196,8 +196,8 @@ arygon_connstring_decode (const nfc_connstring connstring, struct arygon_descrip
free (cs);
return 1;
}
strncpy (desc->port, port, sizeof(desc->port)-1);
desc->port[sizeof(desc->port)-1] = '\0';
strncpy (desc->port, port, sizeof(desc->port) - 1);
desc->port[sizeof(desc->port) - 1] = '\0';
const char *speed_s = strtok (NULL, ":");
if (!speed_s) {
@ -378,7 +378,7 @@ arygon_tama_receive (nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen,
#ifndef WIN32
abort_p = &(DRIVER_DATA (pnd)->iAbortFds[1]);
#else
abort_p = (void*)&(DRIVER_DATA (pnd)->abort_flag);
abort_p = (void*) & (DRIVER_DATA (pnd)->abort_flag);
#endif
pnd->last_error = uart_receive (DRIVER_DATA (pnd)->port, abtRxBuf, 5, abort_p, timeout);

View file

@ -174,8 +174,8 @@ pn532_connstring_decode (const nfc_connstring connstring, struct pn532_uart_desc
free (cs);
return 1;
}
strncpy (desc->port, port, sizeof(desc->port)-1);
desc->port[sizeof(desc->port)-1] = '\0';
strncpy (desc->port, port, sizeof(desc->port) - 1);
desc->port[sizeof(desc->port) - 1] = '\0';
const char *speed_s = strtok (NULL, ":");
if (!speed_s) {
@ -358,7 +358,7 @@ pn532_uart_receive (nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, i
#ifndef WIN32
abort_p = &(DRIVER_DATA (pnd)->iAbortFds[1]);
#else
abort_p = (void*)&(DRIVER_DATA (pnd)->abort_flag);
abort_p = (void*) & (DRIVER_DATA (pnd)->abort_flag);
#endif
pnd->last_error = uart_receive (DRIVER_DATA (pnd)->port, abtRxBuf, 5, abort_p, timeout);

View file

@ -83,8 +83,8 @@ iso14443a_locate_historical_bytes (uint8_t *pbtAts, size_t szAts, size_t *pszTk)
offset++;
}
if (szAts > offset) {
*pszTk = (szAts-offset);
return (pbtAts+offset);
*pszTk = (szAts - offset);
return (pbtAts + offset);
}
}
*pszTk = 0;