linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Lukasz Rymanowski <lukasz.rymanowski@gmail.com>
Cc: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>,
	"linux-bluetooth@vger.kernel.org"
	<linux-bluetooth@vger.kernel.org>,
	Szymon Janc <szymon.janc@tieto.com>
Subject: Re: [PATCH 25/36] android/gatt: Add support to read request
Date: Tue, 29 Apr 2014 15:56:52 +0300	[thread overview]
Message-ID: <20140429125652.GA18942@t440s.lan> (raw)
In-Reply-To: <CAN_7+Yb4ZgRYHSZUfjkGz7bEdvuyt7GDUS6w5y7Aurq8E0+xgw@mail.gmail.com>

Hi Lukasz,

On Tue, Apr 29, 2014, Lukasz Rymanowski wrote:
> On Tue, Apr 29, 2014 at 10:13 AM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> > On Tue, Apr 29, 2014, Lukasz Rymanowski wrote:
> >> +static uint8_t read_request(const uint8_t *cmd, uint16_t cmd_len,
> >> +                                     struct gatt_device *dev)
> >> +{
> >> +     uint16_t handle;
> >> +     uint16_t len;
> >> +     uint16_t offset = 0;
> >> +     struct req_data *req_data;
> >> +
> >> +     DBG("");
> >> +
> >> +     req_data = new0(struct req_data, 1);
> >> +     if (!req_data)
> >> +             return ATT_ECODE_UNLIKELY;
> >> +
> >> +     switch (cmd[0]) {
> >> +     case ATT_OP_READ_BLOB_REQ:
> >> +             len = dec_read_blob_req(cmd, cmd_len, &handle, &offset);
> >> +             if (!len) {
> >> +                     free(req_data);
> >> +                     return ATT_ECODE_INVALID_PDU;
> >> +             }
> >> +             req_data->long_read = true;
> >> +             break;
> >> +     case ATT_OP_READ_REQ:
> >> +             len = dec_read_req(cmd, cmd_len, &handle);
> >> +             if (!len) {
> >> +                     free(req_data);
> >> +                     return ATT_ECODE_INVALID_PDU;
> >> +             }
> >> +             break;
> >> +     default:
> >> +             error("gatt: Unexpected read type 0x%02x", cmd[0]);
> >> +             free(req_data);
> >> +             return ATT_ECODE_REQ_NOT_SUPP;
> >> +     }
> >> +
> >> +     req_data->dev = dev;
> >> +     req_data->opcode = cmd[0];
> >> +
> >> +     if (!gatt_db_read(gatt_db, handle, offset, req_data)) {
> >> +             free(req_data);
> >> +             return ATT_ECODE_UNLIKELY;
> >> +     }
> >> +
> >> +     return 0;
> >> +}
> >
> > Where is req_data freed in the case that gatt_db_read succeeds?
> 
> It is freed later in the callback. Will put comment about that.

Which callback is that? E.g. in 13/36 the gap_read_cb function does not
free req_data.

In general this kind of API design seems quite strange to me. Probably
the information contained in struct req_data can be made fixed for the
gatt-db API instead of something chosen by the user (in this case
android/gatt.c), and probably doesn't have to be dynamically allocated
to begin with.

Johan

  reply	other threads:[~2014-04-29 12:56 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-29  1:14 [PATCH 00/36] android/gatt: GATT server implementation Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 01/36] android/gatt: Add comment about event type being sent Lukasz Rymanowski
