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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux