From 078a047f6a40b0acf67861d01f1f2cb7bb50d024 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Sat, 15 Nov 2025 14:08:15 -0800 Subject: [PATCH] device: Fix the return type of device_irk_cmp() The return value from device_irk_cmp() is returned directly from device_addr_type_cmp() which implements a memcmp()-like interface, so we need to return an int() and a zero for equality. Returning bool will cause false positives since false is 0 and true is 1. Fixes: f1fb4f95f49e ("core: Fix not resolving addresses") --- src/device.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/device.c b/src/device.c index 91b6cc0c6..eb184633a 100644 --- a/src/device.c +++ b/src/device.c @@ -5419,24 +5419,24 @@ static bool addr_is_resolvable(const bdaddr_t *bdaddr, uint8_t addr_type) } } -static bool device_irk_cmp(const struct btd_device *device, +static int device_irk_cmp(const struct btd_device *device, const struct device_addr_type *addr) { struct bt_crypto *crypto; uint8_t hash[3]; if (!device->irk) - return false; + return -1; crypto = bt_crypto_new(); if (!crypto) - return false; + return -1; bt_crypto_ah(crypto, device->irk, addr->bdaddr.b + 3, hash); bt_crypto_unref(crypto); - return !memcmp(addr, hash, 3); + return memcmp(addr, hash, 3); } int device_addr_type_cmp(gconstpointer a, gconstpointer b) -- 2.47.3