All of lore.kernel.org
 help / color / mirror / Atom feed
* [BlueZ PATCH] device: Fix the return type of device_irk_cmp()
@ 2025-11-15 22:08 Andrey Smirnov
  2025-11-15 23:26 ` [BlueZ] " bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: Andrey Smirnov @ 2025-11-15 22:08 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrey Smirnov, Luiz Augusto von Dentz

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")
Cc: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 src/device.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/device.c b/src/device.c
index 434bdf721..26729512f 100644
--- a/src/device.c
+++ b/src/device.c
@@ -5422,24 +5422,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.43.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-15 23:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-15 22:08 [BlueZ PATCH] device: Fix the return type of device_irk_cmp() Andrey Smirnov
2025-11-15 23:26 ` [BlueZ] " bluez.test.bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.