From 4a918591500ca01d324015183636f28ca949663b Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 22 Sep 2013 12:02:31 +0200 Subject: [PATCH] Fix unharmful warning Commit 54729fb4581d8cbe722292eb3ba73e76711bd461 removed some dead code spotted by Coverity but it had as effect to trigger a gcc warning, which prefers to see all enum in a switch rather than dead code: pn53x.c: In function 'pn53x_InJumpForDEP': pn53x.c:2552:5: warning: enumeration value 'NBR_UNDEFINED' not handled in switch [-Wswitch] pn53x.c:2552:5: warning: enumeration value 'NBR_847' not handled in switch [-Wswitch] So both switches were merged, which slightly optimizes the code for speed. --- libnfc/chips/pn53x.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 36a7a03..0cedca8 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -2534,12 +2534,27 @@ pn53x_InJumpForDEP(struct nfc_device *pnd, switch (nbr) { case NBR_106: abtCmd[2] = 0x00; // baud rate is 106 kbps + if (pbtPassiveInitiatorData && (ndm == NDM_PASSIVE)) { /* can't have passive initiator data when using active mode */ + abtCmd[3] |= 0x01; + memcpy(abtCmd + offset, pbtPassiveInitiatorData, 4); + offset += 4; + } break; case NBR_212: abtCmd[2] = 0x01; // baud rate is 212 kbps + if (pbtPassiveInitiatorData && (ndm == NDM_PASSIVE)) { + abtCmd[3] |= 0x01; + memcpy(abtCmd + offset, pbtPassiveInitiatorData, 5); + offset += 5; + } break; case NBR_424: abtCmd[2] = 0x02; // baud rate is 424 kbps + if (pbtPassiveInitiatorData && (ndm == NDM_PASSIVE)) { + abtCmd[3] |= 0x01; + memcpy(abtCmd + offset, pbtPassiveInitiatorData, 5); + offset += 5; + } break; case NBR_847: case NBR_UNDEFINED: @@ -2548,22 +2563,6 @@ pn53x_InJumpForDEP(struct nfc_device *pnd, break; } - if (pbtPassiveInitiatorData && (ndm == NDM_PASSIVE)) { /* can't have passive initiator data when using active mode */ - switch (nbr) { - case NBR_106: - abtCmd[3] |= 0x01; - memcpy(abtCmd + offset, pbtPassiveInitiatorData, 4); - offset += 4; - break; - case NBR_212: - case NBR_424: - abtCmd[3] |= 0x01; - memcpy(abtCmd + offset, pbtPassiveInitiatorData, 5); - offset += 5; - break; - } - } - if (pbtNFCID3i) { abtCmd[3] |= 0x02; memcpy(abtCmd + offset, pbtNFCID3i, 10);