Reduce variables scopes

This commit is contained in:
Philippe Teuwen 2017-02-18 20:13:53 +01:00
parent 2033519b0c
commit 04ef5ca902
4 changed files with 8 additions and 9 deletions

View file

@ -371,7 +371,6 @@ int
pn53x_wrap_frame(const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar,
uint8_t *pbtFrame)
{
uint8_t btFrame;
uint8_t btData;
uint32_t uiBitPos;
uint32_t uiDataPos = 0;
@ -398,7 +397,7 @@ pn53x_wrap_frame(const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbt
// air-bytes = mirror(buffer-byte) + mirror(buffer-byte) + mirror(buffer-byte) + ..
while (true) {
// Reset the temporary frame byte;
btFrame = 0;
uint8_t btFrame = 0;
for (uiBitPos = 0; uiBitPos < 8; uiBitPos++) {
// Copy as much data that fits in the frame byte
@ -1466,9 +1465,8 @@ static void __pn53x_init_timer(struct nfc_device *pnd, const uint32_t max_cycles
static uint32_t __pn53x_get_timer(struct nfc_device *pnd, const uint8_t last_cmd_byte)
{
uint8_t parity;
uint8_t counter_hi, counter_lo;
uint16_t counter, u16cycles;
uint16_t counter;
uint32_t u32cycles;
size_t off = 0;
if (CHIP_DATA(pnd)->type == PN533) {
@ -1496,6 +1494,8 @@ static uint32_t __pn53x_get_timer(struct nfc_device *pnd, const uint8_t last_cmd
// counter saturated
u32cycles = 0xFFFFFFFF;
} else {
uint8_t parity;
uint16_t u16cycles;
u16cycles = 0xFFFF - counter;
u32cycles = u16cycles;
u32cycles *= (CHIP_DATA(pnd)->timer_prescaler * 2 + 1);

View file

@ -400,15 +400,14 @@ acr122_pcsc_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szData, int
{
// FIXME: timeout is not handled
(void) timeout;
int len;
uint8_t abtRxCmd[5] = { 0xFF, 0xC0, 0x00, 0x00 };
if (DRIVER_DATA(pnd)->ioCard.dwProtocol == SCARD_PROTOCOL_T0) {
/*
* Retrieve the PN532 response.
*/
DWORD dwRxLen = sizeof(DRIVER_DATA(pnd)->abtRx);
uint8_t abtRxCmd[5] = { 0xFF, 0xC0, 0x00, 0x00 };
abtRxCmd[4] = DRIVER_DATA(pnd)->abtRx[1];
if (SCardTransmit(DRIVER_DATA(pnd)->hCard, &(DRIVER_DATA(pnd)->ioCard), abtRxCmd, sizeof(abtRxCmd), NULL, DRIVER_DATA(pnd)->abtRx, &dwRxLen) != SCARD_S_SUCCESS) {
pnd->last_error = NFC_EIO;

View file

@ -47,10 +47,10 @@
void
iso14443a_crc(uint8_t *pbtData, size_t szLen, uint8_t *pbtCrc)
{
uint8_t bt;
uint32_t wCrc = 0x6363;
do {
uint8_t bt;
bt = *pbtData++;
bt = (bt ^ (uint8_t)(wCrc & 0x00FF));
bt = (bt ^ (bt << 4));
@ -78,10 +78,10 @@ iso14443a_crc_append(uint8_t *pbtData, size_t szLen)
void
iso14443b_crc(uint8_t *pbtData, size_t szLen, uint8_t *pbtCrc)
{
uint8_t bt;
uint32_t wCrc = 0xFFFF;
do {
uint8_t bt;
bt = *pbtData++;
bt = (bt ^ (uint8_t)(wCrc & 0x00FF));
bt = (bt ^ (bt << 4));

View file

@ -184,7 +184,6 @@ static bool
authenticate(uint32_t uiBlock)
{
mifare_cmd mc;
uint32_t uiTrailerBlock;
// Set the authentication information (uid)
memcpy(mp.mpa.abtAuthUid, nt.nti.nai.abtUid + nt.nti.nai.szUidLen - 4, 4);
@ -196,6 +195,7 @@ authenticate(uint32_t uiBlock)
if (bUseKeyFile) {
// Locate the trailer (with the keys) used for this sector
uint32_t uiTrailerBlock;
uiTrailerBlock = get_trailer_block(uiBlock);
// Extract the right key from dump file