Skip to contentSkip to conversation

core/advertising: Fix string match in le adv search

PATCH In review Andrejs Hanins 2 participants 2 messages Oct 6, 2015 – Oct 7, 2015 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 core/advertising: Fix string match in le adv search

Instead of searching for matched entry in the list, the function match_advertisement was searching for the first non-matched entry. As a result, it wasn't possible to unregister existing advertisement from LE Adv manager.

---
 src/advertising.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/advertising.c +2 -2
index d56b7a2..a148625 100644
@@ -77,10 +77,10 @@ static bool match_advertisement(const void *a, const void *b)
 	const struct advertisement *ad = a;
 	const struct dbus_obj_match *match = b;
 
-	if (match->owner && !g_strcmp0(ad->owner, match->owner))
+	if (match->owner && g_strcmp0(ad->owner, match->owner))
 		return false;
 
-	if (match->path && !g_strcmp0(ad->path, match->path))
+	if (match->path && g_strcmp0(ad->path, match->path))
 		return false;
 
 	return true;
Signature · 1 line
1.9.1
#1 lore raw

Hi Andrejs,

Quoted 5 lines · Andrejs Hanins

Instead of searching for matched entry in the list, the function match_advertisement was searching for the first non-matched entry. As a result, it wasn't possible to unregister existing advertisement from LE Adv manager.

Please remember no signed-off-by in userspace and keep the description under 72 columns, this time I fixed it for you.

Quoted 22 lines
---
 src/advertising.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/advertising.c +2 -3
index d56b7a2..a148625 100644
@@ -77,10 +77,10 @@ static bool match_advertisement(const void *a, const void *b)
        const struct advertisement *ad = a;
        const struct dbus_obj_match *match = b;
 
-       if (match->owner && !g_strcmp0(ad->owner, match->owner))
+       if (match->owner && g_strcmp0(ad->owner, match->owner))
                return false;
 
-       if (match->path && !g_strcmp0(ad->path, match->path))
+       if (match->path && g_strcmp0(ad->path, match->path))
                return false;
 
        return true;
--
Quoted 1 line

1.9.1

Nice catch, applied.

Signature · 1 line
Luiz Augusto von Dentz