From 24c6dee3b307cbf9e99dfdb875895f410120ec41 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Wed, 4 May 2011 14:33:19 +0200 Subject: [PATCH] Remove redundant local copy of GSlist* from functions Those functions already get copy of pointer to list so local copy is not needed. --- audio/a2dp.c | 5 ++--- audio/avdtp.c | 18 ++++++------------ audio/control.c | 6 ++---- audio/manager.c | 6 ++---- audio/unix.c | 5 ++--- health/mcap.c | 5 ++--- input/device.c | 12 ++++-------- network/connection.c | 12 ++++-------- network/server.c | 12 ++++-------- serial/proxy.c | 6 ++---- src/adapter.c | 17 ++++++----------- 11 files changed, 36 insertions(+), 68 deletions(-) diff --git a/audio/a2dp.c b/audio/a2dp.c index 9cd720711..6f7a437f4 100644 --- a/audio/a2dp.c +++ b/audio/a2dp.c @@ -1375,10 +1375,9 @@ static sdp_record_t *a2dp_record(uint8_t type, uint16_t avdtp_ver) static struct a2dp_server *find_server(GSList *list, const bdaddr_t *src) { - GSList *l; - for (l = list; l; l = l->next) { - struct a2dp_server *server = l->data; + for (; list; list = list->next) { + struct a2dp_server *server = list->data; if (bacmp(&server->src, src) == 0) return server; diff --git a/audio/avdtp.c b/audio/avdtp.c index c2aeeec77..f61e2f669 100644 --- a/audio/avdtp.c +++ b/audio/avdtp.c @@ -453,10 +453,8 @@ static void auth_cb(DBusError *derr, void *user_data); static struct avdtp_server *find_server(GSList *list, const bdaddr_t *src) { - GSList *l; - - for (l = list; l; l = l->next) { - struct avdtp_server *server = l->data; + for (; list; list = list->next) { + struct avdtp_server *server = list->data; if (bacmp(&server->src, src) == 0) return server; @@ -2217,10 +2215,8 @@ failed: static struct avdtp *find_session(GSList *list, const bdaddr_t *dst) { - GSList *l; - - for (l = list; l != NULL; l = g_slist_next(l)) { - struct avdtp *s = l->data; + for (; list != NULL; list = g_slist_next(list)) { + struct avdtp *s = list->data; if (bacmp(dst, &s->dst)) continue; @@ -3189,10 +3185,8 @@ gboolean avdtp_stream_has_capability(struct avdtp_stream *stream, gboolean avdtp_stream_has_capabilities(struct avdtp_stream *stream, GSList *caps) { - GSList *l; - - for (l = caps; l; l = g_slist_next(l)) { - struct avdtp_service_capability *cap = l->data; + for (; caps; caps = g_slist_next(caps)) { + struct avdtp_service_capability *cap = caps->data; if (!avdtp_stream_has_capability(stream, cap)) return FALSE; diff --git a/audio/control.c b/audio/control.c index d6890de8b..17454b9ad 100644 --- a/audio/control.c +++ b/audio/control.c @@ -910,10 +910,8 @@ int avrcp_register(DBusConnection *conn, const bdaddr_t *src, GKeyFile *config) static struct avctp_server *find_server(GSList *list, const bdaddr_t *src) { - GSList *l; - - for (l = list; l; l = l->next) { - struct avctp_server *server = l->data; + for (; list; list = list->next) { + struct avctp_server *server = list->data; if (bacmp(&server->src, src) == 0) return server; diff --git a/audio/manager.c b/audio/manager.c index f9b460eff..727c0cc36 100644 --- a/audio/manager.c +++ b/audio/manager.c @@ -124,10 +124,8 @@ static struct enabled_interfaces enabled = { static struct audio_adapter *find_adapter(GSList *list, struct btd_adapter *btd_adapter) { - GSList *l; - - for (l = list; l; l = l->next) { - struct audio_adapter *adapter = l->data; + for (; list; list = list->next) { + struct audio_adapter *adapter = list->data; if (adapter->btd_adapter == btd_adapter) return adapter; diff --git a/audio/unix.c b/audio/unix.c index 37c772d60..b29f5f5a1 100644 --- a/audio/unix.c +++ b/audio/unix.c @@ -629,7 +629,6 @@ static void a2dp_discovery_complete(struct avdtp *session, GSList *seps, char buf[BT_SUGGESTED_BUFFER_SIZE]; struct bt_get_capabilities_rsp *rsp = (void *) buf; struct a2dp_data *a2dp = &client->d.a2dp; - GSList *l; if (!g_slist_find(clients, client)) { DBG("Client disconnected during discovery"); @@ -649,8 +648,8 @@ static void a2dp_discovery_complete(struct avdtp *session, GSList *seps, ba2str(&client->dev->dst, rsp->destination); strncpy(rsp->object, client->dev->path, sizeof(rsp->object)); - for (l = seps; l; l = g_slist_next(l)) { - struct avdtp_remote_sep *rsep = l->data; + for (; seps; seps = g_slist_next(seps)) { + struct avdtp_remote_sep *rsep = seps->data; struct a2dp_sep *sep; struct avdtp_service_capability *cap; struct avdtp_stream *stream; diff --git a/health/mcap.c b/health/mcap.c index 48866d494..793c32d5b 100644 --- a/health/mcap.c +++ b/health/mcap.c @@ -685,11 +685,10 @@ gboolean mcap_mdl_abort(struct mcap_mdl *mdl, mcap_mdl_notify_cb abort_cb, static struct mcap_mcl *find_mcl(GSList *list, const bdaddr_t *addr) { - GSList *l; struct mcap_mcl *mcl; - for (l = list; l; l = l->next) { - mcl = l->data; + for (; list; list = list->next) { + mcl = list->data; if (!bacmp(&mcl->addr, addr)) return mcl; diff --git a/input/device.c b/input/device.c index 554f5ac32..816ad837c 100644 --- a/input/device.c +++ b/input/device.c @@ -94,10 +94,8 @@ GSList *devices = NULL; static struct input_device *find_device_by_path(GSList *list, const char *path) { - GSList *l; - - for (l = list; l; l = l->next) { - struct input_device *idev = l->data; + for (; list; list = list->next) { + struct input_device *idev = list->data; if (!strcmp(idev->path, path)) return idev; @@ -108,10 +106,8 @@ static struct input_device *find_device_by_path(GSList *list, const char *path) static struct input_conn *find_connection(GSList *list, const char *pattern) { - GSList *l; - - for (l = list; l; l = l->next) { - struct input_conn *iconn = l->data; + for (; list; list = list->next) { + struct input_conn *iconn = list->data; if (!strcasecmp(iconn->uuid, pattern)) return iconn; diff --git a/network/connection.c b/network/connection.c index f4dd74ea7..181274ac3 100644 --- a/network/connection.c +++ b/network/connection.c @@ -85,10 +85,8 @@ static GSList *peers = NULL; static struct network_peer *find_peer(GSList *list, const char *path) { - GSList *l; - - for (l = list; l; l = l->next) { - struct network_peer *peer = l->data; + for (; list; list = list->next) { + struct network_peer *peer = list->data; if (!strcmp(peer->path, path)) return peer; @@ -99,10 +97,8 @@ static struct network_peer *find_peer(GSList *list, const char *path) static struct network_conn *find_connection(GSList *list, uint16_t id) { - GSList *l; - - for (l = list; l; l = l->next) { - struct network_conn *nc = l->data; + for (; list; list = list->next) { + struct network_conn *nc = list->data; if (nc->id == id) return nc; diff --git a/network/server.c b/network/server.c index d1da8a9a4..5feb9d00c 100644 --- a/network/server.c +++ b/network/server.c @@ -88,10 +88,8 @@ static gboolean security = TRUE; static struct network_adapter *find_adapter(GSList *list, struct btd_adapter *adapter) { - GSList *l; - - for (l = list; l; l = l->next) { - struct network_adapter *na = l->data; + for (; list; list = list->next) { + struct network_adapter *na = list->data; if (na->adapter == adapter) return na; @@ -102,10 +100,8 @@ static struct network_adapter *find_adapter(GSList *list, static struct network_server *find_server(GSList *list, uint16_t id) { - GSList *l; - - for (l = list; l; l = l->next) { - struct network_server *ns = l->data; + for (; list; list = list->next) { + struct network_server *ns = list->data; if (ns->id == id) return ns; diff --git a/serial/proxy.c b/serial/proxy.c index 46561d0f0..127e78015 100644 --- a/serial/proxy.c +++ b/serial/proxy.c @@ -1147,10 +1147,8 @@ static GDBusSignalTable manager_signals[] = { static struct serial_adapter *find_adapter(GSList *list, struct btd_adapter *btd_adapter) { - GSList *l; - - for (l = list; l; l = l->next) { - struct serial_adapter *adapter = l->data; + for (; list; list = list->next) { + struct serial_adapter *adapter = list->data; if (adapter->btd_adapter == btd_adapter) return adapter; diff --git a/src/adapter.c b/src/adapter.c index f06833514..5ab77fecf 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -459,10 +459,8 @@ static int adapter_set_mode(struct btd_adapter *adapter, uint8_t mode) static struct session_req *find_session_by_msg(GSList *list, const DBusMessage *msg) { - GSList *l; - - for (l = list; l; l = l->next) { - struct session_req *req = l->data; + for (; list; list = list->next) { + struct session_req *req = list->data; if (req->msg == msg) return req; @@ -648,10 +646,8 @@ static void adapter_set_pairable_timeout(struct btd_adapter *adapter, static struct session_req *find_session(GSList *list, const char *sender) { - GSList *l; - - for (l = list; l; l = l->next) { - struct session_req *req = l->data; + for (; list; list = list->next) { + struct session_req *req = list->data; if (g_str_equal(req->owner, sender)) return req; @@ -2834,7 +2830,6 @@ static void emit_device_found(const char *path, const char *address, static char **strlist2array(GSList *list) { - GSList *l; unsigned int i, n; char **array; @@ -2844,8 +2839,8 @@ static char **strlist2array(GSList *list) n = g_slist_length(list); array = g_new0(char *, n + 1); - for (l = list, i = 0; l; l = l->next, i++) - array[i] = g_strdup((const gchar *) l->data); + for (i = 0; list; list = list->next, i++) + array[i] = g_strdup((const gchar *) list->data); return array; } -- 2.47.3