linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 BlueZ] device: Fix not clearing error on update_bredr_services
@ 2021-10-28 21:37 Luiz Augusto von Dentz
  2021-10-28 21:53 ` [v2,BlueZ] " bluez.test.bot
  0 siblings, 1 reply; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2021-10-28 21:37 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

When trying to loads contents from file using g_key_file_load_from_file
it may cause an error which needs to be cleared since the gerr is
reused, also make sure the file is always created upfront to avoid
having such error when storage has not been initialized.
---
 src/device.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/device.c b/src/device.c
index 8ad338419..fdc2d50a4 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4998,22 +4998,28 @@ static void update_bredr_services(struct browse_req *req, sdp_list_t *recs)
 
 	snprintf(sdp_file, PATH_MAX, STORAGEDIR "/%s/cache/%s", srcaddr,
 								dstaddr);
+	create_file(sdp_file, 0600);
 
 	sdp_key_file = g_key_file_new();
 	if (!g_key_file_load_from_file(sdp_key_file, sdp_file, 0, &gerr)) {
 		error("Unable to load key file from %s: (%s)", sdp_file,
 								gerr->message);
-		g_error_free(gerr);
+		g_clear_error(&gerr);
+		g_key_file_free(sdp_key_file);
+		sdp_key_file = NULL;
 	}
 
 	snprintf(att_file, PATH_MAX, STORAGEDIR "/%s/%s/attributes", srcaddr,
 								dstaddr);
+	create_file(att_file, 0600);
 
 	att_key_file = g_key_file_new();
 	if (!g_key_file_load_from_file(att_key_file, att_file, 0, &gerr)) {
 		error("Unable to load key file from %s: (%s)", att_file,
 								gerr->message);
-		g_error_free(gerr);
+		g_clear_error(&gerr);
+		g_key_file_free(att_key_file);
+		att_key_file = NULL;
 	}
 
 	for (seq = recs; seq; seq = seq->next) {
@@ -5068,12 +5074,11 @@ next:
 	if (sdp_key_file) {
 		data = g_key_file_to_data(sdp_key_file, &length, NULL);
 		if (length > 0) {
-			create_file(sdp_file, 0600);
 			if (!g_file_set_contents(sdp_file, data, length,
 								&gerr)) {
 				error("Unable set contents for %s: (%s)",
 						sdp_file, gerr->message);
-				g_error_free(gerr);
+				g_clear_error(&gerr);
 			}
 		}
 
@@ -5084,12 +5089,11 @@ next:
 	if (att_key_file) {
 		data = g_key_file_to_data(att_key_file, &length, NULL);
 		if (length > 0) {
-			create_file(att_file, 0600);
 			if (!g_file_set_contents(att_file, data, length,
 								&gerr)) {
 				error("Unable set contents for %s: (%s)",
 						att_file, gerr->message);
-				g_error_free(gerr);
+				g_clear_error(&gerr);
 			}
 		}
 
-- 
2.31.1


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

* RE: [v2,BlueZ] device: Fix not clearing error on update_bredr_services
  2021-10-28 21:37 [PATCH v2 BlueZ] device: Fix not clearing error on update_bredr_services Luiz Augusto von Dentz
@ 2021-10-28 21:53 ` bluez.test.bot
  2021-10-29 20:57   ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 3+ messages in thread
From: bluez.test.bot @ 2021-10-28 21:53 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 884 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=572167

---Test result---

Test Summary:
CheckPatch                    PASS      1.35 seconds
GitLint                       PASS      0.95 seconds
Prep - Setup ELL              PASS      41.40 seconds
Build - Prep                  PASS      0.46 seconds
Build - Configure             PASS      7.71 seconds
Build - Make                  PASS      178.31 seconds
Make Check                    PASS      9.05 seconds
Make Distcheck                PASS      212.02 seconds
Build w/ext ELL - Configure   PASS      7.82 seconds
Build w/ext ELL - Make        PASS      168.61 seconds



---
Regards,
Linux Bluetooth


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

* Re: [v2,BlueZ] device: Fix not clearing error on update_bredr_services
  2021-10-28 21:53 ` [v2,BlueZ] " bluez.test.bot
@ 2021-10-29 20:57   ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2021-10-29 20:57 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

On Thu, Oct 28, 2021 at 2:53 PM <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=572167
>
> ---Test result---
>
> Test Summary:
> CheckPatch                    PASS      1.35 seconds
> GitLint                       PASS      0.95 seconds
> Prep - Setup ELL              PASS      41.40 seconds
> Build - Prep                  PASS      0.46 seconds
> Build - Configure             PASS      7.71 seconds
> Build - Make                  PASS      178.31 seconds
> Make Check                    PASS      9.05 seconds
> Make Distcheck                PASS      212.02 seconds
> Build w/ext ELL - Configure   PASS      7.82 seconds
> Build w/ext ELL - Make        PASS      168.61 seconds
>
>
>
> ---
> Regards,
> Linux Bluetooth

Pushed.

-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2021-10-29 20:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-28 21:37 [PATCH v2 BlueZ] device: Fix not clearing error on update_bredr_services Luiz Augusto von Dentz
2021-10-28 21:53 ` [v2,BlueZ] " bluez.test.bot
2021-10-29 20:57   ` Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).