From: Johan Hedberg <johan.hedberg@gmail.com>
To: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 2/3] android/bluetooth: Add support for get remote service record property cmd
Date: Thu, 14 Aug 2014 13:01:24 +0300 [thread overview]
Message-ID: <20140814100124.GA2865@t440s.ger.corp.intel.com> (raw)
In-Reply-To: <1407937477-25402-2-git-send-email-grzegorz.kolodziejczyk@tieto.com>
Hi Grzegorz,
On Wed, Aug 13, 2014, Grzegorz Kolodziejczyk wrote:
> +static void send_remote_sdp_rec_notify(bt_uuid_t *uuid, int channel,
> + char *name, uint8_t name_len,
> + uint8_t status, bdaddr_t *bdaddr)
> +{
> + struct hal_prop_device_service_rec *prop;
> + uint8_t buf[BASELEN_REMOTE_DEV_PROP + name_len + sizeof(*prop)];
> + struct hal_ev_remote_device_props *ev = (void *) buf;
> + int prop_len = sizeof(*prop) + name_len;
> +
> + memset(buf, 0, sizeof(buf));
> +
> + if (status == HAL_STATUS_SUCCESS) {
> + prop = malloc(sizeof(*prop) + name_len);
> + prop->name_len = name_len;
> + prop->channel = (uint16_t)channel;
> + memcpy(prop->name, name, name_len);
> + memcpy(prop->uuid, &uuid->value.u128, sizeof(prop->uuid));
> +
> + memcpy(ev->props[0].val, prop, prop_len);
> +
> + free(prop);
> + }
This whole extra malloc (which btw is missing a NULL check) seems
unnecessary to me. Why don't you simply do:
if (status == HAL_STATUS_SUCCESS) {
prop = (void *) &ev->props[0].val;
prop->name_len = name_len;
prop->channel = channel;
memcpy(prop->name, name, name_len);
memcpy(prop->uuid, &uuid->value.u128, sizeof(prop->uuid));
}
Johan
next prev parent reply other threads:[~2014-08-14 10:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-13 13:44 [PATCH 1/3] android/bluetooth: remove unused include Grzegorz Kolodziejczyk
2014-08-13 13:44 ` [PATCH 2/3] android/bluetooth: Add support for get remote service record property cmd Grzegorz Kolodziejczyk
2014-08-14 10:01 ` Johan Hedberg [this message]
2014-08-14 10:13 ` Grzegorz Kolodziejczyk
2014-08-13 13:44 ` [PATCH 3/3] android/pts: Update IOPT test results Grzegorz Kolodziejczyk
2014-08-14 10:02 ` [PATCH 1/3] android/bluetooth: remove unused include Johan Hedberg
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=20140814100124.GA2865@t440s.ger.corp.intel.com \
--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