From 5f6b8717a4ad0938751dabbf99fe538722490e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Redon?= Date: Wed, 11 Jul 2018 09:49:06 +0200 Subject: [PATCH] fix 'ISO_S_IN_ATR not handled' gcc warning when building the cardem application GCC would output the following warning: libcommon/source/card_emu.c: In function 'card_emu_process_rx_byte': libcommon/source/card_emu.c:764:2: warning: enumeration value 'ISO_S_IN_ATR' not handled in switch [-Wswitch] switch (ch->state) { ^~~~~~ in card emulation the reader should not send data while the card is sending its ATR. this is true for other states already handled (RESET, ...). in these cases an error message is output. this behaviour is now the default case as data from the reader is only expected in 3 cases: ISO_S_WAIT_TPDU, ISO_S_IN_TPDU, and ISO_S_IN_PTS. Change-Id: Ifbc8dbe1c9f176343304f211c7e6068fb977961e --- firmware/libcommon/source/card_emu.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/firmware/libcommon/source/card_emu.c b/firmware/libcommon/source/card_emu.c index 92910649..94a601ad 100644 --- a/firmware/libcommon/source/card_emu.c +++ b/firmware/libcommon/source/card_emu.c @@ -762,14 +762,6 @@ void card_emu_process_rx_byte(struct card_handle *ch, uint8_t byte) ch->stats.rx_bytes++; switch (ch->state) { - case ISO_S_WAIT_POWER: - case ISO_S_WAIT_CLK: - case ISO_S_WAIT_RST: - case ISO_S_WAIT_ATR: - TRACE_ERROR("%u: Received UART char in invalid 7816 state " - "%u\r\n", ch->num, ch->state); - /* we shouldn't receive any data from the reader yet! */ - break; case ISO_S_WAIT_TPDU: if (byte == 0xff) { new_state = process_byte_pts(ch, byte); @@ -783,6 +775,10 @@ void card_emu_process_rx_byte(struct card_handle *ch, uint8_t byte) case ISO_S_IN_PTS: new_state = process_byte_pts(ch, byte); goto out_silent; + default: + TRACE_ERROR("%u: Received UART char in invalid 7816 state " + "%u\r\n", ch->num, ch->state); + break; } out_silent: