All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] device: Update cache only if content changed
@ 2020-11-17 15:57 Szymon Janc
  2020-11-17 16:45 ` bluez.test.bot
  0 siblings, 1 reply; 3+ messages in thread
From: Szymon Janc @ 2020-11-17 15:57 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

This fix hammering storage device (eg sdcard) when doing scanning
and LE devices are around.
---
 src/device.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/device.c b/src/device.c
index 2800b276a..cf4226f42 100644
--- a/src/device.c
+++ b/src/device.c
@@ -509,7 +509,9 @@ void device_store_cached_name(struct btd_device *dev, const char *name)
 	char d_addr[18];
 	GKeyFile *key_file;
 	char *data;
+	char *data_old;
 	gsize length = 0;
+	gsize length_old = 0;
 
 	if (device_address_is_private(dev)) {
 		DBG("Can't store name for private addressed device %s",
@@ -524,11 +526,17 @@ void device_store_cached_name(struct btd_device *dev, const char *name)
 
 	key_file = g_key_file_new();
 	g_key_file_load_from_file(key_file, filename, 0, NULL);
+	data_old = g_key_file_to_data(key_file, &length_old, NULL);
+
 	g_key_file_set_string(key_file, "General", "Name", name);
 
 	data = g_key_file_to_data(key_file, &length, NULL);
-	g_file_set_contents(filename, data, length, NULL);
+
+	if ((length != length_old) || (memcmp(data, data_old, length)))
+		g_file_set_contents(filename, data, length, NULL);
+
 	g_free(data);
+	g_free(data_old);
 
 	g_key_file_free(key_file);
 }
-- 
2.28.0


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

* RE: device: Update cache only if content changed
  2020-11-17 15:57 [PATCH] device: Update cache only if content changed Szymon Janc
@ 2020-11-17 16:45 ` bluez.test.bot
  2020-11-17 18:13   ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 3+ messages in thread
From: bluez.test.bot @ 2020-11-17 16:45 UTC (permalink / raw)
  To: linux-bluetooth, szymon.janc

[-- Attachment #1: Type: text/plain, Size: 557 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=386087

---Test result---

##############################
Test: CheckPatch - PASS

##############################
Test: CheckGitLint - PASS

##############################
Test: CheckBuild - PASS

##############################
Test: MakeCheck - PASS



---
Regards,
Linux Bluetooth


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

* Re: device: Update cache only if content changed
  2020-11-17 16:45 ` bluez.test.bot
@ 2020-11-17 18:13   ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2020-11-17 18:13 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org; +Cc: Szymon Janc

Hi Szymon,

On Tue, Nov 17, 2020 at 8:52 AM <bluez.test.bot@gmail.com> wrote:
>
> This is automated email and please do not reply to this email!
>
> Dear submitter,
>
> Thank you for submitting the patches to the linux bluetooth mailing list.
> This is a CI test results with your patch series:
> PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=386087
>
> ---Test result---
>
> ##############################
> Test: CheckPatch - PASS
>
> ##############################
> Test: CheckGitLint - PASS
>
> ##############################
> Test: CheckBuild - PASS
>
> ##############################
> Test: MakeCheck - PASS
>
>
>
> ---
> Regards,
> Linux Bluetooth
>

Applied, thanks.

-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2020-11-17 18:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-17 15:57 [PATCH] device: Update cache only if content changed Szymon Janc
2020-11-17 16:45 ` bluez.test.bot
2020-11-17 18:13   ` Luiz Augusto von Dentz

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.