From: Szymon Janc <szymon.janc@codecoup.pl>
To: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@codecoup.pl>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH BlueZ 2/6] tools/btpclient: Move string to address conversion to helper
Date: Fri, 22 Dec 2017 11:48:28 +0100 [thread overview]
Message-ID: <3054242.MalPW5PRBD@ix> (raw)
In-Reply-To: <20171221164720.20925-2-grzegorz.kolodziejczyk@codecoup.pl>
Hi Grzegorz,
On Thursday, 21 December 2017 17:47:16 CET Grzegorz Kolodziejczyk wrote:
> This patch makes local helper with string to address conversion.
> ---
> tools/btpclient.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/tools/btpclient.c b/tools/btpclient.c
> index 9ea624995..27e5a498e 100644
> --- a/tools/btpclient.c
> +++ b/tools/btpclient.c
> @@ -52,6 +52,12 @@ static struct btp *btp;
>
> static bool gap_service_registered;
>
> +static inline uint8_t str2addr(const char *str, uint8_t *addr)
Just static, no need for inline in .c file.
Also make this return bool and verify sscanf return value in helper.
> +{
> + return sscanf(str,"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &addr[5], &addr[4],
> + &addr[3], &addr[2], &addr[1], &addr[0]);
> +}
> +
> static struct btp_adapter *find_adapter_by_proxy(struct l_dbus_proxy
> *proxy) {
> const struct l_queue_entry *entry;
> @@ -171,9 +177,7 @@ static void btp_gap_read_info(uint8_t index, const void
> *param, uint16_t length, if (!l_dbus_proxy_get_property(adapter->proxy,
> "Address", "s", &str)) goto failed;
>
> - if (sscanf(str,"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
> - &rp.address[5], &rp.address[4], &rp.address[3],
> - &rp.address[2], &rp.address[1], &rp.address[0]) != 6)
> + if (str2addr(str, rp.address) != 6)
> goto failed;
>
> if (!l_dbus_proxy_get_property(adapter->proxy, "Name", "s", &str)) {
--
pozdrawiam
Szymon Janc
next prev parent reply other threads:[~2017-12-22 10:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-21 16:47 [PATCH BlueZ 1/6] shared/btp: define gap device found flags as bit mask Grzegorz Kolodziejczyk
2017-12-21 16:47 ` [PATCH BlueZ 2/6] tools/btpclient: Move string to address conversion to helper Grzegorz Kolodziejczyk
2017-12-22 10:48 ` Szymon Janc [this message]
2017-12-22 13:49 ` Grzegorz Kołodziejczyk
2017-12-21 16:47 ` [PATCH BlueZ 3/6] tools/btpclient: Add advertising proxy to adapter Grzegorz Kolodziejczyk
2017-12-22 10:48 ` Szymon Janc
2017-12-22 13:50 ` Grzegorz Kołodziejczyk
2017-12-21 16:47 ` [PATCH BlueZ 4/6] tools/btpclient: Add device found event Grzegorz Kolodziejczyk
2017-12-22 10:48 ` Szymon Janc
2017-12-22 13:51 ` Grzegorz Kołodziejczyk
2017-12-21 16:47 ` [PATCH BlueZ 5/6] tools/btpclient: Add start, stop discovery commands Grzegorz Kolodziejczyk
2017-12-22 10:48 ` Szymon Janc
2017-12-22 13:53 ` Grzegorz Kołodziejczyk
2017-12-21 16:47 ` [PATCH BlueZ 6/6] tools/btpclient: Add set connectable command Grzegorz Kolodziejczyk
2017-12-22 10:49 ` [PATCH BlueZ 1/6] shared/btp: define gap device found flags as bit mask 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=3054242.MalPW5PRBD@ix \
--to=szymon.janc@codecoup.pl \
--cc=grzegorz.kolodziejczyk@codecoup.pl \
--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 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.