Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1818874pxb; Fri, 6 Nov 2020 23:04:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNec4sLicb/WGFYjkWp+o7MXM44T/tsTJE6HG66QWnWql6t56tKY0u/SVdVe9zeNPlRoNK X-Received: by 2002:aa7:d717:: with SMTP id t23mr5690484edq.286.1604732648677; Fri, 06 Nov 2020 23:04:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604732648; cv=none; d=google.com; s=arc-20160816; b=XFF3RL32Q2N5ZFQSJJE9lArkhGESczURFwfAjgCXQ4VzI2zZqBT4mh0SehozhMUA49 BtFzLeI5w0YPbHbHHv1UukPZsmwbLYP8lKoxiNnpOt1vxWQIYFh/i2kwRrgIVImZi+aB qNDHjq+pWgpb+BbBOb6kcW/yCuCJOhuZPco92QqjpNn3/OXAfPbOnsfoXOqDKp7fHabY 35vtSfKIimdLwq4qjNT37GX4Un/P3ocXqEVqjwjdCySV9U89APsxm/4i4mAeGob3cV/X 4wwvjxZ32/xzOt/Y+r4I9Qg+RU2Z80BE4AKTlwBByesm3yYQHlto0/gexOp9b/4bHXlp vgKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=dyzaux5Hm2m2/vssgaRKHtct/IU2h3DNQNym5xCnDZQ=; b=en9cST7JSiTZW4pqXz8tI0W2ri80zrINxxVYjzmY1p4svI9LDMQ5OaAZ3k+UHbLVXn BwIn5v4bgJrIdWxUONUy6op17gb/oFFOoUNqES4FYUmsYKON0sYunfAFynlGrKcRuUwP qZU9JxnCs18ziFq+gtQlYxD4Am59ulvPCpdZC5SE8qkv2GFJ1RXimcg1ybTxxkujjeGh 6s5RNsBwjUi7yqAQSMYqgKpVH9399zXTnlSo6iZypTC/YUF3hZLAEuSwG8dys7+mqlTb isjomXHqWLJH0E55F3IiSrmFZsuvBwVPf/gEk3NnBT82eQ2nnNhrGzXhwGQjW1s4WPeK jX8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f21si2815274ejf.631.2020.11.06.23.03.38; Fri, 06 Nov 2020 23:04:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727801AbgKGHD3 (ORCPT + 99 others); Sat, 7 Nov 2020 02:03:29 -0500 Received: from mga17.intel.com ([192.55.52.151]:45622 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725985AbgKGHD3 (ORCPT ); Sat, 7 Nov 2020 02:03:29 -0500 IronPort-SDR: V/0cWZcYEfSyEEiZaJxycQLTjA4xE/6r2/v2NtNVNC8+8uK6fC3ypirfA9dwvJy9kPPaSEiBSo W1XbW/MRu1bg== X-IronPort-AV: E=McAfee;i="6000,8403,9797"; a="149485514" X-IronPort-AV: E=Sophos;i="5.77,458,1596524400"; d="scan'208";a="149485514" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2020 23:03:29 -0800 IronPort-SDR: sV8pnVHdorLtD3X4e9DyGW0njEJ1xe+gu0dlP1uPpxTlvbEoOdvmBD8AT/Mh6Jc2j4VhwSbKJt TQZmfYQXthFQ== X-IronPort-AV: E=Sophos;i="5.77,458,1596524400"; d="scan'208";a="359032019" Received: from ralassax-mobl.amr.corp.intel.com (HELO ingas-nuc1.intel.com) ([10.209.101.141]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2020 23:03:29 -0800 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: luiz.von.dentz@intel.com, Inga Stotland Subject: [RFC PATCH BlueZ 04/10] tools/sco-tester: Convert to use ELL library Date: Fri, 6 Nov 2020 23:03:06 -0800 Message-Id: <20201107070312.8561-5-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201107070312.8561-1-inga.stotland@intel.com> References: <20201107070312.8561-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This reworks the source code to use ELL primitives and removes dependecies on GLib. --- Makefile.tools | 4 ++-- tools/sco-tester.c | 33 ++++++++++++++------------------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/Makefile.tools b/Makefile.tools index 259427443..15613a5c9 100644 --- a/Makefile.tools +++ b/Makefile.tools @@ -154,12 +154,12 @@ tools_gap_tester_LDADD = lib/libbluetooth-internal.la \ src/libshared-ell.la $(ell_ldadd) tools_sco_tester_SOURCES = tools/sco-tester.c monitor/bt.h \ - emulator/hciemu.h emulator/hciemu.c \ + emulator/hciemu.h emulator/hciemu-ell.c \ emulator/btdev.h emulator/btdev.c \ emulator/bthost.h emulator/bthost.c \ emulator/smp.c tools_sco_tester_LDADD = lib/libbluetooth-internal.la \ - src/libshared-glib.la $(GLIB_LIBS) + src/libshared-ell.la $(ell_ldadd) tools_hci_tester_SOURCES = tools/hci-tester.c monitor/bt.h tools_hci_tester_LDADD = src/libshared-glib.la $(GLIB_LIBS) diff --git a/tools/sco-tester.c b/tools/sco-tester.c index 2b8dc0d4a..c3c43a1c3 100644 --- a/tools/sco-tester.c +++ b/tools/sco-tester.c @@ -17,7 +17,7 @@ #include #include -#include +#include #include "lib/bluetooth.h" #include "lib/sco.h" @@ -36,7 +36,7 @@ struct test_data { uint16_t mgmt_index; struct hciemu *hciemu; enum hciemu_type hciemu_type; - unsigned int io_id; + struct l_io *io; bool disable_esco; }; @@ -196,20 +196,21 @@ static void test_data_free(void *test_data) { struct test_data *data = test_data; - if (data->io_id > 0) - g_source_remove(data->io_id); + if (data->io) { + l_io_destroy(data->io); + data->io = NULL; + } - free(data); + l_free(data); } #define test_sco_full(name, data, setup, func, _disable_esco) \ do { \ struct test_data *user; \ - user = malloc(sizeof(struct test_data)); \ + user = l_new(struct test_data, 1); \ if (!user) \ break; \ user->hciemu_type = HCIEMU_TYPE_BREDRLE; \ - user->io_id = 0; \ user->test_data = data; \ user->disable_esco = _disable_esco; \ tester_add_full(name, data, \ @@ -474,17 +475,14 @@ static int connect_sco_sock(struct test_data *data, int sk) return 0; } -static gboolean sco_connect_cb(GIOChannel *io, GIOCondition cond, - gpointer user_data) +static bool sco_connect_cb(struct l_io *io, void *user_data) { struct test_data *data = tester_get_data(); const struct sco_client_data *scodata = data->test_data; int err, sk_err, sk; socklen_t len = sizeof(sk_err); - data->io_id = 0; - - sk = g_io_channel_unix_get_fd(io); + sk = l_io_get_fd(io); if (getsockopt(sk, SOL_SOCKET, SO_ERROR, &sk_err, &len) < 0) err = -errno; @@ -501,13 +499,12 @@ static gboolean sco_connect_cb(GIOChannel *io, GIOCondition cond, else tester_test_passed(); - return FALSE; + return false; } static void test_connect(const void *test_data) { struct test_data *data = tester_get_data(); - GIOChannel *io; int sk; sk = create_sco_sock(data); @@ -522,12 +519,10 @@ static void test_connect(const void *test_data) return; } - io = g_io_channel_unix_new(sk); - g_io_channel_set_close_on_unref(io, TRUE); - - data->io_id = g_io_add_watch(io, G_IO_OUT, sco_connect_cb, NULL); + data->io = l_io_new(sk); + l_io_set_close_on_destroy(data->io, true); - g_io_channel_unref(io); + l_io_set_write_handler(data->io, sco_connect_cb, NULL, NULL); tester_print("Connect in progress"); } -- 2.26.2