Linux bluetooth development
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 2/2] android/gatt: Handle Unregister gatt client command
Date: Sat, 08 Mar 2014 21:14:29 +0100	[thread overview]
Message-ID: <4359327.L89oev6F6K@leonov> (raw)
In-Reply-To: <1394197499-2207-2-git-send-email-grzegorz.kolodziejczyk@tieto.com>

Hi Grzegorz,

On Friday 07 of March 2014 14:04:59 Grzegorz Kolodziejczyk wrote:
> This adds unregister gatt client app command handling.
> ---
>  android/gatt.c | 25 ++++++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/android/gatt.c b/android/gatt.c
> index f8f7208..1261c1f 100644
> --- a/android/gatt.c
> +++ b/android/gatt.c
> @@ -60,6 +60,13 @@ static int find_client_uuid(gconstpointer data,
> gconstpointer user_data) return 0;
>  }
> 
> +static int find_client_if(gconstpointer data, gconstpointer user_data)
> +{
> +	const int32_t exp_cif = *((int32_t *)user_data);

You can use int to pointer macro to pass int here.

> +	const int32_t cur_cif = ((struct gatt_client *)data)->client_if;

const struct gatt_client *client = data;

> +
> +	return cur_cif != exp_cif;
> +}
> 
>  static void handle_client_register(const void *buf, uint16_t len)
>  {
> @@ -110,10 +117,26 @@ failed:
> 
>  static void handle_client_unregister(const void *buf, uint16_t len)
>  {
> +	const struct hal_cmd_gatt_client_unregister *cmd = buf;
> +	int32_t client_if = cmd->client_if;

Why is this copy needed?

> +	GList *found_client_if;
> +
>  	DBG("");
> 
> -	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
> +	found_client_if = g_list_find_custom(gatt_client_list, &client_if,
> +								find_client_if);
> +	if (!found_client_if) {
> +		error("client_if: %d not found", client_if);
> +		ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
>  			HAL_OP_GATT_CLIENT_UNREGISTER, HAL_STATUS_FAILED);

Lets follow this convention for error handling:

	status = HAL_STATUS_FAILED;
	goto failed;

> +		return;
> +	}
> +
> +	gatt_client_list = g_list_remove(gatt_client_list,
> +							found_client_if->data);
> +
> +	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
> +			HAL_OP_GATT_CLIENT_UNREGISTER, HAL_STATUS_SUCCESS);
>  }
> 
>  static void handle_client_scan(const void *buf, uint16_t len)

-- 
BR
Szymon Janc

  reply	other threads:[~2014-03-08 20:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-07 13:04 [PATCH 1/2] android/gatt: Handle Register gatt client command Grzegorz Kolodziejczyk
2014-03-07 13:04 ` [PATCH 2/2] android/gatt: Handle Unregister " Grzegorz Kolodziejczyk
2014-03-08 20:14   ` Szymon Janc [this message]
2014-03-08 20:03 ` [PATCH 1/2] android/gatt: Handle Register " Szymon Janc

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=4359327.L89oev6F6K@leonov \
    --to=szymon.janc@tieto.com \
    --cc=grzegorz.kolodziejczyk@tieto.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