Skip to contentSkip to conversation

shared/util: Rename btd_malloc to util_malloc

PATCH In review Luiz Augusto von Dentz 2 participants 6 messages Jan 6, 2022 – Jan 7, 2022

Subsystems (2)
lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/4 shared/util: Rename btd_malloc to util_malloc

From: Luiz Augusto von Dentz <[email protected]>

util functions are not limited to daemon only which is normally the case when using btd prefix.

---
 profiles/audio/avdtp.c | 2 +-
 src/shared/util.c      | 2 +-
 src/shared/util.h      | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
profiles/audio/avdtp.c +1 -1
index d3dfbf96d..f2b461330 100644
@@ -1333,7 +1333,7 @@ static GSList *caps_to_list(uint8_t *data, size_t size,
 			break;
 		}
 
-		cpy = btd_malloc(sizeof(*cpy) + cap->length);
+		cpy = util_malloc(sizeof(*cpy) + cap->length);
 		memcpy(cpy, cap, sizeof(*cap) + cap->length);
 
 		size -= sizeof(*cap) + cap->length;
src/shared/util.c +1 -1
index 81b20d86f..93110047b 100644
@@ -25,7 +25,7 @@
 
 #include "src/shared/util.h"
 
-void *btd_malloc(size_t size)
+void *util_malloc(size_t size)
 {
 	if (__builtin_expect(!!size, 1)) {
 		void *ptr;
src/shared/util.h +2 -2
index ac70117ca..11d09979d 100644
@@ -75,7 +75,7 @@ do {						\
 		size_t __n = (size_t) (count);	\
 		size_t __s = sizeof(type);	\
 		void *__p;			\
-		__p = btd_malloc(__n * __s);	\
+		__p = util_malloc(__n * __s);	\
 		memset(__p, 0, __n * __s);	\
 		__p;				\
 	}))
