Linux bluetooth development
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: Jakub Tyszkowski <jakub.tyszkowski@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 10/10] android/gatt: Avoid copying pointers in matching functions
Date: Fri, 13 Feb 2015 12:48:20 +0100	[thread overview]
Message-ID: <5088455.trWqmuhi6p@uw000953> (raw)
In-Reply-To: <1423665248-5121-10-git-send-email-jakub.tyszkowski@tieto.com>

Hi Jakub,

On Wednesday 11 of February 2015 15:34:08 Jakub Tyszkowski wrote:
> This removes casting void* to struct pointers when there is no need to
> do so (pointer comparison).
> ---
>  android/gatt.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/android/gatt.c b/android/gatt.c
> index cd0825a..3076a02 100644
> --- a/android/gatt.c
> +++ b/android/gatt.c
> @@ -350,9 +350,8 @@ static struct gatt_app *find_app_by_id(int32_t id)
>  static bool match_device_by_bdaddr(const void *data, const void *user_data)
>  {
>  	const struct gatt_device *dev = data;
> -	const bdaddr_t *addr = user_data;
>  
> -	return !bacmp(&dev->bdaddr, addr);
> +	return !bacmp(&dev->bdaddr, user_data);
>  }
>  
>  static bool match_device_by_state(const void *data, const void *user_data)
> @@ -408,17 +407,15 @@ static struct app_connection *find_connection_by_id(int32_t conn_id)
>  static bool match_connection_by_device(const void *data, const void *user_data)
>  {
>  	const struct app_connection *conn = data;
> -	const struct gatt_device *dev = user_data;
>  
> -	return conn->device == dev;
> +	return conn->device == user_data;
>  }
>  
>  static bool match_connection_by_app(const void *data, const void *user_data)
>  {
>  	const struct app_connection *conn = data;
> -	const struct gatt_app *app = user_data;
>  
> -	return conn->app == app;
> +	return conn->app == user_data;
>  }
>  
>  static struct gatt_device *find_device_by_addr(const bdaddr_t *addr)
> @@ -469,9 +466,8 @@ static bool match_srvc_by_bt_uuid(const void *data, const void *user_data)
>  static bool match_srvc_by_range(const void *data, const void *user_data)
>  {
>  	const struct service *srvc = data;
> -	const struct att_range *range = user_data;
>  
> -	return !memcmp(&srvc->prim.range, range, sizeof(srvc->prim.range));
> +	return !memcmp(&srvc->prim.range, user_data, sizeof(srvc->prim.range));
>  }
>  
>  static bool match_char_by_higher_inst_id(const void *data,

I prefer to have those as is so that one can easily see what the userdata
is expected to be. And compiler will most likely optimize those assignments
anyway.

-- 
Best regards, 
Szymon Janc

  reply	other threads:[~2015-02-13 11:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-11 14:33 [PATCH 01/10] android/gatt: Replace request state with boolean Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 02/10] android/gatt: Destroy app connections before destroying apps Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 03/10] android/gatt: Simplify app disconnection function call flow Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 04/10] android/gatt: Make struct destructors NULL proof Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 05/10] android/gatt: Use g_attrib_send consistently Jakub Tyszkowski
2015-02-13 11:31   ` Szymon Janc
2015-02-13 12:49     ` Tyszkowski Jakub
2015-02-11 14:34 ` [PATCH 06/10] android/gatt: Improve send_dev_complete_response Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 07/10] android/gatt: Improve send_dev_complete_response even further Jakub Tyszkowski
2015-02-13 11:35   ` Szymon Janc
2015-02-13 13:38     ` Tyszkowski Jakub
2015-02-11 14:34 ` [PATCH 08/10] android/gatt: Remove not needed checks and jumps Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 09/10] android/gatt: Remove redundant matching function Jakub Tyszkowski
2015-02-11 14:34 ` [PATCH 10/10] android/gatt: Avoid copying pointers in matching functions Jakub Tyszkowski
2015-02-13 11:48   ` Szymon Janc [this message]
2015-02-13 13:25     ` Tyszkowski Jakub
2015-02-13 11:49 ` [PATCH 01/10] android/gatt: Replace request state with boolean 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=5088455.trWqmuhi6p@uw000953 \
    --to=szymon.janc@tieto.com \
    --cc=jakub.tyszkowski@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