[PATCH 2/4] Don't use g_slist_length to check for empty lists.

Andrzej Zaborowski andrew.zaborowski at intel.com
Thu Jul 30 01:05:10 PDT 2009


A glib Anti-pattern according to http://www.burtonini.com/blog
---
 src/voicecall.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/voicecall.c b/src/voicecall.c
index 409d97a..b343ed6 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -897,7 +897,7 @@ static DBusMessage *manager_hangup_all(DBusConnection *conn,
 	if (!calls->ops->release_specific)
 		return dbus_gsm_not_implemented(msg);
 
-	if (g_slist_length(calls->call_list) == 0) {
+	if (calls->call_list == NULL) {
 		DBusMessage *reply = dbus_message_new_method_return(msg);
 		return reply;
 	}
@@ -1009,7 +1009,7 @@ static DBusMessage *multiparty_hangup(DBusConnection *conn,
 	if (!calls->ops->release_all_active)
 		return dbus_gsm_not_implemented(msg);
 
-	if (g_slist_length(calls->multiparty_list) == 0) {
+	if (calls->multiparty_list == NULL) {
 		DBusMessage *reply = dbus_message_new_method_return(msg);
 		return reply;
 	}
@@ -1362,7 +1362,7 @@ static void multirelease_callback(const struct ofono_error *error, void *data)
 	DBusConnection *conn = dbus_gsm_connection();
 	DBusMessage *reply;
 
-	if (g_slist_length(calls->release_list)) {
+	if (calls->release_list != NULL) {
 		voicecalls_release_next(modem);
 		return;
 	}
-- 
1.6.1



More information about the ofono mailing list