diff mbox series

[BlueZ,4/5] shared/gatt-db: Allow passing NULL to gatt_db_attribute_write

Message ID 20221209010314.707606-4-luiz.dentz@gmail.com (mailing list archive)
State Accepted
Commit be9fc9222c033391329e6145ccf4e81dcfcf1934
Headers show
Series [BlueZ,1/5] shared/att: Fix not requeueing in the same channel | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Luiz Augusto von Dentz Dec. 9, 2022, 1:03 a.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This makes gatt_db_attribute_write to accept NULL as a func when
storing directly on the db itself.
---
 src/shared/gatt-db.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index ba47c75ff70c..9a92090ec493 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -2095,7 +2095,7 @@  bool gatt_db_attribute_write(struct gatt_db_attribute *attrib, uint16_t offset,
 {
 	uint8_t err = 0;
 
-	if (!attrib || !func)
+	if (!attrib || (!func && attrib->write_func))
 		return false;
 
 	if (attrib->write_func) {
@@ -2158,7 +2158,8 @@  bool gatt_db_attribute_write(struct gatt_db_attribute *attrib, uint16_t offset,
 	memcpy(&attrib->value[offset], value, len);
 
 done:
-	func(attrib, err, user_data);
+	if (func)
+		func(attrib, err, user_data);
 
 	return true;
 }