From 5027d69b7e38f90ef1249c42d448ba5fc46762cc Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Sat, 26 Jun 2010 13:48:25 +0000 Subject: [PATCH] Silent down gcc44 -Wextra warnings. --- examples/mifare-classic-format.c | 4 +++- examples/mifare-classic-write-ndef.c | 4 ++-- libfreefare/freefare.c | 4 ++-- libfreefare/mifare_application.c | 4 ++-- libfreefare/mifare_classic.c | 6 +++--- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/mifare-classic-format.c b/examples/mifare-classic-format.c index bdea72e..5254fac 100644 --- a/examples/mifare-classic-format.c +++ b/examples/mifare-classic-format.c @@ -90,7 +90,7 @@ int try_format_sector (MifareTag tag, MifareClassicBlockNumber block) { display_progress (); - for (int i = 0; i < (sizeof (default_keys) / sizeof (MifareClassicKey)); i++) { + for (size_t i = 0; i < (sizeof (default_keys) / sizeof (MifareClassicKey)); i++) { if ((0 == mifare_classic_connect (tag)) && (0 == mifare_classic_authenticate (tag, block, default_keys[i], MFC_KEY_A))) { if (0 == mifare_classic_format_sector (tag, block)) { mifare_classic_disconnect (tag); @@ -123,6 +123,8 @@ main(int argc, char *argv[]) nfc_device_t *device = NULL; MifareTag *tags = NULL; + (void)argc, (void)argv; + device = nfc_connect (NULL); if (!device) errx (EXIT_FAILURE, "No NFC device found."); diff --git a/examples/mifare-classic-write-ndef.c b/examples/mifare-classic-write-ndef.c index 8728799..cb9c850 100644 --- a/examples/mifare-classic-write-ndef.c +++ b/examples/mifare-classic-write-ndef.c @@ -58,7 +58,7 @@ int search_sector_key (MifareTag tag, MifareClassicBlockNumber block, MifareClassicKey *key, MifareClassicKeyType *key_type) { mifare_classic_disconnect (tag); - for (int i = 0; i < (sizeof (default_keys) / sizeof (MifareClassicKey)); i++) { + for (size_t i = 0; i < (sizeof (default_keys) / sizeof (MifareClassicKey)); i++) { if ((0 == mifare_classic_connect (tag)) && (0 == mifare_classic_authenticate (tag, block, default_keys[i], MFC_KEY_A))) { if ((1 == mifare_classic_get_trailer_block_permission (tag, block + 3, MCAB_WRITE_KEYA, MFC_KEY_A)) && (1 == mifare_classic_get_trailer_block_permission (tag, block + 3, MCAB_WRITE_ACCESS_BITS, MFC_KEY_A)) && @@ -215,7 +215,7 @@ main(int argc, char *argv[]) size_t encoded_size; - off_t pos = 0; + size_t pos = 0; uint8_t *tlv_data = tlv_encode (3, ndef_msg, sizeof (ndef_msg), &encoded_size); MifareClassicBlockNumber bn = 0x04; diff --git a/libfreefare/freefare.c b/libfreefare/freefare.c index 63a9662..32aa1c6 100644 --- a/libfreefare/freefare.c +++ b/libfreefare/freefare.c @@ -77,7 +77,7 @@ freefare_get_tags (nfc_device_t *device) bool found = false; struct supported_tag *tag_info; - for (int i = 0; i < sizeof (supported_tags) / sizeof (struct supported_tag); i++) { + for (size_t i = 0; i < sizeof (supported_tags) / sizeof (struct supported_tag); i++) { if ((target_info.nai.abtAtqa[0] == supported_tags[i].ATQA[0]) && (target_info.nai.abtAtqa[1] == supported_tags[i].ATQA[1]) && (target_info.nai.btSak == supported_tags[i].SAK)) { @@ -155,7 +155,7 @@ char * freefare_get_tag_uid (MifareTag tag) { char *res = malloc (2 * tag->info.szUidLen + 1); - for (int i =0; i < tag->info.szUidLen; i++) + for (size_t i =0; i < tag->info.szUidLen; i++) snprintf (res + 2*i, 3, "%02x", tag->info.abtUid[i]); return res; } diff --git a/libfreefare/mifare_application.c b/libfreefare/mifare_application.c index 71cef7f..585172e 100644 --- a/libfreefare/mifare_application.c +++ b/libfreefare/mifare_application.c @@ -97,7 +97,7 @@ mifare_application_alloc (Mad mad, MadAid aid, size_t size) return NULL; - for (int c = 0; c < size; c++) { + for (size_t c = 0; c < size; c++) { if (free_aids[c]) { res[c] = free_aids[c]; } else { @@ -111,7 +111,7 @@ mifare_application_alloc (Mad mad, MadAid aid, size_t size) if (res) { /* Update the MAD */ - for (int c = 0; c < size; c++) + for (size_t c = 0; c < size; c++) mad_set_aid (mad, res[c], aid); } diff --git a/libfreefare/mifare_classic.c b/libfreefare/mifare_classic.c index fb2f907..ed9a2de 100644 --- a/libfreefare/mifare_classic.c +++ b/libfreefare/mifare_classic.c @@ -306,12 +306,12 @@ mifare_classic_read_value (MifareTag tag, const MifareClassicBlockNumber block, union mifare_classic_block b = *((union mifare_classic_block *)(&data)); - if ((b.value.value != (~b.value.value_)) || (b.value.value != b.value.value__)) { + if ((b.value.value ^ (uint32_t)~b.value.value_) || (b.value.value != b.value.value__)) { errno = EIO; return -1; } - if ((b.value.address != (unsigned char)(~b.value.address_)) || (b.value.address != b.value.address__) || (b.value.address_ != b.value.address___)) { + if ((b.value.address ^ (uint8_t)~b.value.address_) || (b.value.address != b.value.address__) || (b.value.address_ != b.value.address___)) { errno = EIO; return -1; } @@ -540,7 +540,7 @@ get_block_access_bits (MifareTag tag, const MifareClassicBlockNumber block, Mifa sector_access_bits_ = trailer_data[6] | ((trailer_data[7] & 0x0f) << 8) | 0xf000; sector_access_bits = ((trailer_data[7] & 0xf0) >> 4) | (trailer_data[8] << 4); - if (sector_access_bits != (uint16_t) ~sector_access_bits_) { + if (sector_access_bits ^ (uint16_t)~sector_access_bits_) { /* Sector locked */ errno = EIO; return -1;