public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 4/5] shared/gatt-db: Allow passing NULL to gatt_db_attribute_write
Date: Thu,  8 Dec 2022 17:03:13 -0800	[thread overview]
Message-ID: <20221209010314.707606-4-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20221209010314.707606-1-luiz.dentz@gmail.com>

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 --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;
 }
-- 
2.37.3


  parent reply	other threads:[~2022-12-09  1:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-09  1:03 [PATCH BlueZ 1/5] shared/att: Fix not requeueing in the same channel Luiz Augusto von Dentz
2022-12-09  1:03 ` [PATCH BlueZ 2/5] shared/bap: Log error message if request cannot be sent Luiz Augusto von Dentz
2022-12-09  1:03 ` [PATCH BlueZ 3/5] shared/bap: Read PAC Sink/Source if respective location is found Luiz Augusto von Dentz
2022-12-09  1:03 ` Luiz Augusto von Dentz [this message]
2022-12-09  1:03 ` [PATCH BlueZ 5/5] shared/bap: Make bt_bap_pac_register to be per session Luiz Augusto von Dentz
2022-12-09  4:33 ` [BlueZ,1/5] shared/att: Fix not requeueing in the same channel bluez.test.bot
2022-12-09 21:30 ` [PATCH BlueZ 1/5] " patchwork-bot+bluetooth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221209010314.707606-4-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox