aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>2021-07-12 16:13:44 +0200
committerKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>2021-07-19 12:44:07 +0200
commitb4bfa622cc9c11b97e6bf3467593926b0b906384 (patch)
tree1b2490ecddc9fcb9c80d68f44861e8f39d976cc8
parentc4b1bc196ffd3313aa96a35b9db70c8fbc26ad9b (diff)
downloadneard-b4bfa622cc9c11b97e6bf3467593926b0b906384.tar.gz
mifare: use unsigned int to suppress compiler -Wstrict-overflow
GCC v7.5 (Ubuntu Bionic) with optimizations has trouble spotting lack of possible overflow of a signed integer. There is no overflow possible so this is a false positive which can be suppressed by simply using unsigned integer. Unsigned also has more sense in that context. This fixes GCC 7.5 warning: plugins/mifare.c: In function 'mifare_process_MADs': plugins/mifare.c:626:5: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow] if (global_tag_size == 0) { ^ Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
-rw-r--r--plugins/mifare.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/plugins/mifare.c b/plugins/mifare.c
index a4e4ba4..f42007d 100644
--- a/plugins/mifare.c
+++ b/plugins/mifare.c
@@ -560,7 +560,7 @@ static int mifare_process_MADs(void *data)
struct mifare_cookie *mf_ck = data;
int err;
int i;
- int global_tag_size = 0;
+ unsigned int global_tag_size = 0;
int ioffset;
uint8_t *tag_data;
size_t data_size;
@@ -626,13 +626,13 @@ done_mad:
if (global_tag_size == 0) {
/* no NFC sectors - mark tag as blank */
- near_error("TAG Global size: [%d], not valid NFC tag.",
+ near_error("TAG Global size: [%u], not valid NFC tag.",
global_tag_size);
return -ENODEV;
}
/* n sectors, each sector is 3 blocks, each block is 16 bytes */
- DBG("TAG Global size: [%d]", global_tag_size);
+ DBG("TAG Global size: [%u]", global_tag_size);
mf_ck->tag = near_tag_get_tag(mf_ck->adapter_idx, mf_ck->target_idx);
if (!mf_ck->tag) {