2014-04-29  7:57   ` Johan Hedberg
2014-04-29 10:20     ` Szymon Janc
2014-04-29  9:47   ` Tyszkowski Jakub
2014-04-29  1:14 ` [PATCH] android/gatt: Add support for send indication Lukasz Rymanowski
2014-04-29  1:19   ` Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 02/36] android/gatt: Add service functionality Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 03/36] android/gatt: Add implementation of delete service Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 04/36] android/gatt: Add included service implementation Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 05/36] android/gatt: Add characteristic implementation Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 06/36] android/gatt: Add handling of start service command Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 07/36] android/gatt: Add stop service command handling Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 08/36] android/gatt: Add descriptor implementation Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 09/36] android/gatt: Add listening socket for GATT Lukasz Rymanowski
2014-04-29  8:01   ` Johan Hedberg
2014-04-29 10:41     ` Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 10/36] android/gatt: Add ATT msg handler Lukasz Rymanowski
2014-04-29  8:03   ` Johan Hedberg
2014-04-29 10:44     ` Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 11/36] shared: Use pointer for request data instead of int Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 12/36] shared/gatt: Extend read callback with offset Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 13/36] android/gatt: Add register GAP Service Lukasz Rymanowski
2014-04-29  8:05   ` Johan Hedberg
2014-04-29 11:15     ` Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 14/36] gatt: Add some characteristics uuids Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 15/36] android/gatt: Register device information service Lukasz Rymanowski
2014-04-29  8:08   ` Johan Hedberg
2014-04-29 11:35     ` Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 16/36] shared: Extend write callback with offset Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 17/36] android/gatt: Register GATT service Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 18/36] shared/gatt: Add function to read by group type Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 19/36] shared/gatt: Add function to find by type Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 20/36] shared/gatt: Add function to read " Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 21/36] android/gatt: Add support for ATT read by group type Lukasz Rymanowski
2014-04-29  8:11   ` Johan Hedberg
2014-04-29  1:14 ` [PATCH 22/36] android/gatt: Add support for ATT read by type Lukasz Rymanowski
2014-04-29  8:12   ` Johan Hedberg
2014-04-29 11:37     ` Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 23/36] shared/gatt: Add support to read from database Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 24/36] android/gatt: Move struct req_data up in the file Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 25/36] android/gatt: Add support to read request Lukasz Rymanowski
2014-04-29  8:13   ` Johan Hedberg
2014-04-29 12:12     ` Lukasz Rymanowski
2014-04-29 12:56       ` Johan Hedberg [this message]
2014-04-29 16:32         ` Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 26/36] android/gatt: Add MTU request cmd handling Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 27/36] android/gatt: Add Find info gatt server " Lukasz Rymanowski
2014-04-29  1:14 ` [PATCH 28/36] shared/gatt: Add support for write request Lukasz Rymanowski
2014-04-29  1:15 ` [PATCH 29/36] android/gatt: " Lukasz Rymanowski
2014-04-29  8:15   ` Johan Hedberg
2014-04-29  1:15 ` [PATCH 30/36] android/gatt: Add support for execute write Lukasz Rymanowski
2014-04-29  1:15 ` [PATCH 31/36] android/gatt: Move struct req_data upper in the file Lukasz Rymanowski
2014-04-29  1:15 ` [PATCH 32/36] android/gatt: Add write callback to server Lukasz Rymanowski
2014-04-29  8:16   ` Johan Hedberg
2014-04-30  9:14     ` Lukasz Rymanowski
2014-04-29  1:15 ` [PATCH 33/36] android/gatt: Add read_cb for GATT Server Lukasz Rymanowski
2014-04-29  1:15 ` [PATCH 34/36] android/hal-gatt-api: Fix IPC definition for send response Lukasz Rymanowski
2014-04-29  1:15 ` [PATCH 35/36] android/gatt: Add support for GATT server " Lukasz Rymanowski
2014-04-29  1:15 ` [PATCH 36/36] android/gatt: Add support for send indication Lukasz Rymanowski
2014-04-29  1:21 ` [PATCH 00/36] android/gatt: GATT server implementation Lukasz Rymanowski

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=20140429125652.GA18942@t440s.lan \
    --to=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=lukasz.rymanowski@gmail.com \
    --cc=lukasz.rymanowski@tieto.com \
    --cc=szymon.janc@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;
as well as URLs for NNTP newsgroup(s).