master moved from 2d4543673e9b to 6b7432336951
4 new revisions:
Revision: 7adad098c351
Author: Philippe Teuwen <
yob...@gmail.com>
Date: Tue Mar 4 00:33:44 2014 UTC
Log: Document -Wunreachable-code in HACKING file
http://code.google.com/p/libnfc/source/detail?r=7adad098c351
Revision: db4fae9c2ce8
Author: Philippe Teuwen <
yob...@gmail.com>
Date: Tue Mar 4 00:27:01 2014 UTC
Log: Remove unreachable statements...
http://code.google.com/p/libnfc/source/detail?r=db4fae9c2ce8
Revision: 6ab3c368b8cc
Author: Philippe Teuwen <
yob...@gmail.com>
Date: Tue Mar 4 00:41:01 2014 UTC
Log: nfc-emulate-uid: remove unreachable code and add proper cleaning
when ...
http://code.google.com/p/libnfc/source/detail?r=6ab3c368b8cc
Revision: 6b7432336951
Author: Philippe Teuwen <
yob...@gmail.com>
Date: Tue Mar 4 00:47:42 2014 UTC
Log: target_is_present(): remove unreachable code
http://code.google.com/p/libnfc/source/detail?r=6b7432336951
==============================================================================
Revision: 7adad098c351
Author: Philippe Teuwen <
yob...@gmail.com>
Date: Tue Mar 4 00:33:44 2014 UTC
Log: Document -Wunreachable-code in HACKING file
http://code.google.com/p/libnfc/source/detail?r=7adad098c351
Modified:
/HACKING
=======================================
--- /HACKING Fri Apr 5 09:43:47 2013 UTC
+++ /HACKING Tue Mar 4 00:33:44 2014 UTC
@@ -34,6 +34,7 @@
$ make clean
$ make
2.2.2 Using clang:
+ You can use same CFLAGS but also "-Wunreachable-code"
$ scan-build ./configure
$ make clean
$ scan-build make
==============================================================================
Revision: db4fae9c2ce8
Author: Philippe Teuwen <
yob...@gmail.com>
Date: Tue Mar 4 00:27:01 2014 UTC
Log: Remove unreachable statements
As seen with clang -Wunreachable-code
http://code.google.com/p/libnfc/source/detail?r=db4fae9c2ce8
Modified:
/libnfc/chips/pn53x.c
/libnfc/nfc.c
/utils/jewel.c
/utils/mifare.c
/utils/nfc-read-forum-tag3.c
=======================================
--- /libnfc/chips/pn53x.c Sun Feb 9 23:01:34 2014 UTC
+++ /libnfc/chips/pn53x.c Tue Mar 4 00:27:01 2014 UTC
@@ -607,7 +607,6 @@
// Should not happend...
case NMT_DEP:
return NFC_ECHIP;
- break;
}
return NFC_SUCCESS;
}
@@ -820,11 +819,9 @@
case NP_TIMEOUT_ATR:
CHIP_DATA(pnd)->timeout_atr = value;
return pn53x_RFConfiguration__Various_timings(pnd,
pn53x_int_to_timeout(CHIP_DATA(pnd)->timeout_atr),
pn53x_int_to_timeout(CHIP_DATA(pnd)->timeout_communication));
- break;
case NP_TIMEOUT_COM:
CHIP_DATA(pnd)->timeout_communication = value;
return pn53x_RFConfiguration__Various_timings(pnd,
pn53x_int_to_timeout(CHIP_DATA(pnd)->timeout_atr),
pn53x_int_to_timeout(CHIP_DATA(pnd)->timeout_communication));
- break;
// Following properties are invalid (not integer)
case NP_HANDLE_CRC:
case NP_HANDLE_PARITY:
@@ -863,7 +860,6 @@
return res;
pnd->bCrc = bEnable;
return NFC_SUCCESS;
- break;
case NP_HANDLE_PARITY:
// Handle parity bit by PN53X chip or parse it as data bit
@@ -875,21 +871,17 @@
return res;
pnd->bPar = bEnable;
return NFC_SUCCESS;
- break;
case NP_EASY_FRAMING:
pnd->bEasyFraming = bEnable;
return NFC_SUCCESS;
- break;
case NP_ACTIVATE_FIELD:
return pn53x_RFConfiguration__RF_field(pnd, bEnable);
- break;
case NP_ACTIVATE_CRYPTO1:
btValue = (bEnable) ? SYMBOL_MF_CRYPTO1_ON : 0x00;
return pn53x_write_register(pnd, PN53X_REG_CIU_Status2,
SYMBOL_MF_CRYPTO1_ON, btValue);
- break;
case NP_INFINITE_SELECT:
// TODO Made some research around this point:
@@ -901,17 +893,14 @@
(bEnable) ? 0xff :
0x01, // MxRtyPSL, default: 0x01
(bEnable) ? 0xff :
0x02 // MxRtyPassiveActivation, default: 0xff (0x00 leads to
problems with PN531)
);
- break;
case NP_ACCEPT_INVALID_FRAMES:
btValue = (bEnable) ? SYMBOL_RX_NO_ERROR : 0x00;
return pn53x_write_register(pnd, PN53X_REG_CIU_RxMode,
SYMBOL_RX_NO_ERROR, btValue);
- break;
case NP_ACCEPT_MULTIPLE_FRAMES:
btValue = (bEnable) ? SYMBOL_RX_MULTIPLE : 0x00;
return pn53x_write_register(pnd, PN53X_REG_CIU_RxMode,
SYMBOL_RX_MULTIPLE, btValue);
- break;
case NP_AUTO_ISO14443_4:
if (bEnable == pnd->bAutoIso14443_4)
@@ -919,7 +908,6 @@
return NFC_SUCCESS;
pnd->bAutoIso14443_4 = bEnable;
return pn53x_set_parameters(pnd, PARAM_AUTO_RATS, bEnable);
- break;
case NP_FORCE_ISO14443_A:
if (!bEnable) {
@@ -935,7 +923,6 @@
}
// Set the PN53X to force 100% ASK Modified miller decoding (default
for 14443A cards)
return pn53x_write_register(pnd, PN53X_REG_CIU_TxAuto,
SYMBOL_FORCE_100_ASK, 0x40);
- break;
case NP_FORCE_ISO14443_B:
if (!bEnable) {
@@ -947,7 +934,6 @@
return res;
}
return pn53x_write_register(pnd, PN53X_REG_CIU_RxMode,
SYMBOL_RX_FRAMING, 0x03);
- break;
case NP_FORCE_SPEED_106:
if (!bEnable) {
@@ -959,13 +945,11 @@
return res;
}
return pn53x_write_register(pnd, PN53X_REG_CIU_RxMode,
SYMBOL_RX_SPEED, 0x00);
- break;
// Following properties are invalid (not boolean)
case NP_TIMEOUT_COMMAND:
case NP_TIMEOUT_ATR:
case NP_TIMEOUT_COM:
return NFC_EINVARG;
- break;
}
return NFC_EINVARG;
@@ -1231,17 +1215,14 @@
return pnd->last_error = NFC_ESOFT;
}
return res;
- break;
case 2:
*pnt = ntTargets[1]; // We keep the selected one
if (pn53x_current_target_new(pnd, pnt) == NULL) {
return pnd->last_error = NFC_ESOFT;
}
return res;
- break;
default:
return NFC_ECHIP;
- break;
}
} else {
bool bInfiniteSelect = pnd->bInfiniteSelect;
@@ -1303,7 +1284,6 @@
case NBR_847:
case NBR_UNDEFINED:
return NFC_EINVARG;
- break;
}
pn53x_current_target_free(pnd);
@@ -2150,7 +2130,6 @@
case NMT_JEWEL:
pnd->last_error = NFC_EDEVNOTSUPP;
return pnd->last_error;
- break;
}
// Let the PN53X be activated by the RF level detector from power down
mode
@@ -2252,7 +2231,6 @@
case NMT_JEWEL:
pnd->last_error = NFC_EDEVNOTSUPP;
return pnd->last_error;
- break;
}
bool targetActivated = false;
@@ -2911,7 +2889,6 @@
case NBR_UNDEFINED:
pnd->last_error = NFC_EINVARG;
return pnd->last_error;
- break;
}
if (pbtNFCID3i) {
@@ -3128,22 +3105,17 @@
switch (nm.nmt) {
case NMT_ISO14443A:
return PM_ISO14443A_106;
- break;
case NMT_ISO14443B:
switch (nm.nbr) {
case NBR_106:
return PM_ISO14443B_106;
- break;
case NBR_212:
return PM_ISO14443B_212;
- break;
case NBR_424:
return PM_ISO14443B_424;
- break;
case NBR_847:
return PM_ISO14443B_847;
- break;
case NBR_UNDEFINED:
// Nothing to do...
break;
@@ -3152,16 +3124,13 @@
case NMT_JEWEL:
return PM_JEWEL_106;
- break;
case NMT_FELICA:
switch (nm.nbr) {
case NBR_212:
return PM_FELICA_212;
- break;
case NBR_424:
return PM_FELICA_424;
- break;
case NBR_106:
case NBR_847:
case NBR_UNDEFINED:
@@ -3194,36 +3163,31 @@
case PTT_MIFARE:
case PTT_ISO14443_4A_106:
return (const nfc_modulation) { .nmt = NMT_ISO14443A, .nbr = NBR_106
};
- break;
case PTT_ISO14443_4B_106:
case PTT_ISO14443_4B_TCL_106:
return (const nfc_modulation) { .nmt = NMT_ISO14443B, .nbr = NBR_106
};
- break;
case PTT_JEWEL_106:
return (const nfc_modulation) { .nmt = NMT_JEWEL, .nbr = NBR_106 };
- break;
case PTT_FELICA_212:
return (const nfc_modulation) { .nmt = NMT_FELICA, .nbr = NBR_212 };
- break;
+
case PTT_FELICA_424:
return (const nfc_modulation) { .nmt = NMT_FELICA, .nbr = NBR_424 };
- break;
case PTT_DEP_PASSIVE_106:
case PTT_DEP_ACTIVE_106:
return (const nfc_modulation) { .nmt = NMT_DEP, .nbr = NBR_106 };
- break;
+
case PTT_DEP_PASSIVE_212:
case PTT_DEP_ACTIVE_212:
return (const nfc_modulation) { .nmt = NMT_DEP, .nbr = NBR_212 };
- break;
+
case PTT_DEP_PASSIVE_424:
case PTT_DEP_ACTIVE_424:
return (const nfc_modulation) { .nmt = NMT_DEP, .nbr = NBR_424 };
- break;
}
// We should never be here, this line silent compilation warning
return (const nfc_modulation) { .nmt = NMT_ISO14443A, .nbr = NBR_106 };
@@ -3236,13 +3200,12 @@
case NMT_ISO14443A:
return PTT_MIFARE;
// return PTT_ISO14443_4A_106;
- break;
case NMT_ISO14443B:
switch (nm.nbr) {
case NBR_106:
return PTT_ISO14443_4B_106;
- break;
+
case NBR_UNDEFINED:
case NBR_212:
case NBR_424:
@@ -3254,16 +3217,15 @@
case NMT_JEWEL:
return PTT_JEWEL_106;
- break;
case NMT_FELICA:
switch (nm.nbr) {
case NBR_212:
return PTT_FELICA_212;
- break;
+
case NBR_424:
return PTT_FELICA_424;
- break;
+
case NBR_UNDEFINED:
case NBR_106:
case NBR_847:
=======================================
--- /libnfc/nfc.c Mon Feb 10 00:07:11 2014 UTC
+++ /libnfc/nfc.c Tue Mar 4 00:27:01 2014 UTC
@@ -1260,22 +1260,15 @@
switch (nbr) {
case NBR_UNDEFINED:
return "undefined baud rate";
- break;
case NBR_106:
return "106 kbps";
- break;
case NBR_212:
return "212 kbps";
- break;
case NBR_424:
return "424 kbps";
- break;
case NBR_847:
return "847 kbps";
- break;
}
- // Should never go there..
- return "";
}
/** @ingroup string-converter
@@ -1289,31 +1282,21 @@
switch (nmt) {
case NMT_ISO14443A:
return "ISO/IEC 14443A";
- break;
case NMT_ISO14443B:
return "ISO/IEC 14443-4B";
- break;
case NMT_ISO14443BI:
return "ISO/IEC 14443-4B'";
- break;
case NMT_ISO14443B2CT:
return "ISO/IEC 14443-2B ASK CTx";
- break;
case NMT_ISO14443B2SR:
return "ISO/IEC 14443-2B ST SRx";
- break;
case NMT_FELICA:
return "FeliCa";
- break;
case NMT_JEWEL:
return "Innovision Jewel";
- break;
case NMT_DEP:
return "D.E.P.";
- break;
}
- // Should never go there..
- return "";
}
/** @ingroup string-converter
=======================================
--- /utils/jewel.c Sun Feb 2 23:04:08 2014 UTC
+++ /utils/jewel.c Tue Mar 4 00:27:01 2014 UTC
@@ -97,7 +97,6 @@
break;
default:
return false;
- break;
}
if (nfc_initiator_transceive_bytes(pnd, (uint8_t *)&req, nLenReq,
(uint8_t *)pres, nLenRes, -1) < 0) {
=======================================
--- /utils/mifare.c Wed Jul 17 11:57:56 2013 UTC
+++ /utils/mifare.c Tue Mar 4 00:27:01 2014 UTC
@@ -95,7 +95,6 @@
// Please fix your code, you never should reach this statement
default:
return false;
- break;
}
// When available, copy the parameter bytes
=======================================
--- /utils/nfc-read-forum-tag3.c Mon Feb 17 23:01:43 2014 UTC
+++ /utils/nfc-read-forum-tag3.c Tue Mar 4 00:27:01 2014 UTC
@@ -178,7 +178,6 @@
case 'h':
print_usage(argv[0]);
exit(EXIT_SUCCESS);
- break;
case 'q':
quiet = true;
break;
==============================================================================
Revision: 6ab3c368b8cc
Author: Philippe Teuwen <
yob...@gmail.com>
Date: Tue Mar 4 00:41:01 2014 UTC
Log: nfc-emulate-uid: remove unreachable code and add proper cleaning
when interrupted
http://code.google.com/p/libnfc/source/detail?r=6ab3c368b8cc
Modified:
/examples/nfc-emulate-uid.c
=======================================
--- /examples/nfc-emulate-uid.c Wed Jul 17 11:57:56 2013 UTC
+++ /examples/nfc-emulate-uid.c Tue Mar 4 00:41:01 2014 UTC
@@ -79,7 +79,10 @@
if (pnd != NULL) {
printf("\nAborting current command...\n");
nfc_abort_command(pnd);
+ nfc_close(pnd);
}
+ nfc_exit(context);
+ exit(EXIT_SUCCESS);
}
static void
@@ -237,7 +240,4 @@
}
}
}
- nfc_close(pnd);
- nfc_exit(context);
- exit(EXIT_SUCCESS);
}
==============================================================================
Revision: 6b7432336951
Author: Philippe Teuwen <
yob...@gmail.com>
Date: Tue Mar 4 00:47:42 2014 UTC
Log: target_is_present(): remove unreachable code
http://code.google.com/p/libnfc/source/detail?r=6b7432336951
Modified:
/libnfc/chips/pn53x.c
=======================================
--- /libnfc/chips/pn53x.c Tue Mar 4 00:27:01 2014 UTC
+++ /libnfc/chips/pn53x.c Tue Mar 4 00:47:42 2014 UTC
@@ -2036,7 +2036,7 @@
}
// Ping target
- int ret;
+ int ret = NFC_EDEVNOTSUPP;
switch (CHIP_DATA(pnd)->current_target->nm.nmt) {
case NMT_ISO14443A:
if (CHIP_DATA(pnd)->current_target->nti.nai.btSak & 0x20) {
@@ -2073,10 +2073,6 @@
case NMT_ISO14443B2CT:
ret = pn53x_ISO14443B_CT_is_present(pnd);
break;
- default:
- log_put(LOG_GROUP, LOG_CATEGORY,
NFC_LOG_PRIORITY_DEBUG, "%s", "target_is_present(): card type not
supported");
- ret = NFC_EDEVNOTSUPP;
- break;
}
if (ret == NFC_ETGRELEASED)
pn53x_current_target_free(pnd);