Skip to contentSkip to conversation

core/device: Fix build on some platforms

PATCH Applied Jakub Pawlowski 2 participants 2 messages Oct 23, 2015 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 core/device: Fix build on some platforms

due to type promotions in C this code was failing on some platforms.

src/device.c:2016:8: error: format specifies type 'unsigned short' but the
argument has type 'uint8_t' (aka 'unsigned char') [-Werror,-Wformat]
properties, uuid_str);
^~~~~~~~~~
/build/falco/usr/include/bits/stdio2.h:39:7: note: expanded from macro 'sprintf'

                           __VA_ARGS__)
                           ^
---
 src/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/device.c +1 -1
index 906a1a7..eb1850e 100644
@@ -2015,7 +2015,7 @@ static void store_chrc(struct gatt_db_attribute *attr, void *user_data)
 
 	sprintf(handle, "%04hx", handle_num);
 	bt_uuid_to_string(&uuid, uuid_str, sizeof(uuid_str));
-	sprintf(value, GATT_CHARAC_UUID_STR ":%04hx:%02hx:%s", value_handle,
+	sprintf(value, GATT_CHARAC_UUID_STR ":%04hx:%02hhx:%s", value_handle,
 							properties, uuid_str);
 	g_key_file_set_string(key_file, "Attributes", handle, value);
 
Signature · 1 line
2.5.0
#1 lore raw

Hi Jakub,

Quoted 7 lines · Jakub Pawlowski

due to type promotions in C this code was failing on some platforms.

src/device.c:2016:8: error: format specifies type 'unsigned short' but the
argument has type 'uint8_t' (aka 'unsigned char') [-Werror,-Wformat]
properties, uuid_str);
^~~~~~~~~~
/build/falco/usr/include/bits/stdio2.h:39:7: note: expanded from macro 'sprintf'

Quoted 5 lines
                           __VA_ARGS__)
                           ^
---
 src/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied. Thanks.

Johan