@@ -86,7 +86,7 @@ do {						\
 char *strdelimit(char *str, char *del, char c);
 int strsuffix(const char *str, const char *suffix);
 
-void *btd_malloc(size_t size);
+void *util_malloc(size_t size);
 
 typedef void (*util_debug_func_t)(const char *str, void *user_data);
 
Signature · 1 line
2.33.1
author maintainer
#1 lore raw

PATCH 2/4 attrib: Remove gatt-service.{c,h} and attrib-server.{c,h}

From: Luiz Augusto von Dentz <[email protected]>

These files are not longer needed since this functionality has been moved to gatt-db.{c,h}.

---
 Makefile.am           |    4 +-
 attrib/gatt-service.c |  362 ---------
 attrib/gatt-service.h |   44 --
 src/adapter.c         |    5 -
 src/attrib-server.c   | 1656 -----------------------------------------
 src/attrib-server.h   |   29 -
 src/device.c          |    1 -
 7 files changed, 1 insertion(+), 2100 deletions(-)
 delete mode 100644 attrib/gatt-service.c
 delete mode 100644 attrib/gatt-service.h
 delete mode 100644 src/attrib-server.c
 delete mode 100644 src/attrib-server.h
Makefile.am +1 -3
index 308f13c50..a26ba9bc7 100644
@@ -267,8 +267,7 @@ endif
 
 attrib_sources = attrib/att.h attrib/att-database.h attrib/att.c \
 		attrib/gatt.h attrib/gatt.c \
-		attrib/gattrib.h attrib/gattrib.c \
-		attrib/gatt-service.h attrib/gatt-service.c
+		attrib/gattrib.h attrib/gattrib.c
 
 btio_sources = btio/btio.h btio/btio.c
 
@@ -305,7 +304,6 @@ src_bluetoothd_SOURCES = $(builtin_sources) \
 			src/rfkill.c src/btd.h src/sdpd.h \
 			src/sdpd-server.c src/sdpd-request.c \
 			src/sdpd-service.c src/sdpd-database.c \
-			src/attrib-server.h src/attrib-server.c \
 			src/gatt-database.h src/gatt-database.c \
 			src/sdp-xml.h src/sdp-xml.c \
 			src/sdp-client.h src/sdp-client.c \
attrib/gatt-service.c deleted +0 -362

362 lines not on this page · raw message

attrib/gatt-service.h deleted +0 -44

44 lines not on this page · raw message

src/adapter.c +0 -5
index c49f42cfb..9772e843a 100644
@@ -62,7 +62,6 @@
 #include "attrib/gattrib.h"
 #include "attrib/att.h"
 #include "attrib/gatt.h"
-#include "attrib-server.h"
 #include "gatt-database.h"
 #include "advertising.h"
 #include "adv_monitor.h"
@@ -827,10 +826,6 @@ static void local_name_changed_callback(uint16_t index, uint16_t length,
 
 	g_dbus_emit_property_changed(dbus_conn, adapter->path,
 						ADAPTER_INTERFACE, "Alias");
-
-	attrib_gap_set(adapter, GATT_CHARAC_DEVICE_NAME,
-				(const uint8_t *) adapter->current_alias,
-					strlen(adapter->current_alias));
 }
 
 static void set_local_name_complete(uint8_t status, uint16_t length,
src/attrib-server.c deleted +0 -1656

1,656 lines not on this page · raw message

src/attrib-server.h deleted +0 -29
deleted file mode 100644
index 7cdbe3b96..000000000
@@ -1,29 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- *
- *  BlueZ - Bluetooth protocol stack for Linux
- *
- *  Copyright (C) 2010  Nokia Corporation
- *  Copyright (C) 2010  Marcel Holtmann <[email protected]>
- *
- *
- */
-
-uint16_t attrib_db_find_avail(struct btd_adapter *adapter, bt_uuid_t *svc_uuid,
-							uint16_t nitems);
-struct attribute *attrib_db_add(struct btd_adapter *adapter, uint16_t handle,
-				bt_uuid_t *uuid, int read_req,
-				int write_req, const uint8_t *value,
-				size_t len);
-int attrib_db_update(struct btd_adapter *adapter, uint16_t handle,
-					bt_uuid_t *uuid, const uint8_t *value,
-					size_t len, struct attribute **attr);
-int attrib_db_del(struct btd_adapter *adapter, uint16_t handle);
-int attrib_gap_set(struct btd_adapter *adapter, uint16_t uuid,
-					const uint8_t *value, size_t len);
-uint32_t attrib_create_sdp(struct btd_adapter *adapter, uint16_t handle,
-							const char *name);
-void attrib_free_sdp(struct btd_adapter *adapter, uint32_t sdp_handle);
-GAttrib *attrib_from_device(struct btd_device *device);
-guint attrib_channel_attach(GAttrib *attrib);
-gboolean attrib_channel_detach(GAttrib *attrib, guint id);
src/device.c +0 -1
index 982b7979e..f2447c478 100644
@@ -62,7 +62,6 @@
 #include "agent.h"
 #include "textfile.h"
 #include "storage.h"
-#include "attrib-server.h"
 #include "eir.h"
 
 #define DISCONNECT_TIMER	2
Signature · 1 line
2.33.1
author maintainer
#2 lore raw

PATCH 3/4 shared/util: Add util_memdup

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This adds util_memdup which is intended to replace g_memdup since replacing that with g_memdup2 requires bumping the glib version.

---
 src/shared/util.c | 16 ++++++++++++++++
 src/shared/util.h |  1 +
 2 files changed, 17 insertions(+)
src/shared/util.c +16 -0
index 93110047b..6e1c83057 100644
@@ -41,6 +41,22 @@ void *util_malloc(size_t size)
 	return NULL;
 }
 
+void *util_memdup(const void *src, size_t size)
+{
+	void *cpy;
+
+	if (!src || !size)
+		return NULL;
+
+	cpy = util_malloc(size);
+	if (!cpy)
+		return NULL;
+
+	memcpy(cpy, src, size);
+
+	return cpy;
+}
+
 void util_debug_va(util_debug_func_t function, void *user_data,
 				const char *format, va_list va)
 {
src/shared/util.h +1 -0
index 11d09979d..8ef6132c4 100644
@@ -87,6 +87,7 @@ char *strdelimit(char *str, char *del, char c);
 int strsuffix(const char *str, const char *suffix);
 
 void *util_malloc(size_t size);
+void *util_memdup(const void *src, size_t size);
 
 typedef void (*util_debug_func_t)(const char *str, void *user_data);
 
Signature · 1 line
2.33.1
author maintainer
#3 lore raw

PATCH 4/4 build: Replace use of g_memdup with util_memdup

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This replaces the uses of g_memdup with util_memdup since the former has been deprecated:

warning: ‘g_memdup’ is deprecated: Use 'g_memdup2' instead [-Wdeprecated-declarations]

g_memdup2 requires bumping glib version which would likely have its own problems thus why util_memdup was introduced.

---
 Makefile.am                | 10 ++---
 Makefile.obexd             |  1 +
 Makefile.tools             | 11 ++++--
 android/a2dp.c             |  9 +++--
 android/avctp.c            |  5 ++-
 android/avrcp-lib.c        |  2 +-
 android/gatt.c             |  5 ++-
 android/hidhost.c          |  3 +-
 android/tester-main.c      | 77 +++++++++++++++++++++-----------------
 attrib/gatt.c              | 12 +++---
 client/gatt.c              |  2 +-
 gobex/gobex-header.c       |  7 ++--
 gobex/gobex-packet.c       |  5 ++-
 obexd/src/obex.c           |  5 ++-
 plugins/neard.c            |  9 +++--
 plugins/policy.c           |  7 ++--
 profiles/audio/avctp.c     |  9 +++--
 profiles/audio/avrcp.c     | 10 ++---
 profiles/battery/bas.c     |  4 +-
 profiles/battery/battery.c |  4 +-
 profiles/deviceinfo/dis.c  |  4 +-
 profiles/input/hog-lib.c   | 12 +++---
 profiles/scanparam/scpp.c  |  4 +-
 src/eir.c                  |  8 ++--
 tools/gatt-service.c       | 15 ++++----
 tools/mesh-gatt/gatt.c     |  5 ++-
 unit/test-avctp.c          |  4 +-
 unit/test-avdtp.c          |  6 +--
 unit/test-avrcp.c          | 10 ++---
 unit/test-gatt.c           |  4 +-
 unit/test-hfp.c            | 11 +++---
 unit/test-hog.c            | 26 ++++++-------
 unit/test-sdp.c            | 10 +++--
 unit/test-uhid.c           |  2 +-
 34 files changed, 172 insertions(+), 146 deletions(-)
Makefile.am +5 -5
index a26ba9bc7..e391d7ae8 100644
@@ -506,23 +506,23 @@ unit_tests += unit/test-gobex-header unit/test-gobex-packet unit/test-gobex \
 
 unit_test_gobex_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
 						unit/test-gobex.c
-unit_test_gobex_LDADD = $(GLIB_LIBS)
+unit_test_gobex_LDADD = src/libshared-glib.la $(GLIB_LIBS)
 
 unit_test_gobex_packet_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
 						unit/test-gobex-packet.c
-unit_test_gobex_packet_LDADD = $(GLIB_LIBS)
+unit_test_gobex_packet_LDADD = src/libshared-glib.la $(GLIB_LIBS)
 
 unit_test_gobex_header_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
 						unit/test-gobex-header.c
-unit_test_gobex_header_LDADD = $(GLIB_LIBS)
+unit_test_gobex_header_LDADD = src/libshared-glib.la $(GLIB_LIBS)
 
 unit_test_gobex_transfer_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
 						unit/test-gobex-transfer.c
-unit_test_gobex_transfer_LDADD = $(GLIB_LIBS)
+unit_test_gobex_transfer_LDADD = src/libshared-glib.la $(GLIB_LIBS)
 
 unit_test_gobex_apparam_SOURCES = $(gobex_sources) unit/util.c unit/util.h \
 						unit/test-gobex-apparam.c
-unit_test_gobex_apparam_LDADD = $(GLIB_LIBS)
+unit_test_gobex_apparam_LDADD = src/libshared-glib.la $(GLIB_LIBS)
 endif
 
 unit_tests += unit/test-lib
Makefile.obexd +1 -0
index 37a133455..5d1a4ff65 100644
@@ -82,6 +82,7 @@ obexd_src_obexd_SOURCES = $(btio_sources) $(gobex_sources) \
 			obexd/src/map_ap.h
 obexd_src_obexd_LDADD = lib/libbluetooth-internal.la \
 			gdbus/libgdbus-internal.la \
+			src/libshared-glib.la \
 			$(ICAL_LIBS) $(DBUS_LIBS) $(LIBEBOOK_LIBS) \
 			$(LIBEDATASERVER_LIBS) $(GLIB_LIBS) -ldl
 
Makefile.tools +7 -4
index 0f0331b64..51199b20a 100644
@@ -302,7 +302,8 @@ tools_mpris_proxy_SOURCES = tools/mpris-proxy.c
 tools_mpris_proxy_LDADD = gdbus/libgdbus-internal.la $(GLIB_LIBS) $(DBUS_LIBS)
 
 tools_gatt_service_SOURCES = tools/gatt-service.c
-tools_gatt_service_LDADD = $(GLIB_LIBS) $(DBUS_LIBS) gdbus/libgdbus-internal.la
+tools_gatt_service_LDADD = gdbus/libgdbus-internal.la \
+			   src/libshared-mainloop.la $(GLIB_LIBS) $(DBUS_LIBS)
 
 profiles_iap_iapd_SOURCES = profiles/iap/main.c
 profiles_iap_iapd_LDADD = gdbus/libgdbus-internal.la $(GLIB_LIBS) $(DBUS_LIBS)
@@ -448,11 +449,12 @@ noinst_PROGRAMS += tools/btmgmt tools/obex-client-tool tools/obex-server-tool \
 tools_obex_client_tool_SOURCES = $(gobex_sources) $(btio_sources) \
 						tools/obex-client-tool.c
 tools_obex_client_tool_LDADD = lib/libbluetooth-internal.la \
-						$(GLIB_LIBS) -lreadline
+			       src/libshared-glib.la $(GLIB_LIBS) -lreadline
 
 tools_obex_server_tool_SOURCES = $(gobex_sources) $(btio_sources) \
 						tools/obex-server-tool.c
-tools_obex_server_tool_LDADD = lib/libbluetooth-internal.la $(GLIB_LIBS)
+tools_obex_server_tool_LDADD = lib/libbluetooth-internal.la \
+			       src/libshared-glib.la $(GLIB_LIBS)
 
 tools_bluetooth_player_SOURCES = tools/bluetooth-player.c
 tools_bluetooth_player_LDADD = gdbus/libgdbus-internal.la \
@@ -461,7 +463,8 @@ tools_bluetooth_player_LDADD = gdbus/libgdbus-internal.la \
 
 tools_obexctl_SOURCES = tools/obexctl.c
 tools_obexctl_LDADD = gdbus/libgdbus-internal.la src/libshared-glib.la \
-				$(GLIB_LIBS) $(DBUS_LIBS) -lreadline
+			src/libshared-glib.la $(GLIB_LIBS) $(DBUS_LIBS) \
+			-lreadline
 
 tools_btmgmt_SOURCES = tools/btmgmt.c src/uuid-helper.c client/display.c
 tools_btmgmt_LDADD = lib/libbluetooth-internal.la src/libshared-mainloop.la \
android/a2dp.c +5 -4
index 029107cf5..ee607a32d 100644
@@ -26,6 +26,7 @@
 #include "lib/sdp_lib.h"
 #include "profiles/audio/a2dp-codecs.h"
 #include "src/shared/queue.h"
+#include "src/shared/util.h"
 #include "src/log.h"
 #include "hal-msg.h"
 #include "ipc-common.h"
@@ -428,7 +429,7 @@ static struct a2dp_preset *sbc_select_range(void *caps, uint8_t caps_len,
 
 	p = g_new0(struct a2dp_preset, 1);
 	p->len = conf_len;
-	p->data = g_memdup(conf, p->len);
+	p->data = util_memdup(conf, p->len);
 
 	return p;
 }
@@ -448,7 +449,7 @@ static struct a2dp_preset *aac_select_range(void *caps, uint8_t caps_len,
 
 	p = g_new0(struct a2dp_preset, 1);
 	p->len = conf_len;
-	p->data = g_memdup(conf, p->len);
+	p->data = util_memdup(conf, p->len);
 
 	return p;
 }
@@ -1036,7 +1037,7 @@ static gboolean sep_setconf_ind(struct avdtp *session,
 
 		preset = g_new0(struct a2dp_preset, 1);
 		preset->len = cap->length - sizeof(*codec);
-		preset->data = g_memdup(codec->data, preset->len);
+		preset->data = util_memdup(codec->data, preset->len);
 
 		if (check_config(endpoint, preset) < 0) {
 			preset_free(preset);
@@ -1365,7 +1366,7 @@ static GSList *parse_presets(const struct audio_preset *p, uint8_t count,
 
 		preset = g_new0(struct a2dp_preset, 1);
 		preset->len = p->len;
-		preset->data = g_memdup(p->data, preset->len);
+		preset->data = util_memdup(p->data, preset->len);
 		l = g_slist_append(l, preset);
 
 		len -= preset->len;
android/avctp.c +3 -2
index 14ebbc391..37b4cec4f 100644
@@ -31,6 +31,7 @@
 #include <glib.h>
 
 #include "lib/sdp.h"
+#include "src/shared/util.h"
 #include "src/log.h"
 #include "avctp.h"
 
@@ -1177,7 +1178,7 @@ static int avctp_send_req(struct avctp *session, uint8_t code, uint8_t subunit,
 
 	for (i = 0; i < iov_cnt; i++) {
 		pdu[i].iov_len = iov[i].iov_len;
-		pdu[i].iov_base = g_memdup(iov[i].iov_base, iov[i].iov_len);
+		pdu[i].iov_base = util_memdup(iov[i].iov_base, iov[i].iov_len);
 	}
 
 	req = g_new0(struct avctp_control_req, 1);
@@ -1218,7 +1219,7 @@ int avctp_send_browsing_req(struct avctp *session,
 
 	for (i = 0; i < iov_cnt; i++) {
 		pdu[i].iov_len = iov[i].iov_len;
-		pdu[i].iov_base = g_memdup(iov[i].iov_base, iov[i].iov_len);
+		pdu[i].iov_base = util_memdup(iov[i].iov_base, iov[i].iov_len);
 	}
 
 	req = g_new0(struct avctp_browsing_req, 1);
android/avrcp-lib.c +1 -1
index 2007d09d2..b342692cb 100644
@@ -2620,7 +2620,7 @@ static char *parse_folder_list(uint8_t *params, uint16_t params_len,
 			return NULL;
 		}
 
-		folders[count] = g_memdup(&params[i], len);
+		folders[count] = util_memdup(&params[i], len);
 		i += len;
 	}
 
android/gatt.c +3 -2
index a8a0c488b..e8ba5aabb 100644
@@ -1338,7 +1338,8 @@ static void discover_primary_cb(uint8_t status, GSList *services,
 		}
 
 		bt_uuid_to_uuid128(&uuid, &u128);
-		new_uuid = g_memdup(&u128.value.u128, sizeof(u128.value.u128));
+		new_uuid = util_memdup(&u128.value.u128,
+					sizeof(u128.value.u128));
 
 		uuids = g_slist_prepend(uuids, new_uuid);
 	}
@@ -6633,7 +6634,7 @@ static uint8_t write_prep_request(const uint8_t *cmd, uint16_t cmd_len,
 
 	queue_push_tail(dev->pending_requests, data);
 
-	data->value = g_memdup(value, vlen);
+	data->value = util_memdup(value, vlen);
 	data->length = vlen;
 
 	if (!gatt_db_attribute_write(attrib, offset, value, vlen, cmd[0],
android/hidhost.c +2 -1
index 016382e17..b4e5c527f 100644
@@ -689,7 +689,8 @@ static void hid_sdp_search_cb(sdp_list_t *recs, int err, gpointer data)
 				goto fail;
 
 			dev->rd_size = data->unitSize;
-			dev->rd_data = g_memdup(data->val.str, data->unitSize);
+			dev->rd_data = util_memdup(data->val.str,
+							data->unitSize);
 		}
 	}
 
android/tester-main.c +42 -35

224 lines not on this page · raw message

attrib/gatt.c +6 -6
index 46b2ca381..b496dd1eb 100644
@@ -135,7 +135,7 @@ static void discover_char_unref(void *data)
 
 	g_slist_free_full(dc->characteristics, g_free);
 	g_attrib_unref(dc->attrib);
-	g_free(dc->uuid);
+	free(dc->uuid);
 	g_free(dc);
 }
 
@@ -157,7 +157,7 @@ static void discover_desc_unref(void *data)
 
 	g_slist_free_full(dd->descriptors, g_free);
 	g_attrib_unref(dd->attrib);
-	g_free(dd->uuid);
+	free(dd->uuid);
 	g_free(dd);
 }
 
@@ -696,7 +696,7 @@ guint gatt_discover_char(GAttrib *attrib, uint16_t start, uint16_t end,
 	dc->user_data = user_data;
 	dc->end = end;
 	dc->start = start;
-	dc->uuid = g_memdup(uuid, sizeof(bt_uuid_t));
+	dc->uuid = util_memdup(uuid, sizeof(bt_uuid_t));
 
 	dc->id = g_attrib_send(attrib, 0, buf, plen, char_discovered_cb,
 				discover_char_ref(dc), discover_char_unref);
@@ -905,7 +905,7 @@ static void prepare_write_cb(guint8 status, const guint8 *rpdu, guint16 rlen,
 	if (long_write->offset == long_write->vlen) {
 		execute_write(long_write->attrib, ATT_WRITE_ALL_PREP_WRITES,
 				long_write->func, long_write->user_data);
-		g_free(long_write->value);
+		free(long_write->value);
 		g_free(long_write);
 
 		return;
@@ -964,7 +964,7 @@ guint gatt_write_char(GAttrib *attrib, uint16_t handle, const uint8_t *value,
 	long_write->func = func;
 	long_write->user_data = user_data;
 	long_write->handle = handle;
-	long_write->value = g_memdup(value, vlen);
+	long_write->value = util_memdup(value, vlen);
 	long_write->vlen = vlen;
 
 	return prepare_write(long_write);
@@ -1130,7 +1130,7 @@ guint gatt_discover_desc(GAttrib *attrib, uint16_t start, uint16_t end,
 	dd->user_data = user_data;
 	dd->start = start;
 	dd->end = end;
-	dd->uuid = g_memdup(uuid, sizeof(bt_uuid_t));
+	dd->uuid = util_memdup(uuid, sizeof(bt_uuid_t));
 
 	dd->id = g_attrib_send(attrib, 0, buf, plen, desc_discovered_cb,
 				discover_desc_ref(dd), discover_desc_unref);
client/gatt.c +1 -1
index 11f70dc4f..13872c794 100644
@@ -811,7 +811,7 @@ static uint8_t *str2bytearray(char *arg, size_t *val_len)
 
 	*val_len = i;
 
-	return g_memdup(value, i);
+	return util_memdup(value, i);
 }
 
 void gatt_write_attribute(GDBusProxy *proxy, int argc, char *argv[])
gobex/gobex-header.c +4 -3
index 011d33d1a..002ba8861 100644
@@ -15,6 +15,7 @@
 
 #include "gobex-header.h"
 #include "gobex-debug.h"
+#include "src/shared/util.h"
 
 /* Header types */
 #define G_OBEX_HDR_ENC_UNICODE	(0 << 6)
@@ -222,7 +223,7 @@ GObexHeader *g_obex_header_decode(const void *data, gsize len,
 
 		switch (data_policy) {
 		case G_OBEX_DATA_COPY:
-			header->v.data = g_memdup(ptr, header->vlen);
+			header->v.data = util_memdup(ptr, header->vlen);
 			break;
 		case G_OBEX_DATA_REF:
 			header->extdata = TRUE;
@@ -282,7 +283,7 @@ void g_obex_header_free(GObexHeader *header)
 		break;
 	case G_OBEX_HDR_ENC_BYTES:
 		if (!header->extdata)
-			g_free(header->v.data);
+			free(header->v.data);
 		break;
 	case G_OBEX_HDR_ENC_UINT8:
 	case G_OBEX_HDR_ENC_UINT32:
@@ -410,7 +411,7 @@ GObexHeader *g_obex_header_new_bytes(guint8 id, const void *data, gsize len)
 	header->id = id;
 	header->vlen = len;
 	header->hlen = len + 3;
-	header->v.data = g_memdup(data, len);
+	header->v.data = util_memdup(data, len);
 
 	return header;
 }
gobex/gobex-packet.c +3 -2
index 11937a5a5..8ae78b0f6 100644
@@ -17,6 +17,7 @@
 #include "gobex-defs.h"
 #include "gobex-packet.h"
 #include "gobex-debug.h"
+#include "src/shared/util.h"
 
 #define FINAL_BIT 0x80
 
@@ -201,7 +202,7 @@ gboolean g_obex_packet_set_data(GObexPacket *pkt, const void *data, gsize len,
 
 	switch (data_policy) {
 	case G_OBEX_DATA_COPY:
-		pkt->data.buf = g_memdup(data, len);
+		pkt->data.buf = util_memdup(data, len);
 		break;
 	case G_OBEX_DATA_REF:
 		pkt->data.buf_ref = data;
@@ -259,7 +260,7 @@ void g_obex_packet_free(GObexPacket *pkt)
 	switch (pkt->data_policy) {
 	case G_OBEX_DATA_INHERIT:
 	case G_OBEX_DATA_COPY:
-		g_free(pkt->data.buf);
+		free(pkt->data.buf);
 		break;
 	case G_OBEX_DATA_REF:
 		break;
obexd/src/obex.c +3 -2
index 9f992ec18..3a68fd66c 100644
@@ -40,6 +40,7 @@
 #include "mimetype.h"
 #include "service.h"
 #include "transport.h"
+#include "src/shared/util.h"
 
 typedef struct {
 	uint8_t  version;
@@ -145,7 +146,7 @@ static void os_reset_session(struct obex_session *os)
 		os->path = NULL;
 	}
 	if (os->apparam) {
-		g_free(os->apparam);
+		free(os->apparam);
 		os->apparam = NULL;
 		os->apparam_len = 0;
 	}
@@ -594,7 +595,7 @@ static void parse_apparam(struct obex_session *os, GObexPacket *req)
 	if (!g_obex_header_get_bytes(hdr, &apparam, &len))
 		return;
 
-	os->apparam = g_memdup(apparam, len);
+	os->apparam = util_memdup(apparam, len);
 	os->apparam_len = len;
 	DBG("APPARAM");
 }
plugins/neard.c +5 -4
index e07b51106..a75527148 100644
@@ -30,6 +30,7 @@
 #include "src/eir.h"
 #include "src/agent.h"
 #include "src/btd.h"
+#include "src/shared/util.h"
 
 #define NEARD_NAME "org.neard"
 #define NEARD_PATH "/"
@@ -71,7 +72,7 @@ static void free_oob_params(struct oob_params *params)
 	g_free(params->name);
 	g_free(params->hash);
 	g_free(params->randomizer);
-	g_free(params->pin);
+	free(params->pin);
 }
 
 static DBusMessage *error_reply(DBusMessage *msg, int error)
@@ -407,10 +408,10 @@ static int process_nokia_long (void *data, size_t size, uint8_t marker,
 		remote->name = g_strndup((char *)n->name, n->name_len);
 
 	if (marker == 0x01) {
-		remote->pin = g_memdup(n->authentication, 4);
+		remote->pin = util_memdup(n->authentication, 4);
 		remote->pin_len = 4;
 	} else if (marker == 0x02) {
-		remote->pin = g_memdup(n->authentication, 16);
+		remote->pin = util_memdup(n->authentication, 16);
 		remote->pin_len = 16;
 	}
 
@@ -439,7 +440,7 @@ static int process_nokia_short (void *data, size_t size,
 	if (n->name_len > 0)
 		remote->name = g_strndup((char *)n->name, n->name_len);
 
-	remote->pin = g_memdup(n->authentication, 4);
+	remote->pin = util_memdup(n->authentication, 4);
 	remote->pin_len = 4;
 
 	return 0;
plugins/policy.c +4 -3
index 051db82e1..48f5db7d3 100644
@@ -32,6 +32,7 @@
 #include "src/profile.h"
 #include "src/btd.h"
 #include "src/shared/timeout.h"
+#include "src/shared/util.h"
 
 #define CONTROL_CONNECT_TIMEOUT 2
 #define SOURCE_RETRY_TIMEOUT 2
@@ -855,7 +856,7 @@ static int policy_init(void)
 		reconnect_attempts = default_attempts;
 		reconnect_intervals_len = sizeof(default_intervals) /
 						sizeof(*reconnect_intervals);
-		reconnect_intervals = g_memdup(default_intervals,
+		reconnect_intervals = util_memdup(default_intervals,
 						sizeof(default_intervals));
 		goto done;
 	}
@@ -886,7 +887,7 @@ static int policy_init(void)
 		g_clear_error(&gerr);
 		reconnect_intervals_len = sizeof(default_intervals) /
 						sizeof(*reconnect_intervals);
-		reconnect_intervals = g_memdup(default_intervals,
+		reconnect_intervals = util_memdup(default_intervals,
 						sizeof(default_intervals));
 	}
 
@@ -919,7 +920,7 @@ static void policy_exit(void)
 	if (reconnect_uuids)
 		g_strfreev(reconnect_uuids);
 
-	g_free(reconnect_intervals);
+	free(reconnect_intervals);
 
 	g_slist_free_full(reconnects, reconnect_destroy);
 
profiles/audio/avctp.c +5 -4
index 64d1a8504..6f64f162b 100644
@@ -40,6 +40,7 @@
 #include "src/log.h"
 #include "src/error.h"
 #include "src/shared/timeout.h"
+#include "src/shared/util.h"
 
 #include "avctp.h"
 #include "avrcp.h"
@@ -760,7 +761,7 @@ static void control_req_destroy(void *data)
 						NULL, 0, req->user_data);
 
 done:
-	g_free(req->operands);
+	free(req->operands);
 	g_free(req);
 }
 
@@ -776,7 +777,7 @@ static void browsing_req_destroy(void *data)
 	req->func(session, NULL, 0, req->user_data);
 
 done:
-	g_free(req->operands);
+	free(req->operands);
 	g_free(req);
 }
 
@@ -1727,7 +1728,7 @@ static int avctp_send_req(struct avctp *session, uint8_t code,
 	req->subunit = subunit;
 	req->op = opcode;
 	req->func = func;
-	req->operands = g_memdup(operands, operand_count);
+	req->operands = util_memdup(operands, operand_count);
 	req->operand_count = operand_count;
 	req->user_data = user_data;
 
@@ -1765,7 +1766,7 @@ int avctp_send_browsing_req(struct avctp *session,
 
 	req = g_new0(struct avctp_browsing_req, 1);
 	req->func = func;
-	req->operands = g_memdup(operands, operand_count);
+	req->operands = util_memdup(operands, operand_count);
 	req->operand_count = operand_count;
 	req->user_data = user_data;
 
profiles/audio/avrcp.c +5 -5
index 7c280203c..d4e19ffc0 100644
@@ -1298,7 +1298,7 @@ static uint8_t avrcp_handle_get_current_player_value(struct avrcp *session,
 	 * Save a copy of requested settings because we can override them
 	 * while responding
 	 */
-	settings = g_memdup(&pdu->params[1], pdu->params[0]);
+	settings = util_memdup(&pdu->params[1], pdu->params[0]);
 	len = 0;
 
 	/*
@@ -1323,7 +1323,7 @@ static uint8_t avrcp_handle_get_current_player_value(struct avrcp *session,
 		pdu->params[++len] = val;
 	}
 
-	g_free(settings);
+	free(settings);
 
 	if (len) {
 		pdu->params[0] = len / 2;
@@ -2801,7 +2801,7 @@ static gboolean avrcp_set_browsed_player_rsp(struct avctp *conn,
 			break;
 		}
 
-		folders[count] = g_memdup(&pdu->params[i], len);
+		folders[count] = util_memdup(&pdu->params[i], len);
 		i += len;
 	}
 
@@ -2888,7 +2888,7 @@ static void avrcp_player_parse_features(struct avrcp_player *player,
 {
 	struct media_player *mp = player->user_data;
 
-	player->features = g_memdup(features, 16);
+	player->features = util_memdup(features, 16);
 
 	if (features[7] & 0x08) {
 		media_player_set_browsable(mp, true);
@@ -3622,7 +3622,7 @@ static void player_destroy(gpointer data)
 	g_slist_free(player->sessions);
 	g_free(player->path);
 	g_free(player->change_path);
-	g_free(player->features);
+	free(player->features);
 	g_free(player);
 }
 
profiles/battery/bas.c +2 -2
index 3c6173b61..16ff22e19 100644
@@ -62,7 +62,7 @@ static void bas_free(struct bt_bas *bas)
 {
 	bt_bas_detach(bas);
 
-	g_free(bas->primary);
+	free(bas->primary);
 	queue_destroy(bas->gatt_op, (void *) destroy_gatt_req);
 	free(bas);
 }
@@ -75,7 +75,7 @@ struct bt_bas *bt_bas_new(void *primary)
 	bas->gatt_op = queue_new();
 
 	if (primary)
-		bas->primary = g_memdup(primary, sizeof(*bas->primary));
+		bas->primary = util_memdup(primary, sizeof(*bas->primary));
 
 	return bt_bas_ref(bas);
 }
profiles/battery/battery.c +2 -2
index 176d127f6..02d024d92 100644
@@ -66,7 +66,7 @@ static void batt_free(struct batt *batt)
 	gatt_db_unref(batt->db);
 	bt_gatt_client_unref(batt->client);
 	btd_device_unref(batt->device);
-	g_free (batt->initial_value);
+	free(batt->initial_value);
 	if (batt->battery)
 		btd_battery_unregister(batt->battery);
 	g_free(batt);
@@ -159,7 +159,7 @@ static void read_initial_battery_level_cb(bool success,
 	if (!length)
 		return;
 
-	batt->initial_value = g_memdup(value, length);
+	batt->initial_value = util_memdup(value, length);
 
 	/* request notify */
 	batt->batt_level_cb_id =
profiles/deviceinfo/dis.c +2 -2
index 87fa63306..f660179ed 100644
@@ -72,7 +72,7 @@ static void dis_free(struct bt_dis *dis)
 {
 	bt_dis_detach(dis);
 
-	g_free(dis->primary);
+	free(dis->primary);
 	queue_destroy(dis->gatt_op, (void *) destroy_gatt_req);
 	g_free(dis);
 }
@@ -143,7 +143,7 @@ struct bt_dis *bt_dis_new_primary(void *primary)
 	dis->gatt_op = queue_new();
 
 	if (primary)
-		dis->primary = g_memdup(primary, sizeof(*dis->primary));
+		dis->primary = util_memdup(primary, sizeof(*dis->primary));
 
 	return bt_dis_ref(dis);
 }
profiles/input/hog-lib.c +6 -6
index 3bbe42370..d37caa1f1 100644
@@ -527,9 +527,9 @@ static void report_read_cb(guint8 status, const guint8 *pdu, guint16 len,
 	}
 
 	if (report->value)
-		g_free(report->value);
+		free(report->value);
 
-	report->value = g_memdup(pdu, len);
+	report->value = util_memdup(pdu, len);
 	report->len = len;
 }
 
@@ -1217,7 +1217,7 @@ static void report_free(void *data)
 {
 	struct report *report = data;
 
-	g_free(report->value);
+	free(report->value);
 	g_free(report);
 }
 
@@ -1241,7 +1241,7 @@ static void hog_free(void *data)
 	bt_uhid_unref(hog->uhid);
 	g_slist_free_full(hog->reports, report_free);
 	g_free(hog->name);
-	g_free(hog->primary);
+	free(hog->primary);
 	queue_destroy(hog->gatt_op, (void *) destroy_gatt_req);
 	if (hog->gatt_db)
 		gatt_db_unref(hog->gatt_db);
@@ -1609,7 +1609,7 @@ static void hog_attach_hog(struct bt_hog *hog, struct gatt_primary *primary)
 	struct bt_hog *instance;
 
 	if (!hog->primary) {
-		hog->primary = g_memdup(primary, sizeof(*primary));
+		hog->primary = util_memdup(primary, sizeof(*primary));
 		discover_char(hog, hog->attrib, primary->range.start,
 						primary->range.end, NULL,
 						char_discovered_cb, hog);
@@ -1623,7 +1623,7 @@ static void hog_attach_hog(struct bt_hog *hog, struct gatt_primary *primary)
 	if (!instance)
 		return;
 
-	instance->primary = g_memdup(primary, sizeof(*primary));
+	instance->primary = util_memdup(primary, sizeof(*primary));
 	find_included(instance, hog->attrib, primary->range.start,
 			primary->range.end, find_included_cb, instance);
 
profiles/scanparam/scpp.c +2 -2
index da38a6aaa..4be8b26cc 100644
@@ -91,7 +91,7 @@ static void scpp_free(struct bt_scpp *scan)
 {
 	bt_scpp_detach(scan);
 
-	g_free(scan->primary);
+	free(scan->primary);
 	queue_destroy(scan->gatt_op, NULL); /* cleared in bt_scpp_detach */
 	g_free(scan);
 }
@@ -110,7 +110,7 @@ struct bt_scpp *bt_scpp_new(void *primary)
 	scan->gatt_op = queue_new();
 
 	if (primary)
-		scan->primary = g_memdup(primary, sizeof(*scan->primary));
+		scan->primary = util_memdup(primary, sizeof(*scan->primary));
 
 	return bt_scpp_ref(scan);
 }
src/eir.c +4 -4
index 0f5d14fcd..2f9ee036f 100644
@@ -53,9 +53,9 @@ void eir_data_free(struct eir_data *eir)
 	eir->services = NULL;
 	g_free(eir->name);
 	eir->name = NULL;
-	g_free(eir->hash);
+	free(eir->hash);
 	eir->hash = NULL;
-	g_free(eir->randomizer);
+	free(eir->randomizer);
 	eir->randomizer = NULL;
 	g_slist_free_full(eir->msd_list, g_free);
 	eir->msd_list = NULL;
@@ -323,13 +323,13 @@ void eir_parse(struct eir_data *eir, const uint8_t *eir_data, uint8_t eir_len)
 		case EIR_SSP_HASH:
 			if (data_len < 16)
 				break;
-			eir->hash = g_memdup(data, 16);
+			eir->hash = util_memdup(data, 16);
 			break;
 
 		case EIR_SSP_RANDOMIZER:
 			if (data_len < 16)
 				break;
-			eir->randomizer = g_memdup(data, 16);
+			eir->randomizer = util_memdup(data, 16);
 			break;
 
 		case EIR_DEVICE_ID:
tools/gatt-service.c +8 -7
index 631c4f249..ed6b06f1e 100644
@@ -26,6 +26,7 @@
 #include "gdbus/gdbus.h"
 
 #include "src/error.h"
+#include "src/shared/util.h"
 
 #define GATT_MGR_IFACE			"org.bluez.GattManager1"
 #define GATT_SERVICE_IFACE		"org.bluez.GattService1"
@@ -126,8 +127,8 @@ static gboolean desc_get_value(const GDBusPropertyTable *property,
 
 static void desc_write(struct descriptor *desc, const uint8_t *value, int len)
 {
-	g_free(desc->value);
-	desc->value = g_memdup(value, len);
+	free(desc->value);
+	desc->value = util_memdup(value, len);
 	desc->vlen = len;
 
 	g_dbus_emit_property_changed(connection, desc->path,
@@ -264,8 +265,8 @@ static gboolean chr_get_props(const GDBusPropertyTable *property,
 
 static void chr_write(struct characteristic *chr, const uint8_t *value, int len)
 {
-	g_free(chr->value);
-	chr->value = g_memdup(value, len);
+	free(chr->value);
+	chr->value = util_memdup(value, len);
 	chr->vlen = len;
 
 	g_dbus_emit_property_changed(connection, chr->path, GATT_CHR_IFACE,
@@ -388,7 +389,7 @@ static void chr_iface_destroy(gpointer user_data)
 
 	g_free(chr->uuid);
 	g_free(chr->service);
-	g_free(chr->value);
+	free(chr->value);
 	g_free(chr->path);
 	g_free(chr);
 }
@@ -398,7 +399,7 @@ static void desc_iface_destroy(gpointer user_data)
 	struct descriptor *desc = user_data;
 
 	g_free(desc->uuid);
-	g_free(desc->value);
+	free(desc->value);
 	g_free(desc->path);
 	g_free(desc);
 }
@@ -592,7 +593,7 @@ static gboolean register_characteristic(const char *chr_uuid,
 
 	chr = g_new0(struct characteristic, 1);
 	chr->uuid = g_strdup(chr_uuid);
-	chr->value = g_memdup(value, vlen);
+	chr->value = util_memdup(value, vlen);
 	chr->vlen = vlen;
 	chr->props = props;
 	chr->service = g_strdup(service_path);
tools/mesh-gatt/gatt.c +3 -2
index c8a8123fb..ab9743cd1 100644
@@ -24,6 +24,7 @@
 
 #include "src/shared/io.h"
 #include "src/shared/shell.h"
+#include "src/shared/util.h"
 #include "gdbus/gdbus.h"
 #include "lib/bluetooth.h"
 #include "lib/uuid.h"
@@ -86,7 +87,7 @@ static void write_data_free(void *user_data)
 {
 	struct write_data *data = user_data;
 
-	g_free(data->gatt_data);
+	free(data->gatt_data);
 	free(data);
 }
 
@@ -338,7 +339,7 @@ bool mesh_gatt_write(GDBusProxy *proxy, uint8_t *buf, uint16_t len,
 	/* TODO: should keep in queue in case we need to cancel write? */
 
 	data->gatt_len = len;
-	data->gatt_data = g_memdup(buf, len);
+	data->gatt_data = util_memdup(buf, len);
 	data->gatt_data[0] &= GATT_TYPE_MASK;
 	data->iov.iov_base = data->gatt_data;
 	data->iov.iov_len = len;
unit/test-avctp.c +2 -2
index fa7db59c8..25fd3abc2 100644
@@ -53,7 +53,7 @@ struct context {
 #define raw_pdu(args...)					\
 	{							\
 		.valid = true,					\
-		.data = g_memdup(data(args), sizeof(data(args))), \
+		.data = util_memdup(data(args), sizeof(data(args))), \
 		.size = sizeof(data(args)),			\
 	}
 
@@ -64,7 +64,7 @@ struct context {
 		};							\
 		static struct test_data data;				\
 		data.test_name = g_strdup(name);			\
-		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
+		data.pdu_list = util_memdup(pdus, sizeof(pdus));	\
 		tester_add(name, &data, NULL, function, NULL);		\
 	} while (0)
 
unit/test-avdtp.c +3 -3
index 4e8a68c6b..2e49def43 100644
@@ -48,7 +48,7 @@ struct test_data {
 #define raw_pdu(args...) \
 	{							\
 		.valid = true,					\
-		.data = g_memdup(data(args), sizeof(data(args))), \
+		.data = util_memdup(data(args), sizeof(data(args))), \
 		.size = sizeof(data(args)),			\
 	}
 
@@ -56,7 +56,7 @@ struct test_data {
 	{							\
 		.valid = true,					\
 		.fragmented = true,				\
-		.data = g_memdup(data(args), sizeof(data(args))), \
+		.data = util_memdup(data(args), sizeof(data(args))), \
 		.size = sizeof(data(args)),			\
 	}
 
@@ -67,7 +67,7 @@ struct test_data {
 		};							\
 		static struct test_data data;				\
 		data.test_name = g_strdup(name);			\
-		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
+		data.pdu_list = util_memdup(pdus, sizeof(pdus));	\
 		tester_add(name, &data, NULL, function, NULL);	\
 	} while (0)
 
unit/test-avrcp.c +5 -5
index 34a70377d..b637a8a1b 100644
@@ -61,7 +61,7 @@ struct context {
 #define raw_pdu(args...)					\
 	{							\
 		.valid = true,					\
-		.data = g_memdup(data(args), sizeof(data(args))), \
+		.data = util_memdup(data(args), sizeof(data(args))), \
 		.size = sizeof(data(args)),			\
 	}
 
@@ -69,7 +69,7 @@ struct context {
 	{							\
 		.valid = true,					\
 		.browse = true,					\
-		.data = g_memdup(data(args), sizeof(data(args))), \
+		.data = util_memdup(data(args), sizeof(data(args))), \
 		.size = sizeof(data(args)),			\
 	}
 
@@ -77,7 +77,7 @@ struct context {
 	{							\
 		.valid = true,					\
 		.fragmented = true,				\
-		.data = g_memdup(data(args), sizeof(data(args))), \
+		.data = util_memdup(data(args), sizeof(data(args))), \
 		.size = sizeof(data(args)),			\
 	}
 
@@ -85,7 +85,7 @@ struct context {
 	{							\
 		.valid = true,					\
 		.continuing = true,				\
-		.data = g_memdup(data(args), sizeof(data(args))), \
+		.data = util_memdup(data(args), sizeof(data(args))), \
 		.size = sizeof(data(args)),			\
 	}
 
@@ -96,7 +96,7 @@ struct context {
 		};							\
 		static struct test_data data;				\
 		data.test_name = g_strdup(name);			\
-		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
+		data.pdu_list = util_memdup(pdus, sizeof(pdus));	\
 		tester_add(name, &data, NULL, function, NULL);		\
 	} while (0)
 
unit/test-gatt.c +2 -2
index 6a47268e6..f92d860c4 100644
@@ -73,7 +73,7 @@ struct context {
 #define raw_pdu(args...)					\
 	{							\
 		.valid = true,					\
-		.data = g_memdup(data(args), sizeof(data(args))), \
+		.data = util_memdup(data(args), sizeof(data(args))), \
 		.size = sizeof(data(args)),			\
 	}
 
@@ -94,7 +94,7 @@ struct context {
 		data.uuid = bt_uuid;					\
 		data.step = test_step;					\
 		data.source_db = db;					\
-		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
+		data.pdu_list = util_memdup(pdus, sizeof(pdus));	\
 		tester_add(name, &data, NULL, function, NULL);		\
 	} while (0)
 
unit/test-hfp.c +6 -5
index f504724d7..b4af99d53 100644
@@ -17,6 +17,7 @@
 #include <glib.h>
 #include "src/shared/hfp.h"
 #include "src/shared/tester.h"
+#include "src/shared/util.h"
 
 struct context {
 	guint watch_id;
@@ -50,7 +51,7 @@ struct test_data {
 #define raw_pdu(args...)					\
 	{							\
 		.valid = true,					\
-		.data = g_memdup(data(args), sizeof(data(args))), \
+		.data = util_memdup(data(args), sizeof(data(args))), \
 		.size = sizeof(data(args)),			\
 	}
 
@@ -62,7 +63,7 @@ struct test_data {
 #define type_pdu(cmd_type, args...)				\
 	{							\
 		.valid = true,					\
-		.data = g_memdup(data(args), sizeof(data(args))), \
+		.data = util_memdup(data(args), sizeof(data(args))), \
 		.size = sizeof(data(args)),			\
 		.type = cmd_type,				\
 	}
@@ -70,7 +71,7 @@ struct test_data {
 #define frg_pdu(args...)					\
 	{							\
 		.valid = true,					\
-		.data = g_memdup(data(args), sizeof(data(args))), \
+		.data = util_memdup(data(args), sizeof(data(args))), \
 		.size = sizeof(data(args)),			\
 		.fragmented = true,				\
 	}
@@ -82,7 +83,7 @@ struct test_data {
 		};							\
 		static struct test_data data;				\
 		data.test_name = g_strdup(name);			\
-		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
+		data.pdu_list = util_memdup(pdus, sizeof(pdus));	\
 		data.result_func = result_function;			\
 		tester_add(name, &data, NULL, function, NULL);		\
 		data.test_handler = test_handler;			\
@@ -96,7 +97,7 @@ struct test_data {
 		};							\
 		static struct test_data data;				\
 		data.test_name = g_strdup(name);			\
-		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
+		data.pdu_list = util_memdup(pdus, sizeof(pdus));	\
 		data.hf_result_func = result_func;			\
 		data.response_func = response_function;			\
 		tester_add(name, &data, NULL, function, NULL);		\
unit/test-hog.c +13 -13
index 116a5cb07..067497de4 100644
@@ -59,24 +59,24 @@ struct context {
 #define raw_pdu(args...)					\
 {								\
 	.valid = true,						\
-	.data = g_memdup(data(args), sizeof(data(args))),	\
+	.data = util_memdup(data(args), sizeof(data(args))),	\
 	.size = sizeof(data(args)),				\
 }
 
-#define false_pdu()	\
-{						\
-		.valid = false, \
+#define false_pdu()						\
+{								\
+		.valid = false,					\
 }
 
-#define define_test(name, function, args...)      \
-	do {    \
-		const struct test_pdu pdus[] = {			\
-			args, { }					\
-		};		\
-		static struct test_data data;      \
-		data.test_name = g_strdup(name);   \
-		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
-		tester_add(name, &data, NULL, function, NULL);     \
+#define define_test(name, function, args...)			\
+	do {							\
+		const struct test_pdu pdus[] = {		\
+			args, { }				\
+		};						\
+		static struct test_data data;			\
+		data.test_name = g_strdup(name);		\
+		data.pdu_list = util_memdup(pdus, sizeof(pdus));\
+		tester_add(name, &data, NULL, function, NULL);	\
 	} while (0)
 
 static gboolean context_quit(gpointer user_data)
unit/test-sdp.c +6 -4
index 8f95fcb71..5c04a71eb 100644
@@ -47,14 +47,16 @@ struct test_data {
 #define raw_pdu(args...) \
 	{							\
 		.valid = true,					\
-		.raw_data = g_memdup(raw_data(args), sizeof(raw_data(args))), \
+		.raw_data = util_memdup(raw_data(args),		\
+					sizeof(raw_data(args))), \
 		.raw_size = sizeof(raw_data(args)),		\
 	}
 
 #define raw_pdu_cont(cont, args...) \
 	{							\
 		.valid = true,					\
-		.raw_data = g_memdup(raw_data(args), sizeof(raw_data(args))), \
+		.raw_data = util_memdup(raw_data(args),		\
+					sizeof(raw_data(args))), \
 		.raw_size = sizeof(raw_data(args)),		\
 		.cont_len = cont,				\
 	}
@@ -66,7 +68,7 @@ struct test_data {
 		};							\
 		static struct test_data data;				\
 		data.mtu = _mtu;					\
-		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
+		data.pdu_list = util_memdup(pdus, sizeof(pdus));	\
 		tester_add(name, &data, NULL, test_sdp, NULL);		\
 	} while (0)
 
@@ -92,7 +94,7 @@ struct test_data_de {
 #define define_test_de_attr(name, input, exp) \
 	do {								\
 		static struct test_data_de data;			\
-		data.input_data = g_memdup(input, sizeof(input));	\
+		data.input_data = util_memdup(input, sizeof(input));	\
 		data.input_size = sizeof(input);			\
 		data.expected = exp;					\
 		tester_add("/sdp/DE/ATTR/" name, &data,	NULL,		\
unit/test-uhid.c +1 -1
index 001d39a3d..8a8eef855 100644
@@ -61,7 +61,7 @@ struct context {
 		};							\
 		static struct test_data data;				\
 		data.test_name = g_strdup(name);			\
-		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
+		data.pdu_list = util_memdup(pdus, sizeof(pdus));	\
 		tester_add(name, &data, NULL, function, NULL);		\
 	} while (0)
 
Signature · 1 line
2.33.1
#4 lore raw
In reply to Luiz Augusto von Dentz

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=603319

---Test result---

Test Summary:

CheckPatch                    PASS      2.96 seconds
GitLint                       PASS      1.42 seconds
Prep - Setup ELL              PASS      44.08 seconds
Build - Prep                  PASS      0.55 seconds
Build - Configure             PASS      9.53 seconds
Build - Make                  PASS      1586.93 seconds
Make Check                    PASS      10.98 seconds
Make Check w/Valgrind         PASS      454.25 seconds
Make Distcheck                PASS      242.18 seconds
Build w/ext ELL - Configure   PASS      9.33 seconds
Build w/ext ELL - Make        PASS      1548.57 seconds
Incremental Build with patchesPASS      6454.71 seconds

---
Regards,
Linux Bluetooth

author maintainer
#5 lore raw

Hi,

Quoted 27 lines · On Thu, Jan 6, 2022 at 4:16 PM <[email protected]> wrote:

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=603319

---Test result---

Test Summary:

CheckPatch                    PASS      2.96 seconds
GitLint                       PASS      1.42 seconds
Prep - Setup ELL              PASS      44.08 seconds
Build - Prep                  PASS      0.55 seconds
Build - Configure             PASS      9.53 seconds
Build - Make                  PASS      1586.93 seconds
Make Check                    PASS      10.98 seconds
Make Check w/Valgrind         PASS      454.25 seconds
Make Distcheck                PASS      242.18 seconds
Build w/ext ELL - Configure   PASS      9.33 seconds
Build w/ext ELL - Make        PASS      1548.57 seconds
Incremental Build with patchesPASS      6454.71 seconds
Quoted 3 lines

---
Regards,
Linux Bluetooth

Pushed.

Signature · 1 line
Luiz Augusto von Dentz