diff mbox series

[4/4] device: Fix compilation with GCC 10

Message ID 20200420120705.89691-4-szymon.janc@codecoup.pl (mailing list archive)
State Accepted
Delegated to: Luiz Von Dentz
Headers show
Series [1/4] android: Fix build with GCC 10 | expand

Commit Message

Szymon Janc April 20, 2020, 12:07 p.m. UTC
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 mbox series

Patch

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);