diff options
author | Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> | 2021-07-11 16:53:37 +0200 |
---|---|---|
committer | Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> | 2021-07-19 12:44:07 +0200 |
commit | ae769ea06146b9d91d6c16dc83bd1ac01581fdd3 (patch) | |
tree | 7d49fa64fdbc945f3671872fe36eff936814c947 | |
parent | ed85ddb81e7645bf9d68150afc0ad53340feb2a0 (diff) | |
download | neard-ae769ea06146b9d91d6c16dc83bd1ac01581fdd3.tar.gz |
tag: use proper format for integers (-Wformat)
Properly print signed and unsigned integers. This fixes warnings like:
src/tag.c: In function ‘near_tag_get_tag’:
src/tag.c:99:33: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=]
99 | path = g_strdup_printf("%s/nfc%d/tag%d", NFC_PATH,
| ~^
| |
| int
| %d
100 | adapter_idx, target_idx);
| ~~~~~~~~~~~
| |
| uint32_t {aka unsigned int}
In file included from src/near.h:36,
from src/tag.c:35:
src/tag.c: In function ‘near_tag_set_nfcid’:
./include/near/log.h:45:14: error: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=]
45 | near_debug("%s:%s() " fmt, \
| ^~~~~~~~~~
src/tag.c:791:2: note: in expansion of macro ‘DBG’
791 | DBG("NFCID len %zd", nfcid_len);
| ^~~
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
-rw-r--r-- | src/tag.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -96,7 +96,7 @@ struct near_tag *near_tag_get_tag(uint32_t adapter_idx, uint32_t target_idx) struct near_tag *tag; char *path; - path = g_strdup_printf("%s/nfc%d/tag%d", NFC_PATH, + path = g_strdup_printf("%s/nfc%u/tag%u", NFC_PATH, adapter_idx, target_idx); if (!path) return NULL; @@ -658,7 +658,7 @@ static int tag_initialize(struct near_tag *tag, { DBG(""); - tag->path = g_strdup_printf("%s/nfc%d/tag%d", NFC_PATH, + tag->path = g_strdup_printf("%s/nfc%u/tag%u", NFC_PATH, adapter_idx, target_idx); if (!tag->path) return -ENOMEM; @@ -788,7 +788,7 @@ int near_tag_set_nfcid(uint32_t adapter_idx, uint32_t target_idx, { struct near_tag *tag; - DBG("NFCID len %zd", nfcid_len); + DBG("NFCID len %zu", nfcid_len); tag = near_tag_get_tag(adapter_idx, target_idx); if (!tag) @@ -881,7 +881,7 @@ int near_tag_add_records(struct near_tag *tag, GList *records, for (list = records; list; list = list->next) { record = list->data; - path = g_strdup_printf("%s/nfc%d/tag%d/record%d", + path = g_strdup_printf("%s/nfc%u/tag%u/record%u", NFC_PATH, tag->adapter_idx, tag->target_idx, tag->next_record); |