Skip to contentSkip to conversation

shared/btp: Fix return type in btp_send

PATCH Applied Szymon Janc 1 participant 3 messages Feb 23, 2018 – Feb 26, 2018 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 shared/btp: Fix return type in btp_send

This function returns bool.

---
 src/shared/btp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/shared/btp.c +1 -1
index 77622671c..555dabc39 100644
@@ -297,7 +297,7 @@ bool btp_send(struct btp *btp, uint8_t service, uint8_t opcode, uint8_t index,
 	len = sizeof(*hdr) + length;
 	hdr = l_malloc(len);
 	if (!hdr)
-		return NULL;
+		return false;
 
 	hdr->service = service;
 	hdr->opcode = opcode;
Signature · 1 line
2.14.3
#1 lore raw

PATCH 2/2 shared/btp: Allow to call btp_send without valid btp

This allows to unconditionally call btp_send from code that generates events eg when mapping those from D-Bus events.

---
 src/shared/btp.c | 3 +++
 1 file changed, 3 insertions(+)
src/shared/btp.c +3 -0
index 555dabc39..7eea241a2 100644
@@ -294,6 +294,9 @@ bool btp_send(struct btp *btp, uint8_t service, uint8_t opcode, uint8_t index,
 	struct pending_message *msg;
 	size_t len;
 
+	if (!btp)
+		return false;
+
 	len = sizeof(*hdr) + length;
 	hdr = l_malloc(len);
 	if (!hdr)
Signature · 1 line
2.14.3
author Applied
#2 lore raw
In reply to Szymon Janc
Quoted 10 lines · On Friday, 23 February 2018 14:40:09 CET Szymon Janc wrote:

This function returns bool.

---
 src/shared/btp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/shared/btp.c +0 -0
index 77622671c..555dabc39 100644

src/shared/btp.c bool btp_send(struct btp *btp, uint8_t service, uint8_t · line 303

Quoted 8 lines
src/shared/btp.c +1 -1
@@ -297,7 +297,7 @@ bool btp_send(struct btp *btp, uint8_t service, uint8_t
 opcode, uint8_t index, len = sizeof(*hdr) + length;
 	hdr = l_malloc(len);
 	if (!hdr)
-		return NULL;
+		return false;
 
 	hdr->service = service;
 	hdr->opcode = opcode;

Applied.

Signature · 2 lines
pozdrawiam
Szymon Janc