[linux-nfc] [neard][PATCH v2 25/73] bluetooth: use proper format for integers (-Wformat)

Krzysztof Kozlowski <[email protected]> Mon, 19 Jul 2021 13:07:31 +0200
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:

    In file included from src/near.h:36,
                     from src/bluetooth.c:32:
    src/bluetooth.c: In function ‘bt_adapter_property_changed’:
    ./include/near/log.h:45:14: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 5 has type ‘int’ [-Werror=format=]
       45 |   near_debug("%s:%s() " fmt, \
          |              ^~~~~~~~~~
    src/bluetooth.c:465:3: note: in expansion of macro ‘DBG’
      465 |   DBG("%s: %x", property, bt_def_oob_data.class_of_device);
          |   ^~~

    In file included from src/near.h:36,
                     from src/bluetooth.c:32:
    src/bluetooth.c: In function ‘bt_adapter_property_changed’:
    ./include/near/log.h:45:14: error: format ‘%u’ expects argument of type ‘unsigned int’, but argument 5 has type ‘int’ [-Werror=format=]
       45 |   near_debug("%s:%s() " fmt, \
          |              ^~~~~~~~~~
    src/bluetooth.c:475:3: note: in expansion of macro ‘DBG’
      475 |   DBG("%s: %u", property, bt_def_oob_data.powered);
          |   ^~~

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
 src/bluetooth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/bluetooth.c b/src/bluetooth.c
index 3e67f1c88b84..79cfbb38e334 100644
--- a/src/bluetooth.c
+++ b/src/bluetooth.c
@@ -462,7 +462,7 @@ static gboolean bt_adapter_property_changed(DBusConnection *conn,
 		dbus_message_iter_get_basic(&var, &class);
 		bt_def_oob_data.class_of_device = class;
 
-		DBG("%s: %x", property, bt_def_oob_data.class_of_device);
+		DBG("%s: %x", property, (unsigned int)bt_def_oob_data.class_of_device);
 	} else if (g_str_equal(property, "Powered")) {
 		dbus_bool_t powered;
 
@@ -472,7 +472,7 @@ static gboolean bt_adapter_property_changed(DBusConnection *conn,
 		dbus_message_iter_get_basic(&var, &powered);
 		bt_def_oob_data.powered = powered;
 
-		DBG("%s: %u", property, bt_def_oob_data.powered);
+		DBG("%s: %d", property, bt_def_oob_data.powered);
 	}
 
 	return TRUE;
-- 
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