2013-02-18 16:04:42

by Syam Sidhardhan

[permalink] [raw]
Subject: [PATCH 1/2] tools: Fix compilation error with GINT_TO_POINTER

Fixes the following error:
tools/btmgmt.c: In function ‘index_rsp’:
tools/btmgmt.c:756:10: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
tools/btmgmt.c: In function ‘cmd_info’:
tools/btmgmt.c:791:9: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
cc1: all warnings being treated as errors
make[1]: *** [tools/btmgmt.o] Error 1
make: *** [all] Error 2
---
tools/btmgmt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 85e790b..715efde 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -753,7 +753,7 @@ static void index_rsp(uint8_t status, uint16_t len, const void *param,
if (monitor)
printf("hci%u ", index);

- data = GINT_TO_POINTER(index);
+ data = GINT_TO_POINTER((gint) index);

if (mgmt_send(mgmt, MGMT_OP_READ_INFO, index, 0, NULL,
info_rsp, data, NULL) == 0) {
@@ -788,7 +788,7 @@ static void cmd_info(struct mgmt *mgmt, uint16_t index, int argc, char **argv)
return;
}

- data = GINT_TO_POINTER(index);
+ data = GINT_TO_POINTER((gint) index);

if (mgmt_send(mgmt, MGMT_OP_READ_INFO, index, 0, NULL, info_rsp,
data, NULL) == 0) {
--
1.7.9.5



2013-02-20 08:00:30

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH 2/2] avctp: Fix invalid file descriptor close

Hi Syam,

On Mon, Feb 18, 2013, Syam Sidhardhan wrote:
> During avctp_confirm_cb(), if any error happens we set the session
> state to AVCTP_STATE_DISCONNECTED, which inturn try to close fd 0.
> ---
>
> I'm not sure about this fix in the latest upstream code,
> but in the case of Bluez 4.101, I got the following
> error log(with extra fd print) and this patch fixes the same.
>
> audio/avctp.c:avctp_confirm_cb() AVCTP: incoming connect from BC:47:60:F5:88:89
> Refusing unexpected connect from BC:47:60:F5:88:89
> audio/avctp.c:avctp_set_state() AVCTP Disconnected
> audio/avctp.c:avctp_disconnected()
> AVCTP: closing uinput[fd=0] for BC:47:60:F5:88:89
>
>
> profiles/audio/avctp.c | 1 +
> 1 file changed, 1 insertion(+)

Applied. Thanks.

Johan

2013-02-19 09:30:14

by Syam Sidhardhan

[permalink] [raw]
Subject: Re: [PATCH 1/2] tools: Fix compilation error with GINT_TO_POINTER

Hi Johan,

-----Original Message-----
From: Lucas De Marchi
Sent: Monday, February 18, 2013 10:14 PM
To: Syam Sidhardhan ; [email protected]
Subject: Re: [PATCH 1/2] tools: Fix compilation error with GINT_TO_POINTER

On Mon, Feb 18, 2013 at 1:13 PM, Johan Hedberg <[email protected]>
wrote:
> Hi Syam,
>
> On Mon, Feb 18, 2013, Syam Sidhardhan wrote:
>> Fixes the following error:
>> tools/btmgmt.c: In function ?index_rsp?:
>> tools/btmgmt.c:756:10: error: cast to pointer from integer of different
>> size [-Werror=int-to-pointer-cast]
>> tools/btmgmt.c: In function ?cmd_info?:
>> tools/btmgmt.c:791:9: error: cast to pointer from integer of different
>> size [-Werror=int-to-pointer-cast]
>> cc1: all warnings being treated as errors
>> make[1]: *** [tools/btmgmt.o] Error 1
>> make: *** [all] Error 2
>> ---
>> tools/btmgmt.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> This patch has been applied. For whatever reason I did not get this
> warning/error in my environment. Which gcc version and architecture are
> you using?

The problem is more likely to be in the different glib versions and
running on 32 bits:
https://bugzilla.gnome.org/show_bug.cgi?id=661546

I found this in gcc version 4.6.3 for PC arch(i386 on ubuntu 12.04) with
glib version 2.28.0.

Regards,
Syam


2013-02-18 16:44:07

by Lucas De Marchi

[permalink] [raw]
Subject: Re: [PATCH 1/2] tools: Fix compilation error with GINT_TO_POINTER

On Mon, Feb 18, 2013 at 1:13 PM, Johan Hedberg <[email protected]> wrote:
> Hi Syam,
>
> On Mon, Feb 18, 2013, Syam Sidhardhan wrote:
>> Fixes the following error:
>> tools/btmgmt.c: In function ?index_rsp?:
>> tools/btmgmt.c:756:10: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>> tools/btmgmt.c: In function ?cmd_info?:
>> tools/btmgmt.c:791:9: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>> cc1: all warnings being treated as errors
>> make[1]: *** [tools/btmgmt.o] Error 1
>> make: *** [all] Error 2
>> ---
>> tools/btmgmt.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> This patch has been applied. For whatever reason I did not get this
> warning/error in my environment. Which gcc version and architecture are
> you using?

The problem is more likely to be in the different glib versions and
running on 32 bits:
https://bugzilla.gnome.org/show_bug.cgi?id=661546

Lucas De Marchi

2013-02-18 16:13:31

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH 1/2] tools: Fix compilation error with GINT_TO_POINTER

Hi Syam,

On Mon, Feb 18, 2013, Syam Sidhardhan wrote:
> Fixes the following error:
> tools/btmgmt.c: In function ‘index_rsp’:
> tools/btmgmt.c:756:10: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
> tools/btmgmt.c: In function ‘cmd_info’:
> tools/btmgmt.c:791:9: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
> cc1: all warnings being treated as errors
> make[1]: *** [tools/btmgmt.o] Error 1
> make: *** [all] Error 2
> ---
> tools/btmgmt.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

This patch has been applied. For whatever reason I did not get this
warning/error in my environment. Which gcc version and architecture are
you using?

Johan

2013-02-18 16:04:43

by Syam Sidhardhan

[permalink] [raw]
Subject: [PATCH 2/2] avctp: Fix invalid file descriptor close

During avctp_confirm_cb(), if any error happens we set the session
state to AVCTP_STATE_DISCONNECTED, which inturn try to close fd 0.
---

I'm not sure about this fix in the latest upstream code,
but in the case of Bluez 4.101, I got the following
error log(with extra fd print) and this patch fixes the same.

audio/avctp.c:avctp_confirm_cb() AVCTP: incoming connect from BC:47:60:F5:88:89
Refusing unexpected connect from BC:47:60:F5:88:89
audio/avctp.c:avctp_set_state() AVCTP Disconnected
audio/avctp.c:avctp_disconnected()
AVCTP: closing uinput[fd=0] for BC:47:60:F5:88:89


profiles/audio/avctp.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index 13dd4c3..c276c52 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -1201,6 +1201,7 @@ static struct avctp *avctp_get_internal(struct btd_device *device)
session->server = server;
session->device = btd_device_ref(device);
session->state = AVCTP_STATE_DISCONNECTED;
+ session->uinput = -1;

server->sessions = g_slist_append(server->sessions, session);

--
1.7.9.5