* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- * MA 02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu-common.h"
static struct l2cap_chan_s *l2cap_channel_open(struct l2cap_instance_s *l2cap,
int psm, int source_cid)
{
- struct l2cap_chan_s *ch = 0;
+ struct l2cap_chan_s *ch = NULL;
struct bt_l2cap_psm_s *psm_info;
int result, status;
int cid = l2cap_cid_new(l2cap);
if (psm_info) {
/* Device supports this use-case. */
- ch = qemu_mallocz(sizeof(*ch));
+ ch = g_malloc0(sizeof(*ch));
ch->params.sdu_out = l2cap_bframe_out;
ch->params.sdu_submit = l2cap_bframe_submit;
ch->frame_in = l2cap_bframe_in;
result = L2CAP_CR_SUCCESS;
status = L2CAP_CS_NO_INFO;
} else {
- qemu_free(ch);
+ g_free(ch);
result = L2CAP_CR_NO_MEM;
status = L2CAP_CS_NO_INFO;
static void l2cap_channel_close(struct l2cap_instance_s *l2cap,
int cid, int source_cid)
{
- struct l2cap_chan_s *ch = 0;
+ struct l2cap_chan_s *ch = NULL;
/* According to Volume 3, section 6.1.1, pg 1048 of BT Core V2.0, a
* connection in CLOSED state still responds with a L2CAP_DisconnectRsp
return;
}
- l2cap->cid[cid] = 0;
+ l2cap->cid[cid] = NULL;
ch->params.close(ch->params.opaque);
- qemu_free(ch);
+ g_free(ch);
}
l2cap_disconnection_response(l2cap, cid, source_cid);
static void l2cap_channel_config_null(struct l2cap_instance_s *l2cap,
struct l2cap_chan_s *ch)
{
- l2cap_configuration_request(l2cap, ch->remote_cid, 0, 0, 0);
+ l2cap_configuration_request(l2cap, ch->remote_cid, 0, NULL, 0);
ch->config_req_id = l2cap->last_id;
ch->config &= ~L2CAP_CFG_INIT;
}
l2cap_rexmit_enable(ch, !(hdr->data[0] >> 7));
if (hdr->data[0] & 1) {
- if (len != 4)
- /* TODO: Signal an error? */;
+ if (len != 4) {
+ /* TODO: Signal an error? */
return;
-
- return l2cap_sframe_in(ch, le16_to_cpup((void *) hdr->data));
+ }
+ l2cap_sframe_in(ch, le16_to_cpup((void *) hdr->data));
+ return;
}
switch (hdr->data[1] >> 6) { /* SAR */
if (len - 4 > ch->mps)
goto len_error;
- return ch->params.sdu_in(ch->params.opaque, hdr->data + 2, len - 4);
+ ch->params.sdu_in(ch->params.opaque, hdr->data + 2, len - 4);
+ break;
case L2CAP_SAR_START:
if (ch->len_total || len < 6)
goto len_error;
memcpy(ch->sdu + ch->len_cur, hdr->data + 2, len - 4);
- return ch->params.sdu_in(ch->params.opaque, ch->sdu, ch->len_total);
+ ch->params.sdu_in(ch->params.opaque, ch->sdu, ch->len_total);
+ break;
case L2CAP_SAR_CONT:
if (!ch->len_total || ch->len_cur + len - 4 >= ch->len_total)
{
struct l2cap_chan_s *chan = (struct l2cap_chan_s *) parms;
- return l2cap_pdu_submit(chan->l2cap);
+ l2cap_pdu_submit(chan->l2cap);
}
#if 0
for (cid = L2CAP_CID_ALLOC; cid < L2CAP_CID_MAX; cid ++)
if (l2cap->cid[cid]) {
l2cap->cid[cid]->params.close(l2cap->cid[cid]->params.opaque);
- free(l2cap->cid[cid]);
+ g_free(l2cap->cid[cid]);
}
if (l2cap->role)
- qemu_free(l2cap);
+ g_free(l2cap);
else
- qemu_free(l2cap->link);
+ g_free(l2cap->link);
}
/* L2CAP glue to lower layers in bluetooth stack (LMP) */
/* Always accept - we only get called if (dev->device->page_scan). */
- l2cap = qemu_mallocz(sizeof(struct slave_l2cap_instance_s));
+ l2cap = g_malloc0(sizeof(struct slave_l2cap_instance_s));
l2cap->link.slave = &dev->device;
l2cap->link.host = link->host;
l2cap_init(&l2cap->l2cap, &l2cap->link, 0);
return;
}
- l2cap = qemu_mallocz(sizeof(struct l2cap_instance_s));
+ l2cap = g_malloc0(sizeof(struct l2cap_instance_s));
l2cap_init(l2cap, link, 1);
link->acl_mode = acl_active;
exit(-1);
}
- new_psm = qemu_mallocz(sizeof(*new_psm));
+ new_psm = g_malloc0(sizeof(*new_psm));
new_psm->psm = psm;
new_psm->min_mtu = min_mtu;
new_psm->new_channel = new_channel;