From: Szymon Janc <szymon.janc@tieto.com>
To: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] android/avrcp-lib: Use void pointer in register_notification
Date: Thu, 16 Apr 2015 13:24:23 +0200 [thread overview]
Message-ID: <204171214.V0XEUk3NZF@leonov> (raw)
In-Reply-To: <1429019315-29216-1-git-send-email-szymon.janc@tieto.com>
On Tuesday 14 of April 2015 15:48:35 Szymon Janc wrote:
> In this callback params vary depending on code. Passing those as void*
> allows to avoid extra memcpy that would be otherwise needed to
> avoid warnings due to increased alignment when casting.
> ---
> android/avrcp-lib.h | 2 +-
> android/avrcp.c | 5 +++--
> unit/test-avrcp.c | 9 +++++----
> 3 files changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
> index add7739..6554b12 100644
> --- a/android/avrcp-lib.h
> +++ b/android/avrcp-lib.h
> @@ -224,7 +224,7 @@ struct avrcp_control_cfm {
> char **text, void *user_data);
> bool (*register_notification) (struct avrcp *session, int err,
> uint8_t code, uint8_t event,
> - uint8_t *params, void *user_data);
> + void *params, void *user_data);
> void (*set_volume) (struct avrcp *session, int err, uint8_t volume,
> void *user_data);
> void (*set_addressed) (struct avrcp *session, int err,
> diff --git a/android/avrcp.c b/android/avrcp.c
> index bcb4228..8c3e25a 100644
> --- a/android/avrcp.c
> +++ b/android/avrcp.c
> @@ -748,11 +748,12 @@ static const struct avrcp_control_ind control_ind = {
>
> static bool handle_register_notification_rsp(struct avrcp *session, int
> err, uint8_t code, uint8_t event,
> - uint8_t *params,
> + void *params,
> void *user_data)
> {
> struct avrcp_device *dev = user_data;
> struct hal_ev_avrcp_volume_changed ev;
> + uint8_t *volume = params;
>
> if (err < 0) {
> error("AVRCP: %s", strerror(-err));
> @@ -766,7 +767,7 @@ static bool handle_register_notification_rsp(struct
> avrcp *session, int err, return false;
>
> ev.type = code;
> - ev.volume = params[0] & 0x7f;
> + ev.volume = volume[0];
>
> ipc_send_notif(hal_ipc, HAL_SERVICE_ID_AVRCP,
> HAL_EV_AVRCP_VOLUME_CHANGED,
> diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
> index a610ad5..01307e6 100644
> --- a/unit/test-avrcp.c
> +++ b/unit/test-avrcp.c
> @@ -826,22 +826,23 @@ static void set_volume_rsp(struct avrcp *session, int
> err, uint8_t volume,
>
> static bool register_notification_rsp(struct avrcp *session, int err,
> uint8_t code, uint8_t event,
> - uint8_t *params, void *user_data)
> + void *params, void *user_data)
> {
> struct context *context = user_data;
> + uint8_t *p = params;
>
> g_assert_cmpint(err, ==, 0);
>
> switch (event) {
> case AVRCP_EVENT_VOLUME_CHANGED:
> if (g_str_equal(context->data->test_name, "/TP/VLH/BV-03-C")) {
> - g_assert_cmpint(params[0], ==, 0);
> + g_assert_cmpint(p[0], ==, 0);
> break;
> } else if (code == AVC_CTYPE_INTERIM) {
> - g_assert_cmpint(params[0], ==, 0);
> + g_assert_cmpint(p[0], ==, 0);
> return true;
> }
> - g_assert_cmpint(params[0], ==, 1);
> + g_assert_cmpint(p[0], ==, 1);
> break;
> }
Applied.
--
BR
Szymon Janc
next prev parent reply other threads:[~2015-04-16 11:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-14 13:48 [PATCH] android/avrcp-lib: Use void pointer in register_notification Szymon Janc
2015-04-16 11:24 ` Szymon Janc [this message]
2015-04-16 14:42 ` Luiz Augusto von Dentz
2015-04-16 14:47 ` 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=204171214.V0XEUk3NZF@leonov \
--to=szymon.janc@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;
as well as URLs for NNTP newsgroup(s).