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] android/client: Check if hex string is byte format
Date: Tue, 09 Sep 2014 13:06:59 +0200	[thread overview]
Message-ID: <5489320.EjvoHrjmAo@leonov> (raw)
In-Reply-To: <1409925341-32033-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>

Hi Grzegorz,

On Friday 05 of September 2014 15:55:41 Grzegorz Kolodziejczyk wrote:
> Data strings should be byte format.
> ---
>  android/client/if-gatt.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/android/client/if-gatt.c b/android/client/if-gatt.c
> index c8352b5..0dee225 100644
> --- a/android/client/if-gatt.c
> +++ b/android/client/if-gatt.c
> @@ -114,11 +114,17 @@ const btgatt_interface_t *if_gatt = NULL;
> 
>  #define GET_VERIFY_HEX_STRING(n, v, l) \
>  	do { \
> +		int ll;\
>  		if (n[0] != '0' || (n[1] != 'X' && n[1] != 'x')) { \
>  			haltest_error("Value must be hex string\n"); \
>  			return; \
>  		} \
> -		l = fill_buffer(n + 2, (uint8_t *) v, sizeof(v)); \
> +		ll = fill_buffer(n + 2, (uint8_t *) v, sizeof(v)); \
> +		if (ll < 0) { \
> +			haltest_error("Value must be byte hex string\n"); \
> +			return; \
> +		} \
> +		l = ll; \
>  	} while (0)
> 
>  /* Gatt uses little endian uuid */
> @@ -803,6 +809,10 @@ static int fill_buffer(const char *str, uint8_t *out,
> int out_size)
> 
>  	str_len = strlen(str);
> 
> +	/* Hex string must be byte format */
> +	if (str_len%2 != 0)
> +		return -1;

There should be spaces around '%'. I've fixed this myself but please pay 
attention to coding style.

> +
>  	for (i = 0, j = 0; i < out_size && j < str_len; i++, j++) {
>  		c = str[j];

Patch applied. Thanks.

-- 
BR
Szymon Janc

      reply	other threads:[~2014-09-09 11:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-05 13:55 [PATCH] android/client: Check if hex string is byte format Grzegorz Kolodziejczyk
2014-09-09 11:06 ` Szymon Janc [this message]

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=5489320.EjvoHrjmAo@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