From: Johan Hedberg <johan.hedberg@gmail.com>
To: Bartosz Szatkowski <bulislaw@linux.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH obexd] Fix memory issues in EDS PBAP
Date: Mon, 8 Aug 2011 11:30:43 +0300 [thread overview]
Message-ID: <20110808083043.GA8902@dell> (raw)
In-Reply-To: <1312658839-26919-1-git-send-email-bulislaw@linux.com>
Hi Bartosz,
On Sat, Aug 06, 2011, Bartosz Szatkowski wrote:
> --- a/plugins/phonebook-ebook.c
> +++ b/plugins/phonebook-ebook.c
> @@ -58,6 +58,7 @@ struct query_context {
> unsigned queued_calls;
> void *user_data;
> GSList *ebooks;
> + gboolean canceled;
> };
>
> static char *attribute_mask[] = {
> @@ -172,6 +173,9 @@ static void ebookpull_cb(EBook *book, const GError *gerr, GList *contacts,
> goto done;
> }
>
> + if (data->canceled)
> + goto canceled;
> +
> DBG("");
>
> /*
> @@ -217,6 +221,9 @@ done:
> 0, TRUE, data->user_data);
>
> g_string_free(buf, TRUE);
> +
> +canceled:
> + free_query_context(data);
> }
> }
Here you're jumping from a higher level into a deeper level
if-statement. Please don't do that. If you use goto stay on the same
level, otherwise the code flow & logic become too hard to follow.
> @@ -233,6 +240,9 @@ static void ebook_entry_cb(EBook *book, const GError *gerr,
> goto done;
> }
>
> + if (data->canceled)
> + goto canceled;
> +
> DBG("");
>
> evcard = E_VCARD(contact);
> @@ -255,6 +265,7 @@ done:
> data->contacts_cb(NULL, 0, 1, 0, TRUE,
> data->user_data);
>
> +canceled:
> free_query_context(data);
> }
> }
Same here.
> @@ -300,6 +311,9 @@ static void cache_cb(EBook *book, const GError *gerr, GList *contacts,
> goto done;
> }
>
> + if (data->canceled)
> + goto canceled;
> +
> DBG("");
>
> for (l = contacts; l; l = g_list_next(l)) {
> @@ -338,15 +352,20 @@ done:
> g_list_free_full(contacts, g_object_unref);
>
> data->queued_calls--;
> - if (data->queued_calls == 0)
> + if (data->queued_calls == 0) {
> data->ready_cb(data->user_data);
> +
> +canceled:
> + free_query_context(data);
> + }
> }
And here.
Johan
prev parent reply other threads:[~2011-08-08 8:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-06 19:27 [PATCH obexd] Fix memory issues in EDS PBAP Bartosz Szatkowski
2011-08-08 8:30 ` Johan Hedberg [this message]
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=20110808083043.GA8902@dell \
--to=johan.hedberg@gmail.com \
--cc=bulislaw@linux.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