Linux bluetooth development
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Lukasz Pawlik <lucas.pawlik@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] Fix issues with emails category
Date: Mon, 23 Aug 2010 14:42:44 +0300	[thread overview]
Message-ID: <20100823114244.GA28080@jh-x301> (raw)
In-Reply-To: <AANLkTik_S1g==mJKEQHpKGbFiQALj2nE=UboDBiNfVYY@mail.gmail.com>

Hi Lukasz,

On Mon, Aug 23, 2010, Lukasz Pawlik wrote:
> +	struct phonebook_email *email_addr;
> +
> +	for (l = emails; l; l = l->next) {
> +		email_addr = l->data;

Please always define variables in the smallest possible scope. In this
case email_addr can be defined in the beginning of the for-loop instead
of the beginning of the function.

> +		if (g_strcmp0(email_addr->email, email) == 0
> +			&& email_addr->type == type)
> +			return email_addr;

Continuation lines should be indented by at least two tabs more than the
original so that they stand out clearly from the actual code that's part
of the subsection. Also, the && goes on the preceeding line.


> -static void add_email(struct phonebook_contact *contact, const char *email)
> +static void add_email(struct phonebook_contact *contact, const char *email,
> +					int type)
>  {
> +	struct phonebook_email *email_addr;
>  	if (email == NULL || strlen(email) == 0)
>  		return;
>  
>  	/* Not adding email if there is already added with the same value */
> -	if (find_email(contact->emails, email))
> +	if (find_email(contact->emails, email, type))
>  		return;
>  
> -	contact->emails = g_slist_append(contact->emails, g_strdup(email));
> +	email_addr = g_new0(struct phonebook_email, 1);
> +	email_addr->email = g_strdup(email);
> +	email_addr->type = type;
> +
> +	contact->emails = g_slist_append(contact->emails, email_addr);

I'd do some renaming of variables here to make it more readable:

s/email/address/
s/email_address/email/
s/email->email/email->address/

> +struct phonebook_email {
> +	char *email;

As mentioned above I'd do a s/email/address/ here.

Johan

  reply	other threads:[~2010-08-23 11:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-23 11:18 [PATCH] Fix issues with emails category Lukasz Pawlik
2010-08-23 11:42 ` Johan Hedberg [this message]
2010-08-23 12:20 ` Uwe Kleine-König
  -- strict thread matches above, loose matches on Subject: below --
2010-08-23 13:45 Lukasz Pawlik
2010-08-23 20:50 ` Johan Hedberg

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=20100823114244.GA28080@jh-x301 \
    --to=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=lucas.pawlik@gmail.com \
    /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