All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] android: Fix build with GCC 10
@ 2020-04-20 12:07 Szymon Janc
  2020-04-20 12:07 ` [PATCH 2/4] sap: Fix compilation " Szymon Janc
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Szymon Janc @ 2020-04-20 12:07 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: 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(-)

diff --git a/android/tester-main.h b/android/tester-main.h
index 8a7384c57..6bdfdbcdb 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -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;
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] sap: Fix compilation with GCC 10
  2020-04-20 12:07 [PATCH 1/4] android: Fix build with GCC 10 Szymon Janc
@ 2020-04-20 12:07 ` Szymon Janc
  2020-04-20 12:07 ` [PATCH 3/4] avctp: " Szymon Janc
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Szymon Janc @ 2020-04-20 12:07 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

---
 profiles/sap/sap.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/profiles/sap/sap.h b/profiles/sap/sap.h
index 16c333a9b..6e78d6c2d 100644
--- a/profiles/sap/sap.h
+++ b/profiles/sap/sap.h
@@ -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
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] avctp: Fix compilation with GCC 10
  2020-04-20 12:07 [PATCH 1/4] android: Fix build with GCC 10 Szymon Janc
  2020-04-20 12:07 ` [PATCH 2/4] sap: Fix compilation " Szymon Janc
@ 2020-04-20 12:07 ` Szymon Janc
  2020-04-20 16:37   ` Gix, Brian
  2020-04-20 12:07 ` [PATCH 4/4] device: " Szymon Janc
  2020-04-20 16:41 ` [PATCH 1/4] android: Fix build " Gix, Brian
  3 siblings, 1 reply; 8+ messages in thread
From: Szymon Janc @ 2020-04-20 12:07 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

This 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(-)

diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index 37ffde9e7..058b44a8b 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -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")) {
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] device: Fix compilation with GCC 10
  2020-04-20 12:07 [PATCH 1/4] android: Fix build with GCC 10 Szymon Janc
  2020-04-20 12:07 ` [PATCH 2/4] sap: Fix compilation " Szymon Janc
  2020-04-20 12:07 ` [PATCH 3/4] avctp: " Szymon Janc
@ 2020-04-20 12:07 ` Szymon Janc
  2020-04-20 16:41 ` [PATCH 1/4] android: Fix build " Gix, Brian
  3 siblings, 0 replies; 8+ messages in thread
From: Szymon Janc @ 2020-04-20 12:07 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] avctp: Fix compilation with GCC 10
  2020-04-20 12:07 ` [PATCH 3/4] avctp: " Szymon Janc
@ 2020-04-20 16:37   ` Gix, Brian
  2020-04-20 16:57     ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 8+ messages in thread
From: Gix, Brian @ 2020-04-20 16:37 UTC (permalink / raw)
  To: szymon.janc, linux-bluetooth

On Mon, 2020-04-20 at 14:07 +0200, Szymon Janc wrote:
> This 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(-)
> 
> diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
> index 37ffde9e7..058b44a8b 100644
> --- a/profiles/audio/avctp.c
> +++ b/profiles/audio/avctp.c
> @@ -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)  ?

>  
>  	device_get_name(session->device, name, sizeof(name));
>  	if (g_str_equal(name, "Nokia CK-20W")) {

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/4] android: Fix build with GCC 10
  2020-04-20 12:07 [PATCH 1/4] android: Fix build with GCC 10 Szymon Janc
                   ` (2 preceding siblings ...)
  2020-04-20 12:07 ` [PATCH 4/4] device: " Szymon Janc
@ 2020-04-20 16:41 ` Gix, Brian
  2020-04-20 18:00   ` Luiz Augusto von Dentz
  3 siblings, 1 reply; 8+ messages in thread
From: Gix, Brian @ 2020-04-20 16:41 UTC (permalink / raw)
  To: szymon.janc, linux-bluetooth; +Cc: luiz.dentz

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.

On Mon, 2020-04-20 at 14:07 +0200, Szymon Janc wrote:
> 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(-)
> 
> diff --git a/android/tester-main.h b/android/tester-main.h
> index 8a7384c57..6bdfdbcdb 100644
> --- a/android/tester-main.h
> +++ b/android/tester-main.h
> @@ -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;

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] avctp: Fix compilation with GCC 10
  2020-04-20 16:37   ` Gix, Brian
@ 2020-04-20 16:57     ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 8+ messages in thread
From: Luiz Augusto von Dentz @ 2020-04-20 16:57 UTC (permalink / raw)
  To: Gix, Brian; +Cc: szymon.janc, linux-bluetooth

Hi Brian,

On Mon, Apr 20, 2020 at 9:44 AM Gix, Brian <brian.gix@intel.com> wrote:
>
> On Mon, 2020-04-20 at 14:07 +0200, Szymon Janc wrote:
> > This 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(-)
> >
> > diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
> > index 37ffde9e7..058b44a8b 100644
> > --- a/profiles/audio/avctp.c
> > +++ b/profiles/audio/avctp.c
> > @@ -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)  ?

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'.

> >
> >       device_get_name(session->device, name, sizeof(name));
> >       if (g_str_equal(name, "Nokia CK-20W")) {



-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/4] android: Fix build with GCC 10
  2020-04-20 16:41 ` [PATCH 1/4] android: Fix build " Gix, Brian
@ 2020-04-20 18:00   ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 8+ messages in thread
From: Luiz Augusto von Dentz @ 2020-04-20 18:00 UTC (permalink / raw)
  To: Gix, Brian; +Cc: szymon.janc, linux-bluetooth

Hi Szymon,

On Mon, Apr 20, 2020 at 9:42 AM Gix, Brian <brian.gix@intel.com> wrote:
>
> 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.
>
> On Mon, 2020-04-20 at 14:07 +0200, Szymon Janc wrote:
> > 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(-)
> >
> > diff --git a/android/tester-main.h b/android/tester-main.h
> > index 8a7384c57..6bdfdbcdb 100644
> > --- a/android/tester-main.h
> > +++ b/android/tester-main.h
> > @@ -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.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-04-20 18:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-20 12:07 [PATCH 1/4] android: Fix build with GCC 10 Szymon Janc
2020-04-20 12:07 ` [PATCH 2/4] sap: Fix compilation " Szymon Janc
2020-04-20 12:07 ` [PATCH 3/4] avctp: " Szymon Janc
2020-04-20 16:37   ` Gix, Brian
2020-04-20 16:57     ` Luiz Augusto von Dentz
2020-04-20 12:07 ` [PATCH 4/4] device: " Szymon Janc
2020-04-20 16:41 ` [PATCH 1/4] android: Fix build " Gix, Brian
2020-04-20 18:00   ` Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.