2011-01-31 18:57:33

by Andre Dieb Martins

[permalink] [raw]
Subject: [PATCH] Fix hciconfig leadv returned response.

Fixes hciconfig leadv returned response by treating both status of the command
execution and HCI error code.
---
tools/hciconfig.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index c271d14..05a8910 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -269,11 +269,20 @@ static void cmd_le_adv(int ctl, int hdev, char *opt)
rq.rlen = 1;

ret = hci_send_req(dd, &rq, 100);
- if (status || ret < 0)
+
+ hci_close_dev(dd);
+
+ if (ret < 0) {
fprintf(stderr, "Can't set advertise mode on hci%d: %s (%d)\n",
hdev, strerror(errno), errno);
+ exit(1);
+ }

- hci_close_dev(dd);
+ if (status) {
+ fprintf(stderr, "LE set advertise enable on hci%d returned status %d\n",
+ hdev, status);
+ exit(1);
+ }
}

static void cmd_le_states(int ctl, int hdev, char *opt)
@@ -302,7 +311,7 @@ static void cmd_le_states(int ctl, int hdev, char *opt)

err = hci_send_req(dd, &rq, 1000);

- close(dd);
+ hci_close_dev(dd);

if (err < 0) {
fprintf(stderr, "Can't read LE supported states on hci%d:"
--
1.7.1



2011-02-01 09:10:10

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH] Fix hciconfig leadv returned response.

Hi Andr?,

On Mon, Jan 31, 2011, Andre Dieb Martins wrote:
> Fixes hciconfig leadv returned response by treating both status of the command
> execution and HCI error code.
> ---
> tools/hciconfig.c | 15 ++++++++++++---
> 1 files changed, 12 insertions(+), 3 deletions(-)

The patch has been pushed upstream. Thanks. However, I did have to fix
your commit message first: the summary line should not have a '.' at the
end and no line should be longer than 74 characters so that the message
is properly viewable with git log on a 80 character wide terminal.

Johan