android: Fix build with GCC 10
PATCH 1/4 android: Fix build with GCC 10
status and state are used to hold various enum types depending on test and callback passed. Define them as int to avoid warnings about enum assignment from invalid type.
--- android/tester-main.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
android/tester-main.h +2 -2
@@ -653,8 +653,8 @@ struct map_inst_data {* matching with expected step data. */ struct bt_callback_data { -bt_state_t state; -bt_status_t status; +int state; +int status;int num_properties;bt_property_t *properties;bt_uuid_t *uuid;
Signature · 1 line
2.26.0
PATCH 2/4 sap: Fix compilation with GCC 10
--- profiles/sap/sap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
profiles/sap/sap.h +2 -2
@@ -76,7 +76,7 @@ struct sap_parameter {uint8_t id;uint8_t reserved;uint16_t len; -uint8_t val[0 ]; +uint8_t val[];/* * Padding bytes 0-3 bytes */
@@ -86,7 +86,7 @@ struct sap_message {uint8_t id;uint8_t nparam;uint16_t reserved; -struct sap_parameter param[0 ]; +struct sap_parameter param[]; } __attribute__((packed));#define SAP_BUF_SIZE 512
Signature · 1 line
2.26.0
PATCH 3/4 avctp: Fix compilation with GCC 10
In reply to Szymon JancThis one is a false positive but since we never use more than UINPUT_MAX_NAME_SIZE bytes of name we can silence GCC by reducing size of source string.
CC profiles/audio/bluetoothd-avctp.o
In function ‘uinput_create’,
inlined from ‘init_uinput’ at profiles/audio/avctp.c:1259:20:profiles/audio/avctp.c:1188:3: error: ‘strncpy’ output may be truncated copying 79 bytes from a string of length 248 [-Werror=stringop-truncation]
1188 | strncpy(dev.name, name, UINPUT_MAX_NAME_SIZE);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
---
profiles/audio/avctp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)profiles/audio/avctp.c +1 -1
@@ -1246,7 +1246,7 @@ static int uinput_create(struct btd_device *device, const char *name,static void init_uinput (struct avctp *session) { -char name[248 +1 ]; +char name[UINPUT_MAX_NAME_SIZE ];device_get_name (session->device, name,sizeof (name));if (g_str_equal (name,"Nokia CK-20W" )) {
Signature · 1 line
2.26.0
Re: [PATCH 3/4] avctp: Fix compilation with GCC 10
Quoted 21 lines · Szymon Janc
This one is a false positive but since we never use more than
UINPUT_MAX_NAME_SIZEbytes of name we can silence GCC by reducing size of source string.CC
profiles/audio/bluetoothd-avctp.o
In function ‘uinput_create’,
inlined from ‘init_uinput’ atprofiles/audio/avctp.c:1259:20:profiles/audio/avctp.c:1188:3: error: ‘strncpy’ output may be truncated copying 79 bytes from a string of length 248 [-Werror=stringop-truncation]1188 | strncpy(dev.name, name, UINPUT_MAX_NAME_SIZE); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors --- profiles/audio/avctp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)profiles/audio/avctp.c +0
-0
profiles/audio/avctp.c static int uinput_create(struct btd_device *device, const char *name, · line 1249
Quoted 5 lines
profiles/audio/avctp.c +1
-1@@ -1246,7 +1246,7 @@ static int uinput_create(struct btd_device *device, const char *name,static void init_uinput (struct avctp *session) { -char name[248 +1 ]; +char name[UINPUT_MAX_NAME_SIZE ];
Should this be nul terminated? (UINPUT_MAX_NAME_SIZE + 1) ?
Quoted 3 lines
profiles/audio/avctp.c +0
-0device_get_name (session->device, name,sizeof (name));if (g_str_equal (name,"Nokia CK-20W" )) {
Luiz Augusto von Dentz
maintainerRe: [PATCH 3/4] avctp: Fix compilation with GCC 10
Hi Brian,
Quoted 24 lines · Brian
Quoted 22 lines · Szymon Janc
This one is a false positive but since we never use more than
UINPUT_MAX_NAME_SIZEbytes of name we can silence GCC by reducing size of source string.CC
profiles/audio/bluetoothd-avctp.o
In function ‘uinput_create’,
inlined from ‘init_uinput’ atprofiles/audio/avctp.c:1259:20:profiles/audio/avctp.c:1188:3: error: ‘strncpy’ output may be truncated copying 79 bytes from a string of length 248 [-Werror=stringop-truncation]1188 | strncpy(dev.name, name, UINPUT_MAX_NAME_SIZE); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors --- profiles/audio/avctp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)profiles/audio/avctp.c +0
-0@@ -1246,7 +1246,7 @@ static int uinput_create(struct btd_device *device, const char *name,
Quoted 6 lines
profiles/audio/avctp.c static int uinput_create(struct btd_device *device, const char *name, · line 1249
Quoted 4 lines
profiles/audio/avctp.c +1
-1static void init_uinput (struct avctp *session) { -char name[248 +1 ]; +char name[UINPUT_MAX_NAME_SIZE ];Should this be nul terminated? (
UINPUT_MAX_NAME_SIZE+ 1) ?
I guess not since that is send over to the kernel which accepts up to UINPUT_MAX_NAME_SIZE so if the name is exactly 248 then the kernel should be the one adding the NULL termination, if it doesn't then we need to truncate by doing name[247] = '\0'.
Quoted 3 lines
Quoted 3 lines
profiles/audio/avctp.c +0
-0device_get_name (session->device, name,sizeof (name));if (g_str_equal (name,"Nokia CK-20W" )) {
Signature · 1 line
Luiz Augusto von Dentz
PATCH 4/4 device: Fix compilation with GCC 10
In reply to Szymon JancClass 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(-)src/device.c +1 -1
@@ -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 );
Signature · 1 line
2.26.0
Hi Luiz,
Modulo my question about nul termination on patch 3/4, This patchset resolves all of the GCC 10 build error/warnings and, I think, should be applied.
Quoted 22 lines · Szymon Janc
status and state are used to hold various enum types depending on test and callback passed. Define them as int to avoid warnings about enum assignment from invalid type.
--- android/tester-main.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)android/tester-main.h +2
-2@@ -653,8 +653,8 @@ struct map_inst_data {* matching with expected step data. */ struct bt_callback_data { -bt_state_t state; -bt_status_t status; +int state; +int status;int num_properties;bt_property_t *properties;bt_uuid_t *uuid;
Hi Szymon,
Quoted 14 lines · Brian
Hi Luiz,
Modulo my question about nul termination on patch 3/4, This patchset resolves all of the GCC 10 build error/warnings and, I think, should be applied.
Quoted 7 lines · Szymon Janc
status and state are used to hold various enum types depending on test and callback passed. Define them as int to avoid warnings about enum assignment from invalid type.
--- android/tester-main.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 15 lines
Quoted 5 lines
android/tester-main.h +0
-0android/tester-main.h struct map_inst_data { · line 660
Quoted 10 lines
android/tester-main.h +2
-2@@ -653,8 +653,8 @@ struct map_inst_data {* matching with expected step data. */ struct bt_callback_data { -bt_state_t state; -bt_status_t status; +int state; +int status;int num_properties;bt_property_t *properties;bt_uuid_t *uuid;
Applied, thanks.
Signature · 1 line
Luiz Augusto von Dentz