* [PATCH RESEND 1/2] android/handsfree-client: Decrease number of memcpy
@ 2014-12-08 10:47 Lukasz Rymanowski
2014-12-08 10:47 ` [PATCH RESEND 2/2] android/handsfree-client: Trivial fix typo Lukasz Rymanowski
2014-12-08 13:17 ` [PATCH RESEND 1/2] android/handsfree-client: Decrease number of memcpy Szymon Janc
0 siblings, 2 replies; 4+ messages in thread
From: Lukasz Rymanowski @ 2014-12-08 10:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
Some string we can directly copy from context to IPC event struct.
---
android/handsfree-client.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/android/handsfree-client.c b/android/handsfree-client.c
index f7a03cc..3eb8517 100644
--- a/android/handsfree-client.c
+++ b/android/handsfree-client.c
@@ -85,6 +85,9 @@
#define CODEC_ID_CVSD 0x01
#define CODEC_ID_MSBC 0x02
+#define MAX_NUMBER_LEN 33
+#define MAX_OPERATOR_NAME_LEN 17
+
enum hfp_indicator {
HFP_INDICATOR_SERVICE = 0,
HFP_INDICATOR_CALL,
@@ -938,7 +941,6 @@ static void clcc_cb(struct hfp_context *context, void *user_data)
uint8_t buf[IPC_MTU];
struct hal_ev_hf_client_current_call *ev = (void *) buf;
unsigned int val;
- char number[33];
DBG("");
@@ -980,10 +982,9 @@ static void clcc_cb(struct hfp_context *context, void *user_data)
ev->multiparty = val;
- if (hfp_context_get_string(context, number, sizeof(number))) {
- ev->number_len = strlen(number) + 1;
- memcpy(ev->number, number, ev->number_len);
- }
+ if (hfp_context_get_string(context, (char *) &ev->number[0],
+ MAX_NUMBER_LEN))
+ ev->number_len = strlen((char *) ev->number) + 1;
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
HAL_EV_HF_CLIENT_CURRENT_CALL,
@@ -1020,7 +1021,6 @@ static void cnum_cb(struct hfp_context *context, void *user_data)
{
uint8_t buf[IPC_MTU];
struct hal_ev_hf_client_subscriber_service_info *ev = (void *) buf;
- char number[33];
unsigned int service;
DBG("");
@@ -1028,11 +1028,14 @@ static void cnum_cb(struct hfp_context *context, void *user_data)
/* Alpha field is empty string, just skip it */
hfp_context_skip_field(context);
- if (!hfp_context_get_string(context, number, sizeof(number))) {
+ if (!hfp_context_get_string(context, (char *) &ev->name[0],
+ MAX_NUMBER_LEN)) {
error("hf-client: Could not get number");
return;
}
+ ev->name_len = strlen((char *) &ev->name[0]) + 1;
+
/* Type is not used in Android */
hfp_context_skip_field(context);
@@ -1042,9 +1045,6 @@ static void cnum_cb(struct hfp_context *context, void *user_data)
if (!hfp_context_get_number(context, &service))
return;
- ev->name_len = strlen(number) + 1;
- memcpy(ev->name, number, ev->name_len);
-
switch (service) {
case 4:
ev->type = HAL_HF_CLIENT_SUBSCR_TYPE_VOICE;
@@ -1066,7 +1066,6 @@ static void cops_cb(struct hfp_context *context, void *user_data)
{
uint8_t buf[IPC_MTU];
struct hal_ev_hf_client_operator_name *ev = (void *) buf;
- char name[17];
unsigned int format;
DBG("");
@@ -1080,13 +1079,13 @@ static void cops_cb(struct hfp_context *context, void *user_data)
if (format != 0)
info("hf-client: Not correct string format in +COSP");
- if (!hfp_context_get_string(context, name, sizeof(name))) {
+ if (!hfp_context_get_string(context,(char *) &ev->name[0] ,
+ MAX_OPERATOR_NAME_LEN)) {
error("hf-client: incorrect COPS response");
return;
}
- ev->name_len = strlen(name) + 1;
- memcpy(ev->name, name, ev->name_len);
+ ev->name_len = strlen((char *) &ev->name[0]) + 1;
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
HAL_EV_HF_CLIENT_OPERATOR_NAME,
--
1.8.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH RESEND 2/2] android/handsfree-client: Trivial fix typo
2014-12-08 10:47 [PATCH RESEND 1/2] android/handsfree-client: Decrease number of memcpy Lukasz Rymanowski
@ 2014-12-08 10:47 ` Lukasz Rymanowski
2014-12-08 13:18 ` Szymon Janc
2014-12-08 13:17 ` [PATCH RESEND 1/2] android/handsfree-client: Decrease number of memcpy Szymon Janc
1 sibling, 1 reply; 4+ messages in thread
From: Lukasz Rymanowski @ 2014-12-08 10:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
---
android/hal-msg.h | 2 +-
android/handsfree-client.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index d43cdbe..3cf2d85 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -2226,7 +2226,7 @@ struct hal_ev_hf_client_call_waiting {
} __attribute__((packed));
#define HAL_HF_CLIENT_DIRECTION_OUTGOING 0x00
-#define HAL_HF_CLIENT_DIRECTION_INCOMIGN 0x01
+#define HAL_HF_CLIENT_DIRECTION_INCOMING 0x01
#define HAL_HF_CLIENT_CALL_STATE_ACTIVE 0x00
#define HAL_HF_CLIENT_CALL_STATE_HELD 0x01
diff --git a/android/handsfree-client.c b/android/handsfree-client.c
index 3eb8517..007ac32 100644
--- a/android/handsfree-client.c
+++ b/android/handsfree-client.c
@@ -954,7 +954,7 @@ static void clcc_cb(struct hfp_context *context, void *user_data)
ev->index = val;
if (!hfp_context_get_number(context, &val) ||
- val > HAL_HF_CLIENT_DIRECTION_INCOMIGN) {
+ val > HAL_HF_CLIENT_DIRECTION_INCOMING) {
error("hf-client: Could not get direction");
return;
}
--
1.8.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH RESEND 2/2] android/handsfree-client: Trivial fix typo
2014-12-08 10:47 ` [PATCH RESEND 2/2] android/handsfree-client: Trivial fix typo Lukasz Rymanowski
@ 2014-12-08 13:18 ` Szymon Janc
0 siblings, 0 replies; 4+ messages in thread
From: Szymon Janc @ 2014-12-08 13:18 UTC (permalink / raw)
To: Lukasz Rymanowski; +Cc: linux-bluetooth
Hi Łukasz,
On Monday 08 of December 2014 11:47:36 Lukasz Rymanowski wrote:
> ---
> android/hal-msg.h | 2 +-
> android/handsfree-client.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/android/hal-msg.h b/android/hal-msg.h
> index d43cdbe..3cf2d85 100644
> --- a/android/hal-msg.h
> +++ b/android/hal-msg.h
> @@ -2226,7 +2226,7 @@ struct hal_ev_hf_client_call_waiting {
> } __attribute__((packed));
>
> #define HAL_HF_CLIENT_DIRECTION_OUTGOING 0x00
> -#define HAL_HF_CLIENT_DIRECTION_INCOMIGN 0x01
> +#define HAL_HF_CLIENT_DIRECTION_INCOMING 0x01
>
> #define HAL_HF_CLIENT_CALL_STATE_ACTIVE 0x00
> #define HAL_HF_CLIENT_CALL_STATE_HELD 0x01
> diff --git a/android/handsfree-client.c b/android/handsfree-client.c
> index 3eb8517..007ac32 100644
> --- a/android/handsfree-client.c
> +++ b/android/handsfree-client.c
> @@ -954,7 +954,7 @@ static void clcc_cb(struct hfp_context *context, void
> *user_data) ev->index = val;
>
> if (!hfp_context_get_number(context, &val) ||
> - val > HAL_HF_CLIENT_DIRECTION_INCOMIGN) {
> + val > HAL_HF_CLIENT_DIRECTION_INCOMING) {
> error("hf-client: Could not get direction");
> return;
> }
This patch is now applied, thanks.
--
BR
Szymon Janc
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH RESEND 1/2] android/handsfree-client: Decrease number of memcpy
2014-12-08 10:47 [PATCH RESEND 1/2] android/handsfree-client: Decrease number of memcpy Lukasz Rymanowski
2014-12-08 10:47 ` [PATCH RESEND 2/2] android/handsfree-client: Trivial fix typo Lukasz Rymanowski
@ 2014-12-08 13:17 ` Szymon Janc
1 sibling, 0 replies; 4+ messages in thread
From: Szymon Janc @ 2014-12-08 13:17 UTC (permalink / raw)
To: Lukasz Rymanowski; +Cc: linux-bluetooth
Hi Łukasz,
On Monday 08 of December 2014 11:47:35 Lukasz Rymanowski wrote:
> Some string we can directly copy from context to IPC event struct.
> ---
> android/handsfree-client.c | 27 +++++++++++++--------------
> 1 file changed, 13 insertions(+), 14 deletions(-)
>
> diff --git a/android/handsfree-client.c b/android/handsfree-client.c
> index f7a03cc..3eb8517 100644
> --- a/android/handsfree-client.c
> +++ b/android/handsfree-client.c
> @@ -85,6 +85,9 @@
> #define CODEC_ID_CVSD 0x01
> #define CODEC_ID_MSBC 0x02
>
> +#define MAX_NUMBER_LEN 33
> +#define MAX_OPERATOR_NAME_LEN 17
> +
> enum hfp_indicator {
> HFP_INDICATOR_SERVICE = 0,
> HFP_INDICATOR_CALL,
> @@ -938,7 +941,6 @@ static void clcc_cb(struct hfp_context *context, void
> *user_data) uint8_t buf[IPC_MTU];
> struct hal_ev_hf_client_current_call *ev = (void *) buf;
> unsigned int val;
> - char number[33];
>
> DBG("");
>
> @@ -980,10 +982,9 @@ static void clcc_cb(struct hfp_context *context, void
> *user_data)
>
> ev->multiparty = val;
>
> - if (hfp_context_get_string(context, number, sizeof(number))) {
> - ev->number_len = strlen(number) + 1;
> - memcpy(ev->number, number, ev->number_len);
> - }
> + if (hfp_context_get_string(context, (char *) &ev->number[0],
> + MAX_NUMBER_LEN))
> + ev->number_len = strlen((char *) ev->number) + 1;
>
> ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
> HAL_EV_HF_CLIENT_CURRENT_CALL,
> @@ -1020,7 +1021,6 @@ static void cnum_cb(struct hfp_context *context, void
> *user_data) {
> uint8_t buf[IPC_MTU];
> struct hal_ev_hf_client_subscriber_service_info *ev = (void *) buf;
> - char number[33];
> unsigned int service;
>
> DBG("");
> @@ -1028,11 +1028,14 @@ static void cnum_cb(struct hfp_context *context,
> void *user_data) /* Alpha field is empty string, just skip it */
> hfp_context_skip_field(context);
>
> - if (!hfp_context_get_string(context, number, sizeof(number))) {
> + if (!hfp_context_get_string(context, (char *) &ev->name[0],
> + MAX_NUMBER_LEN)) {
> error("hf-client: Could not get number");
> return;
> }
>
> + ev->name_len = strlen((char *) &ev->name[0]) + 1;
> +
> /* Type is not used in Android */
> hfp_context_skip_field(context);
>
> @@ -1042,9 +1045,6 @@ static void cnum_cb(struct hfp_context *context, void
> *user_data) if (!hfp_context_get_number(context, &service))
> return;
>
> - ev->name_len = strlen(number) + 1;
> - memcpy(ev->name, number, ev->name_len);
> -
> switch (service) {
> case 4:
> ev->type = HAL_HF_CLIENT_SUBSCR_TYPE_VOICE;
> @@ -1066,7 +1066,6 @@ static void cops_cb(struct hfp_context *context, void
> *user_data) {
> uint8_t buf[IPC_MTU];
> struct hal_ev_hf_client_operator_name *ev = (void *) buf;
> - char name[17];
> unsigned int format;
>
> DBG("");
> @@ -1080,13 +1079,13 @@ static void cops_cb(struct hfp_context *context,
> void *user_data) if (format != 0)
> info("hf-client: Not correct string format in +COSP");
>
> - if (!hfp_context_get_string(context, name, sizeof(name))) {
> + if (!hfp_context_get_string(context,(char *) &ev->name[0] ,
Some coding style issues here (no space after comma and space before comma).
> + MAX_OPERATOR_NAME_LEN)) {
> error("hf-client: incorrect COPS response");
> return;
> }
>
> - ev->name_len = strlen(name) + 1;
> - memcpy(ev->name, name, ev->name_len);
> + ev->name_len = strlen((char *) &ev->name[0]) + 1;
>
> ipc_send_notif(hal_ipc, HAL_SERVICE_ID_HANDSFREE_CLIENT,
> HAL_EV_HF_CLIENT_OPERATOR_NAME,
--
BR
Szymon Janc
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-12-08 13:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-08 10:47 [PATCH RESEND 1/2] android/handsfree-client: Decrease number of memcpy Lukasz Rymanowski
2014-12-08 10:47 ` [PATCH RESEND 2/2] android/handsfree-client: Trivial fix typo Lukasz Rymanowski
2014-12-08 13:18 ` Szymon Janc
2014-12-08 13:17 ` [PATCH RESEND 1/2] android/handsfree-client: Decrease number of memcpy Szymon Janc
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.