summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz-von@nokia.com>2010-06-30 18:11:13 +0300
committerJohan Hedberg <johan.hedberg@nokia.com>2010-07-01 12:37:46 +0300
commit90608519f3701763ca00b27d6ae133d6bbb07bad (patch)
tree2382746271a00d5701e5384a2349346e75adb586
parent3e6f4f99f2aa89920ff023e10666b0d0165b193f (diff)
downloadbluez-90608519f3701763ca00b27d6ae133d6bbb07bad.tar.gz
hciops: fix not checking all possible errors
-rw-r--r--plugins/hciops.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/plugins/hciops.c b/plugins/hciops.c
index da2e3d0b6..35cba0ec0 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -456,7 +456,7 @@ done:
static int hciops_powered(int index, gboolean powered)
{
- int dd;
+ int dd, err;
uint8_t mode = SCAN_DISABLED;
if (powered)
@@ -466,8 +466,13 @@ static int hciops_powered(int index, gboolean powered)
if (dd < 0)
return -EIO;
- hci_send_cmd(dd, OGF_HOST_CTL, OCF_WRITE_SCAN_ENABLE,
+ err = hci_send_cmd(dd, OGF_HOST_CTL, OCF_WRITE_SCAN_ENABLE,
1, &mode);
+ if (err < 0) {
+ err = -errno;
+ hci_close_dev(dd);
+ return err;
+ }
hci_close_dev(dd);
@@ -476,36 +481,40 @@ static int hciops_powered(int index, gboolean powered)
static int hciops_connectable(int index)
{
- int dd;
+ int dd, err;
uint8_t mode = SCAN_PAGE;
dd = hci_open_dev(index);
if (dd < 0)
return -EIO;
- hci_send_cmd(dd, OGF_HOST_CTL, OCF_WRITE_SCAN_ENABLE,
+ err = hci_send_cmd(dd, OGF_HOST_CTL, OCF_WRITE_SCAN_ENABLE,
1, &mode);
+ if (err < 0)
+ err = -errno;
hci_close_dev(dd);
- return 0;
+ return err;
}
static int hciops_discoverable(int index)
{
- int dd;
+ int dd, err;
uint8_t mode = (SCAN_PAGE | SCAN_INQUIRY);
dd = hci_open_dev(index);
if (dd < 0)
return -EIO;
- hci_send_cmd(dd, OGF_HOST_CTL, OCF_WRITE_SCAN_ENABLE,
+ err = hci_send_cmd(dd, OGF_HOST_CTL, OCF_WRITE_SCAN_ENABLE,
1, &mode);
+ if (err < 0)
+ err = -errno;
hci_close_dev(dd);
- return 0;
+ return err;
}
static int hciops_set_class(int index, uint32_t class)
@@ -533,7 +542,7 @@ static int hciops_set_class(int index, uint32_t class)
static int hciops_set_limited_discoverable(int index, uint32_t class,
gboolean limited)
{
- int dd;
+ int dd, err;
int num = (limited ? 2 : 1);
uint8_t lap[] = { 0x33, 0x8b, 0x9e, 0x00, 0x8b, 0x9e };
write_current_iac_lap_cp cp;
@@ -550,8 +559,13 @@ static int hciops_set_limited_discoverable(int index, uint32_t class,
cp.num_current_iac = num;
memcpy(&cp.lap, lap, num * 3);
- hci_send_cmd(dd, OGF_HOST_CTL, OCF_WRITE_CURRENT_IAC_LAP,
+ err = hci_send_cmd(dd, OGF_HOST_CTL, OCF_WRITE_CURRENT_IAC_LAP,
(num * 3 + 1), &cp);
+ if (err < 0) {
+ err = -errno;
+ hci_close_dev(dd);
+ return err;
+ }
hci_close_dev(dd);