2020-04-20 12:08:43

by Szymon Janc

[permalink] [raw]
Subject: [PATCH 4/4] device: Fix compilation with GCC 10

Class is using only 3 bytes so make sure GCC is aware of that.

src/device.c:397:3: note: ‘sprintf’ output between 9 and 11 bytes into a destination of size 9
397 | sprintf(class, "0x%6.6x", device->class);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
---
src/device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/device.c b/src/device.c
index 5f9ad227d..a8d95346a 100644
--- a/src/device.c
+++ b/src/device.c
@@ -394,7 +394,7 @@ static gboolean store_device_info_cb(gpointer user_data)
g_key_file_remove_key(key_file, "General", "Alias", NULL);

if (device->class) {
- sprintf(class, "0x%6.6x", device->class);
+ sprintf(class, "0x%6.6x", device->class & 0xffffff);
g_key_file_set_string(key_file, "General", "Class", class);
} else {
g_key_file_remove_key(key_file, "General", "Class", NULL);
--
2.26.0