Re: [PATCH] Fix issues with emails category

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux