[linux-nfc] [neard][PATCH 28/34] tag: use proper format for integers (-Wformat)

Krzysztof Kozlowski <[email protected]>
Newsgroups org.01.lists.linux-nfc,dev.linux.lists.oe-linux-nfc
Message-ID <[email protected]>
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 <[email protected]>
---
 src/tag.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/tag.c b/src/tag.c
index 9eba4eefef35..520368b1552c 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -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);
 
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.