Linux bluetooth development
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Marcin Kraglak <marcin.kraglak@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 1/2] android/client: Fix reversing send_response values
Date: Thu, 5 Jun 2014 18:54:51 +0200	[thread overview]
Message-ID: <98CCDBAF-AEE9-40C7-AD1D-C8CEC69FDA9A@holtmann.org> (raw)
In-Reply-To: <1401985955-13502-1-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

> We don't want to reverse data passed to send_response.
> ---
> android/client/if-gatt.c | 32 +++++++++++++++++++++++++++-----
> 1 file changed, 27 insertions(+), 5 deletions(-)
> 
> diff --git a/android/client/if-gatt.c b/android/client/if-gatt.c
> index 0375126..a9c8644 100644
> --- a/android/client/if-gatt.c
> +++ b/android/client/if-gatt.c
> @@ -1750,6 +1750,30 @@ static void gatts_send_indication_p(int argc, const char *argv[])
> 							len, confirm, data);
> }
> 
> +/*
> + * convert hex string to uint8_t array
> + */
> +static int fill_buffer(const char *str, uint8_t *out, int out_size)
> +{
> +	int len = strlen(str);
> +	int length = 0;
> +	int i;
> +
> +	memset(out, 0, out_size);
> +	if (out_size * 2 > len + 1)
> +		out_size = (len + 1) / 2;
> +
> +	for (i = 0; i < out_size && len > length; ++i) {
> +		if (len >= length)
> +			sscanf(str + length, "%02hhx", &out[i]);
> +		else
> +			sscanf(str, "%1hhx", &out[i]);
> +		length += 2;
> +	}
> +
> +	return len/2;
> +}

it is just the client code, but what is this function doing? My brain seriously takes a core dump trying to understand this.

Has anybody actually looked into decode_hex_own_buf or similar from oFono. Using sscanf seems the most inefficient way of handling this.

Regards

Marcel


  parent reply	other threads:[~2014-06-05 16:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-05 16:32 [PATCH 1/2] android/client: Fix reversing send_response values Marcin Kraglak
2014-06-05 16:32 ` [PATCH 2/2] android/pts: Update GATT test result Marcin Kraglak
2014-06-05 16:49   ` Marcel Holtmann
2014-06-05 16:54 ` Marcel Holtmann [this message]
2014-06-06  4:14   ` [PATCH 1/2] android/client: Fix reversing send_response values 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=98CCDBAF-AEE9-40C7-AD1D-C8CEC69FDA9A@holtmann.org \
    --to=marcel@holtmann.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcin.kraglak@tieto.com \
    /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