From 9b98a6c7646bc0404c602ca0b5383aec4b996455 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 18 Oct 2011 10:57:06 +0300 Subject: [PATCH] Add glib-compat.h to deal with issues in old GLib versions --- Makefile.am | 2 +- attrib/client.c | 2 +- attrib/gatt.c | 2 +- audio/a2dp.c | 2 +- audio/avdtp.c | 2 +- audio/gateway.c | 1 + audio/headset.c | 1 + audio/telephony-maemo6.c | 2 +- audio/telephony-ofono.c | 2 +- audio/unix.c | 2 +- network/connection.c | 2 +- network/server.c | 2 +- plugins/hciops.c | 2 +- serial/port.c | 1 + src/adapter.c | 1 + src/attrib-server.c | 2 +- src/device.c | 1 + src/eir.c | 1 + src/glib-compat.h | 30 ++++++++++++++++++++++++++++++ src/glib-helper.c | 1 + src/glib-helper.h | 8 -------- src/storage.c | 1 + 22 files changed, 50 insertions(+), 20 deletions(-) create mode 100644 src/glib-compat.h diff --git a/Makefile.am b/Makefile.am index a63c469c5..eec458e47 100644 --- a/Makefile.am +++ b/Makefile.am @@ -301,7 +301,7 @@ src_bluetoothd_SOURCES = $(gdbus_sources) $(builtin_sources) \ src/sdpd-service.c src/sdpd-database.c \ src/attrib-server.h src/attrib-server.c \ src/sdp-xml.h src/sdp-xml.c \ - src/textfile.h src/textfile.c \ + src/textfile.h src/textfile.c src/glib-compat.h \ src/glib-helper.h src/glib-helper.c \ src/oui.h src/oui.c src/uinput.h src/ppoll.h \ src/plugin.h src/plugin.c \ diff --git a/attrib/client.c b/attrib/client.c index 70cbf1565..bfe587709 100644 --- a/attrib/client.c +++ b/attrib/client.c @@ -36,7 +36,7 @@ #include #include -#include "glib-helper.h" +#include "glib-compat.h" #include "adapter.h" #include "device.h" #include "log.h" diff --git a/attrib/gatt.c b/attrib/gatt.c index a62f348c6..452a4cf8c 100644 --- a/attrib/gatt.c +++ b/attrib/gatt.c @@ -33,7 +33,7 @@ #include #include -#include "glib-helper.h" +#include "glib-compat.h" #include "att.h" #include "gattrib.h" diff --git a/audio/a2dp.c b/audio/a2dp.c index 47be7fd01..75ad6ced8 100644 --- a/audio/a2dp.c +++ b/audio/a2dp.c @@ -36,7 +36,7 @@ #include #include -#include "glib-helper.h" +#include "glib-compat.h" #include "log.h" #include "device.h" #include "manager.h" diff --git a/audio/avdtp.c b/audio/avdtp.c index 5b24f38db..d3568baa7 100644 --- a/audio/avdtp.c +++ b/audio/avdtp.c @@ -52,7 +52,7 @@ #include "manager.h" #include "control.h" #include "avdtp.h" -#include "glib-helper.h" +#include "glib-compat.h" #include "btio.h" #include "sink.h" #include "source.h" diff --git a/audio/gateway.c b/audio/gateway.c index 1a1c0357e..fb16a3d09 100644 --- a/audio/gateway.c +++ b/audio/gateway.c @@ -42,6 +42,7 @@ #include #include +#include "glib-compat.h" #include "glib-helper.h" #include "device.h" #include "gateway.h" diff --git a/audio/headset.c b/audio/headset.c index f1cda6ae1..e45e2162c 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -53,6 +53,7 @@ #include "error.h" #include "telephony.h" #include "headset.h" +#include "glib-compat.h" #include "glib-helper.h" #include "btio.h" #include "dbus-common.h" diff --git a/audio/telephony-maemo6.c b/audio/telephony-maemo6.c index fb5901301..5df3235fe 100644 --- a/audio/telephony-maemo6.c +++ b/audio/telephony-maemo6.c @@ -38,7 +38,7 @@ #include -#include "glib-helper.h" +#include "glib-compat.h" #include "log.h" #include "telephony.h" #include "error.h" diff --git a/audio/telephony-ofono.c b/audio/telephony-ofono.c index 26815cfdd..3607d7fd7 100644 --- a/audio/telephony-ofono.c +++ b/audio/telephony-ofono.c @@ -37,7 +37,7 @@ #include -#include "glib-helper.h" +#include "glib-compat.h" #include "log.h" #include "telephony.h" diff --git a/audio/unix.c b/audio/unix.c index c2d6d4a9b..4e0a6f9fd 100644 --- a/audio/unix.c +++ b/audio/unix.c @@ -52,7 +52,7 @@ #include "source.h" #include "gateway.h" #include "unix.h" -#include "glib-helper.h" +#include "glib-compat.h" #define check_nul(str) (str[sizeof(str) - 1] == '\0') diff --git a/network/connection.c b/network/connection.c index ac27cf22b..ca1f4b227 100644 --- a/network/connection.c +++ b/network/connection.c @@ -38,7 +38,7 @@ #include #include "log.h" -#include "glib-helper.h" +#include "glib-compat.h" #include "btio.h" #include "dbus-common.h" #include "adapter.h" diff --git a/network/server.c b/network/server.c index 7865f3985..6e0ce0959 100644 --- a/network/server.c +++ b/network/server.c @@ -46,7 +46,7 @@ #include "error.h" #include "sdpd.h" #include "btio.h" -#include "glib-helper.h" +#include "glib-compat.h" #include "common.h" #include "server.h" diff --git a/plugins/hciops.c b/plugins/hciops.c index 8d97f97b2..90b211222 100644 --- a/plugins/hciops.c +++ b/plugins/hciops.c @@ -40,7 +40,7 @@ #include -#include "glib-helper.h" +#include "glib-compat.h" #include "hcid.h" #include "sdpd.h" #include "btio.h" diff --git a/serial/port.c b/serial/port.c index 7f5fce12b..045f45997 100644 --- a/serial/port.c +++ b/serial/port.c @@ -48,6 +48,7 @@ #include "../src/dbus-common.h" #include "log.h" +#include "glib-compat.h" #include "glib-helper.h" #include "btio.h" diff --git a/src/adapter.c b/src/adapter.c index d1ef17cff..c2999d190 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -52,6 +52,7 @@ #include "device.h" #include "dbus-common.h" #include "error.h" +#include "glib-compat.h" #include "glib-helper.h" #include "agent.h" #include "storage.h" diff --git a/src/attrib-server.c b/src/attrib-server.c index 9ba5f74f7..e41206130 100644 --- a/src/attrib-server.c +++ b/src/attrib-server.c @@ -38,7 +38,7 @@ #include #include "log.h" -#include "glib-helper.h" +#include "glib-compat.h" #include "btio.h" #include "sdpd.h" #include "hcid.h" diff --git a/src/device.c b/src/device.c index b7e343b5b..339c001df 100644 --- a/src/device.c +++ b/src/device.c @@ -54,6 +54,7 @@ #include "device.h" #include "dbus-common.h" #include "error.h" +#include "glib-compat.h" #include "glib-helper.h" #include "gatt.h" #include "agent.h" diff --git a/src/eir.c b/src/eir.c index 8772191aa..e82d30bce 100644 --- a/src/eir.c +++ b/src/eir.c @@ -35,6 +35,7 @@ #include #include +#include "glib-compat.h" #include "glib-helper.h" #include "eir.h" diff --git a/src/glib-compat.h b/src/glib-compat.h new file mode 100644 index 000000000..d50d5e934 --- /dev/null +++ b/src/glib-compat.h @@ -0,0 +1,30 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2004-2011 Marcel Holtmann + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 + * + */ + +#ifdef NEED_G_SLIST_FREE_FULL +static inline void g_slist_free_full(GSList *list, GDestroyNotify free_func) +{ + g_slist_foreach(list, (GFunc) free_func, NULL); + g_slist_free(list); +} +#endif diff --git a/src/glib-helper.c b/src/glib-helper.c index 0288c9c9f..bb8883e57 100644 --- a/src/glib-helper.c +++ b/src/glib-helper.c @@ -39,6 +39,7 @@ #include "btio.h" #include "sdpd.h" +#include "glib-compat.h" #include "glib-helper.h" /* Number of seconds to keep a sdp_session_t in the cache */ diff --git a/src/glib-helper.h b/src/glib-helper.h index a38374164..c83f5e29a 100644 --- a/src/glib-helper.h +++ b/src/glib-helper.h @@ -34,11 +34,3 @@ char *bt_name2string(const char *string); int bt_string2uuid(uuid_t *uuid, const char *string); gchar *bt_list2string(GSList *list); GSList *bt_string2list(const gchar *str); - -#ifdef NEED_G_SLIST_FREE_FULL -static inline void g_slist_free_full(GSList *list, GDestroyNotify free_func) -{ - g_slist_foreach(list, (GFunc) free_func, NULL); - g_slist_free(list); -} -#endif diff --git a/src/storage.c b/src/storage.c index c64842c84..cc0213bd1 100644 --- a/src/storage.c +++ b/src/storage.c @@ -43,6 +43,7 @@ #include #include "textfile.h" +#include "glib-compat.h" #include "glib-helper.h" #include "storage.h" -- 2.47.3