From: Johan Hedberg <johan.hedberg@gmail.com>
To: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH v2 1/2] android/bluetooth: Add support for get remote service record property cmd
Date: Thu, 14 Aug 2014 15:28:50 +0300 [thread overview]
Message-ID: <20140814122850.GA10628@t440s> (raw)
In-Reply-To: <1408017189-15089-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
Hi Grzegorz,
On Thu, Aug 14, 2014, Grzegorz Kolodziejczyk wrote:
> + prop->channel = (uint16_t)channel;
This typecast seems unnecessary to me. At least I don't get any compiler
warnings/errors if I remove it.
> +static void find_remote_sdp_rec_cb(sdp_list_t *recs, int err,
> + gpointer user_data)
> +{
> + uint8_t name_len = 0;
> + uint8_t status;
> + char name_buf[256];
> + int channel = 0;
Since both name_len and channel are tied to the specific record that
you're iterating it seems wrong to me to initialize these here.
> + for ( ; recs; recs = recs->next) {
> + sdp_rec = recs->data;
> +
> + switch (sdp_rec->svclass.type) {
> + case SDP_UUID16:
> + sdp_uuid16_to_uuid128(&uuid128_sdp,
> + &sdp_rec->svclass);
> + break;
> + case SDP_UUID32:
> + sdp_uuid32_to_uuid128(&uuid128_sdp,
> + &sdp_rec->svclass);
> + break;
> + case SDP_UUID128:
> + break;
> + default:
> + error("wrong sdp uuid type");
> + goto done;
> + }
> +
> + if (!sdp_get_access_protos(sdp_rec, &protos)) {
> + channel = sdp_get_proto_port(protos, L2CAP_UUID);
> + if (channel < 0)
> + error("wrong channel");
> + }
Probably this should be here:
} else {
channel = -1;
}
> + if (!sdp_get_service_name(sdp_rec, name_buf, sizeof(name_buf)))
> + name_len = (uint8_t)strlen(name_buf);
And here:
else
name_len = 0;
Otherwise you'll end up including the name from previous records as the
name of subsequent ones which don't have a service name attribute. Also,
the (uint8_t) typecast seems unnecessary here (compiles fine for me
without it).
> +static uint8_t find_remote_sdp_rec(const bdaddr_t *addr,
> + const uint8_t *find_uuid)
> +{
> + uuid_t uuid;
> + bdaddr_t *bdaddr;
> +
> + /* from android we always get full 128bit length uuid */
> + sdp_uuid128_create(&uuid, find_uuid);
> +
> + bdaddr = malloc(sizeof(*bdaddr));
Could you tell me what's the rationale of choosing malloc vs g_malloc in
this code. In most places this c-file is using the GLib allocators and
having a mixed set is just begging for trouble (e.g. you might end up
calling g_free on something allocated with malloc, or free for something
allocated with g_malloc).
Johan
next prev parent reply other threads:[~2014-08-14 12:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-14 11:53 [PATCH v2 1/2] android/bluetooth: Add support for get remote service record property cmd Grzegorz Kolodziejczyk
2014-08-14 11:53 ` [PATCH v2 2/2] android/pts: Update IOPT test results Grzegorz Kolodziejczyk
2014-08-14 12:28 ` Johan Hedberg [this message]
2014-08-14 12:43 ` [PATCH v2 1/2] android/bluetooth: Add support for get remote service record property cmd Grzegorz Kolodziejczyk
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=20140814122850.GA10628@t440s \
--to=johan.hedberg@gmail.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