From ab1dbca212d64943dfca2af7ad543ea116d30e4c Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 29 Dec 2014 02:50:34 -0500 Subject: [PATCH] tools/btmgmt: Don't use hci_set_bit for discovery type Using hci_set_bit() on the 1-byte discovery type value produces the wrong results at least on 64-bit ppc. This patch fixes btmgmt to use the same style of manual bit setting as bluetoothd uses. --- tools/btmgmt.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tools/btmgmt.c b/tools/btmgmt.c index eac7204ef..846995e1c 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -1678,9 +1678,9 @@ static void cmd_find_service(struct mgmt *mgmt, uint16_t index, int argc, index = 0; type = 0; - hci_set_bit(BDADDR_BREDR, &type); - hci_set_bit(BDADDR_LE_PUBLIC, &type); - hci_set_bit(BDADDR_LE_RANDOM, &type); + type |= (1 << BDADDR_BREDR); + type |= (1 << BDADDR_LE_PUBLIC); + type |= (1 << BDADDR_LE_RANDOM); rssi = 127; count = 0; @@ -1693,14 +1693,14 @@ static void cmd_find_service(struct mgmt *mgmt, uint16_t index, int argc, find_service_options, NULL)) != -1) { switch (opt) { case 'l': - hci_clear_bit(BDADDR_BREDR, &type); - hci_set_bit(BDADDR_LE_PUBLIC, &type); - hci_set_bit(BDADDR_LE_RANDOM, &type); + type &= ~(1 << BDADDR_BREDR); + type |= (1 << BDADDR_LE_PUBLIC); + type |= (1 << BDADDR_LE_RANDOM); break; case 'b': - hci_set_bit(BDADDR_BREDR, &type); - hci_clear_bit(BDADDR_LE_PUBLIC, &type); - hci_clear_bit(BDADDR_LE_RANDOM, &type); + type |= (1 << BDADDR_BREDR); + type &= ~(1 << BDADDR_LE_PUBLIC); + type &= ~(1 << BDADDR_LE_RANDOM); break; case 'u': if (count == MAX_UUIDS) { @@ -1789,22 +1789,22 @@ static void cmd_find(struct mgmt *mgmt, uint16_t index, int argc, char **argv) index = 0; type = 0; - hci_set_bit(BDADDR_BREDR, &type); - hci_set_bit(BDADDR_LE_PUBLIC, &type); - hci_set_bit(BDADDR_LE_RANDOM, &type); + type |= (1 << BDADDR_BREDR); + type |= (1 << BDADDR_LE_PUBLIC); + type |= (1 << BDADDR_LE_RANDOM); while ((opt = getopt_long(argc, argv, "+lbh", find_options, NULL)) != -1) { switch (opt) { case 'l': - hci_clear_bit(BDADDR_BREDR, &type); - hci_set_bit(BDADDR_LE_PUBLIC, &type); - hci_set_bit(BDADDR_LE_RANDOM, &type); + type &= ~(1 << BDADDR_BREDR); + type |= (1 << BDADDR_LE_PUBLIC); + type |= (1 << BDADDR_LE_RANDOM); break; case 'b': - hci_set_bit(BDADDR_BREDR, &type); - hci_clear_bit(BDADDR_LE_PUBLIC, &type); - hci_clear_bit(BDADDR_LE_RANDOM, &type); + type |= (1 << BDADDR_BREDR); + type &= ~(1 << BDADDR_LE_PUBLIC); + type &= ~(1 << BDADDR_LE_RANDOM); break; case 'h': default: -- 2.47.3