From bfcdb1bd4cd6cff9650f6288d94024c7ba8c059e Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Wed, 16 May 2012 18:08:42 +0000 Subject: [PATCH] Fix more warnings while using -Wswitch-enum and -Wshadow on internal libnfc files --- libnfc/drivers/acr122_usb.c | 2 +- libnfc/drivers/pn53x_usb.c | 15 +++++++++++---- libnfc/nfc-device.c | 8 ++++---- libnfc/nfc-internal.c | 4 +++- libnfc/nfc.c | 8 +++++++- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/libnfc/drivers/acr122_usb.c b/libnfc/drivers/acr122_usb.c index 1abb99f..7f1f60f 100644 --- a/libnfc/drivers/acr122_usb.c +++ b/libnfc/drivers/acr122_usb.c @@ -408,7 +408,7 @@ acr122_usb_open (const nfc_connstring connstring) case TOUCHATAG: CHIP_DATA (pnd)->timer_correction = 50; break; - default: + case UNKNOWN: break; } pnd->driver = &acr122_usb_driver; diff --git a/libnfc/drivers/pn53x_usb.c b/libnfc/drivers/pn53x_usb.c index eeff690..7c2cdb5 100644 --- a/libnfc/drivers/pn53x_usb.c +++ b/libnfc/drivers/pn53x_usb.c @@ -224,7 +224,7 @@ pn53x_usb_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t *p usb_dev_handle *udev = usb_open (dev); // Set configuration - int res = usb_set_configuration (udev, 1); + res = usb_set_configuration (udev, 1); if (res < 0) { log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "Unable to set USB configuration (%s)", _usb_strerror (res)); usb_close (udev); @@ -362,7 +362,7 @@ pn53x_usb_open (const nfc_connstring connstring) // Retrieve end points pn53x_usb_get_end_points (dev, &data); // Set configuration - int res = usb_set_configuration (data.pudh, 1); + res = usb_set_configuration (data.pudh, 1); if (res < 0) { log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "Unable to set USB configuration (%s)", _usb_strerror (res)); if (EPERM == -res) { @@ -406,7 +406,9 @@ pn53x_usb_open (const nfc_connstring connstring) case SONY_PN531: CHIP_DATA (pnd)->timer_correction = 54; break; - default: + case SONY_RCS360: + case UNKNOWN: + CHIP_DATA (pnd)->timer_correction = 0; // TODO: allow user to know if timed functions are available break; } pnd->driver = &pn53x_usb_driver; @@ -731,7 +733,12 @@ pn53x_usb_set_property_bool (nfc_device *pnd, const nfc_property property, const return res; } break; - default: + case NXP_PN531: + case NXP_PN533: + case SONY_PN531: + case SONY_RCS360: + case UNKNOWN: + // Nothing to do. break; } return NFC_SUCCESS; diff --git a/libnfc/nfc-device.c b/libnfc/nfc-device.c index b19dec6..db576f0 100644 --- a/libnfc/nfc-device.c +++ b/libnfc/nfc-device.c @@ -59,10 +59,10 @@ nfc_device_new (const nfc_connstring connstring) } void -nfc_device_free (nfc_device *nfc_device) +nfc_device_free (nfc_device *dev) { - if (nfc_device) { - free (nfc_device->driver_data); - free (nfc_device); + if (dev) { + free (dev->driver_data); + free (dev); } } diff --git a/libnfc/nfc-internal.c b/libnfc/nfc-internal.c index fe669eb..c52ef52 100644 --- a/libnfc/nfc-internal.c +++ b/libnfc/nfc-internal.c @@ -59,7 +59,9 @@ prepare_initiator_data (const nfc_modulation nm, uint8_t **ppbtInitiatorData, si *pszInitiatorData = 5; } break; - default: + case NMT_ISO14443A: + case NMT_JEWEL: + case NMT_DEP: *ppbtInitiatorData = NULL; *pszInitiatorData = 0; break; diff --git a/libnfc/nfc.c b/libnfc/nfc.c index 78f1538..7709acf 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -404,7 +404,13 @@ nfc_initiator_select_passive_target (nfc_device *pnd, iso14443_cascade_uid (pbtInitData, szInitData, abtInit, &szInit); break; - default: + case NMT_JEWEL: + case NMT_ISO14443B: + case NMT_ISO14443BI: + case NMT_ISO14443B2SR: + case NMT_ISO14443B2CT: + case NMT_FELICA: + case NMT_DEP: memcpy (abtInit, pbtInitData, szInitData); szInit = szInitData; break;