Skip to content

Commit c9647a5

Browse files
jhedbergkartben
authored andcommitted
Bluetooth: Classic: Fix invalid comparison with int8_t
We can't use 0xff to compare with an int8_t since it'll trigger compiler warnings/errors: subsys/bluetooth/host/classic/br.c:397:11: error: result of comparison of constant 255 with expression of type 'int8_t' (aka 'signed char') is always false [-Werror,-Wtautological-constant-out-of-range-compare] if (rssi == 0xff) { ~~ ^ ~~ 1 error generated. Use 127 instead for situations where we don't know the RSSI value, like when processing remote name events. This is fine since from a spec perspective only -127 - +20 are valid values for the parameter. Signed-off-by: Johan Hedberg <[email protected]>
1 parent 9ba1f2e commit c9647a5

File tree

1 file changed

+4
-2
lines changed
  • subsys/bluetooth/host/classic

1 file changed

+4
-2
lines changed

subsys/bluetooth/host/classic/br.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <zephyr/logging/log.h>
2323
LOG_MODULE_REGISTER(bt_br);
2424

25+
#define RSSI_INVALID 127
26+
2527
struct bt_br_discovery_result *discovery_results;
2628
static size_t discovery_results_size;
2729
static size_t discovery_results_count;
@@ -394,7 +396,7 @@ static struct bt_br_discovery_result *get_result_slot(const bt_addr_t *addr, int
394396
}
395397

396398
/* ignore if invalid RSSI */
397-
if (rssi == 0xff) {
399+
if (rssi == RSSI_INVALID) {
398400
return NULL;
399401
}
400402

@@ -512,7 +514,7 @@ void bt_hci_remote_name_request_complete(struct net_buf *buf)
512514
int i;
513515
struct bt_br_discovery_cb *listener, *next;
514516

515-
result = get_result_slot(&evt->bdaddr, 0xff);
517+
result = get_result_slot(&evt->bdaddr, RSSI_INVALID);
516518
if (!result) {
517519
return;
518520
}

0 commit comments

Comments
 (0)