add some whitespaces

This commit is contained in:
Audrey Diacre 2012-01-20 09:17:38 +00:00
parent 838faa8d7e
commit 5a475cf074
7 changed files with 34 additions and 34 deletions

View file

@ -176,7 +176,7 @@ main(int argc, char *argv[])
};
struct nfc_emulator emulator = {
.target= &nt,
.target = &nt,
.state_machine = &state_machine,
.user_data = __nfcforum_tag2_memory_area,
};

View file

@ -80,7 +80,7 @@ int main(int argc, const char* argv[])
FILE* input = NULL;
if (argc >= 2) {
if((input=fopen(argv[1], "r"))==NULL) {
if((input = fopen(argv[1], "r"))==NULL) {
ERR ("%s", "Cannot open file.");
return EXIT_FAILURE;
}
@ -105,12 +105,12 @@ int main(int argc, const char* argv[])
char *cmd;
char *prompt = "> ";
while(1) {
int offset=0;
int offset = 0;
#if defined(HAVE_READLINE)
if (input==NULL) { // means we use stdin
cmd=readline(prompt);
if (input == NULL) { // means we use stdin
cmd = readline(prompt);
// NULL if ctrl-d
if (cmd==NULL) {
if (cmd == NULL) {
printf("Bye!\n");
break;
}
@ -137,18 +137,18 @@ int main(int argc, const char* argv[])
#if defined(HAVE_READLINE)
}
#endif //HAVE_READLINE
if (cmd[0]=='q') {
if (cmd[0] == 'q') {
printf("Bye!\n");
free(cmd);
break;
}
if (cmd[0]=='p') {
int s=0;
if (cmd[0] == 'p') {
int s = 0;
offset++;
while (isspace(cmd[offset])) {
offset++;
}
sscanf(cmd+offset, "%d", &s);
sscanf(cmd + offset, "%d", &s);
printf("Pause for %i msecs\n", s);
if (s>0) {
sleep(s * SUSP_TIME);
@ -157,14 +157,14 @@ int main(int argc, const char* argv[])
continue;
}
szTx = 0;
for(int i = 0; i<MAX_FRAME_LEN-10; i++) {
for(int i = 0; i < MAX_FRAME_LEN - 10; i++) {
int size;
uint8_t byte;
while (isspace(cmd[offset])) {
offset++;
}
size = sscanf(cmd+offset, "%2x", (unsigned int*)&byte);
if (size<1) {
if (size < 1 ) {
break;
}
abtTx[i] = byte;

View file

@ -1088,7 +1088,7 @@ pn53x_initiator_poll_target (struct nfc_device *pnd,
if (CHIP_DATA(pnd)->type == PN532) {
size_t szTargetTypes = 0;
pn53x_target_type apttTargetTypes[32];
for (size_t n=0; n<szModulations; n++) {
for (size_t n = 0; n < szModulations; n++) {
const pn53x_target_type ptt = pn53x_nm_to_ptt(pnmModulations[n]);
if (PTT_UNDEFINED == ptt) {
pnd->last_error = NFC_EINVARG;
@ -1122,8 +1122,8 @@ pn53x_initiator_poll_target (struct nfc_device *pnd,
pn53x_set_property_bool (pnd, NP_INFINITE_SELECT, true);
// FIXME It does not support DEP targets
do {
for (size_t p=0; p<uiPollNr; p++) {
for (size_t n=0; n<szModulations; n++) {
for (size_t p = 0; p < uiPollNr; p++) {
for (size_t n = 0; n < szModulations; n++) {
uint8_t *pbtInitiatorData;
size_t szInitiatorData;
prepare_initiator_data (pnmModulations[n], &pbtInitiatorData, &szInitiatorData);
@ -1421,7 +1421,7 @@ pn53x_initiator_transceive_bits_timed (struct nfc_device *pnd, const uint8_t *pb
BUFFER_APPEND (abtWriteRegisterCmd, PN53X_REG_CIU_FIFOLevel >> 8);
BUFFER_APPEND (abtWriteRegisterCmd, PN53X_REG_CIU_FIFOLevel & 0xff);
BUFFER_APPEND (abtWriteRegisterCmd, SYMBOL_FLUSH_BUFFER);
for (i=0; i< ((szTxBits / 8) + 1); i++) {
for (i = 0; i < ((szTxBits / 8) + 1); i++) {
BUFFER_APPEND (abtWriteRegisterCmd, PN53X_REG_CIU_FIFOData >> 8);
BUFFER_APPEND (abtWriteRegisterCmd, PN53X_REG_CIU_FIFOData & 0xff);
BUFFER_APPEND (abtWriteRegisterCmd, pbtTx[i]);
@ -1440,7 +1440,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;
@ -1453,7 +1453,7 @@ pn53x_initiator_transceive_bits_timed (struct nfc_device *pnd, const uint8_t *pb
while (1) {
BUFFER_INIT (abtReadRegisterCmd, PN53x_EXTENDED_FRAME__DATA_MAX_LEN);
BUFFER_APPEND (abtReadRegisterCmd, ReadRegister);
for (i=0; i<sz; i++) {
for (i = 0; i < sz; i++) {
BUFFER_APPEND (abtReadRegisterCmd, PN53X_REG_CIU_FIFOData >> 8);
BUFFER_APPEND (abtReadRegisterCmd, PN53X_REG_CIU_FIFOData & 0xff);
}
@ -1515,7 +1515,7 @@ pn53x_initiator_transceive_bytes_timed (struct nfc_device *pnd, const uint8_t *p
BUFFER_APPEND (abtWriteRegisterCmd, PN53X_REG_CIU_FIFOLevel >> 8);
BUFFER_APPEND (abtWriteRegisterCmd, PN53X_REG_CIU_FIFOLevel & 0xff);
BUFFER_APPEND (abtWriteRegisterCmd, SYMBOL_FLUSH_BUFFER);
for (i=0; i< szTx; i++) {
for (i = 0; i < szTx; i++) {
BUFFER_APPEND (abtWriteRegisterCmd, PN53X_REG_CIU_FIFOData >> 8);
BUFFER_APPEND (abtWriteRegisterCmd, PN53X_REG_CIU_FIFOData & 0xff);
BUFFER_APPEND (abtWriteRegisterCmd, pbtTx[i]);
@ -1535,7 +1535,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;
@ -1548,7 +1548,7 @@ pn53x_initiator_transceive_bytes_timed (struct nfc_device *pnd, const uint8_t *p
while (1) {
BUFFER_INIT (abtReadRegisterCmd, PN53x_EXTENDED_FRAME__DATA_MAX_LEN);
BUFFER_APPEND (abtReadRegisterCmd, ReadRegister);
for (i=0; i<sz; i++) {
for (i = 0; i < sz; i++) {
BUFFER_APPEND (abtReadRegisterCmd, PN53X_REG_CIU_FIFOData >> 8);
BUFFER_APPEND (abtReadRegisterCmd, PN53X_REG_CIU_FIFOData & 0xff);
}

View file

@ -165,7 +165,7 @@ test_dep (void)
.cut_test_context = test_context,
};
for (int i=0; i<3; i++) {
for (int i = 0; i < 3; i++) {
initiator_data.nbr = nbrs[i];
if ((res = pthread_create (&(threads[TARGET]), NULL, target_thread, &target_data)))

View file

@ -344,7 +344,7 @@ main (int argc, char *argv[])
transmit_bytes (abtWrite,4);
transmit_bytes (abtData,18);
if(format) {
for(i= 3 ; i < 64 ; i += 4) {
for(i = 3 ; i < 64 ; i += 4) {
abtWrite[1]= (char) i;
iso14443a_crc_append (abtWrite, 2);
transmit_bytes (abtWrite,4);

View file

@ -98,7 +98,7 @@ nfc_forum_tag_type3_check (nfc_device *pnd, const nfc_target nt, const uint16_t
};
size_t payload_len = 1 + 2 + 1;
for (uint8_t b=0; b<block_count; b++) {
for (uint8_t b = 0; b < block_count; b++) {
if (block < 0x100) {
payload[payload_len++] = 0x80;
payload[payload_len++] = block + b;
@ -120,7 +120,7 @@ nfc_forum_tag_type3_check (nfc_device *pnd, const nfc_target nt, const uint16_t
return -1;
}
const size_t res_overhead = 1 + 1 + 8 + 2; // 1+1+8+2: LEN + CMD + NFCID2 + STATUS
if (res_len<res_overhead) {
if (res_len < res_overhead) {
// Not enough data
return -1;
}
@ -277,7 +277,7 @@ main(int argc, char *argv[])
fprintf (message_stream, "NDEF data lenght: %d bytes\n", ndef_data_len);
uint16_t ndef_calculated_checksum = 0;
for (size_t n=0; n<14; n++)
for (size_t n = 0; n < 14; n++)
ndef_calculated_checksum += data[n];
const uint16_t ndef_checksum = (data[14] << 8) + data[15];
@ -297,7 +297,7 @@ main(int argc, char *argv[])
const uint16_t block_count_to_check = (ndef_data_len / 16) + 1;
data_len = 0;
for (uint16_t b=0; b<(block_count_to_check/block_max_per_check); b+=block_max_per_check) {
for (uint16_t b = 0; b < (block_count_to_check/block_max_per_check); b += block_max_per_check) {
size_t len = sizeof(data) - data_len;
if(!nfc_forum_tag_type3_check (pnd, nt, 1+b, MIN(block_max_per_check, (block_count_to_check-(b*block_max_per_check))), data + data_len, &len)) {
nfc_perror (pnd, "nfc_forum_tag_type3_check");

View file

@ -98,16 +98,16 @@ bool print_hex_fd4 (const uint8_t *pbtData, const size_t szBytes, const char *pc
if (szBytes > MAX_FRAME_LEN) {
return EXIT_FAILURE;
}
if (fprintf (fd4, "#%s %04zx: ", pchPrefix, szBytes)<0) {
if (fprintf (fd4, "#%s %04zx: ", pchPrefix, szBytes) < 0) {
return EXIT_FAILURE;
}
for (szPos = 0; szPos < szBytes; szPos++) {
if (fprintf (fd4, "%02x ", pbtData[szPos])<0) {
if (fprintf (fd4, "%02x ", pbtData[szPos]) < 0) {
return EXIT_FAILURE;
}
}
if (fprintf (fd4, "\n")<0) {
if (fprintf (fd4, "\n") < 0) {
return EXIT_FAILURE;
}
fflush(fd4);
@ -129,7 +129,7 @@ bool scan_hex_fd3 (uint8_t *pbtData, size_t *pszBytes, const char *pchPrefix)
}
strncpy(pchScan, pchPrefix, 250);
strcat(pchScan, " %04x:");
if (fscanf (fd3, pchScan, &uiBytes)<1) {
if (fscanf (fd3, pchScan, &uiBytes) < 1) {
return EXIT_FAILURE;
}
*pszBytes=uiBytes;
@ -137,7 +137,7 @@ bool scan_hex_fd3 (uint8_t *pbtData, size_t *pszBytes, const char *pchPrefix)
return EXIT_FAILURE;
}
for (szPos = 0; szPos < *pszBytes; szPos++) {
if (fscanf (fd3, "%02x", &uiData)<1) {
if (fscanf (fd3, "%02x", &uiData) < 1) {
return EXIT_FAILURE;
}
pbtData[szPos]=uiData;
@ -168,7 +168,7 @@ main (int argc, char *argv[])
initiator_only_mode = true;
target_only_mode = false;
} else if (0 == strcmp (argv[arg], "-n")) {
if (++arg==argc || (sscanf(argv[arg], "%i", &waiting_time)<1)) {
if (++arg == argc || (sscanf(argv[arg], "%i", &waiting_time) < 1)) {
ERR ("Missing or wrong waiting time value: %s.", argv[arg]);
print_usage (argv);
return EXIT_FAILURE;