From d7930dc38453a155a145bf96abf70c9a1ac50139 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 25 Feb 2013 11:18:10 +0000 Subject: [PATCH 5/6] fd.o #61433: caps hash: make all field comparisons NULL-safe This is less targeted than wjt's version in Wocky - some of these are probably guaranteed to be non-NULL anyway, but it's quicker to g_strcmp0 everywhere. Signed-off-by: Simon McVittie --- src/caps-hash.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/caps-hash.c b/src/caps-hash.c index 31b5d7d..1c7621c 100644 --- a/src/caps-hash.c +++ b/src/caps-hash.c @@ -63,7 +63,7 @@ char_cmp (gconstpointer a, gconstpointer b) gchar *left = *(gchar **) a; gchar *right = *(gchar **) b; - return strcmp (left, right); + return g_strcmp0 (left, right); } static gint @@ -73,13 +73,13 @@ identity_cmp (gconstpointer a, gconstpointer b) GabbleDiscoIdentity *right = *(GabbleDiscoIdentity **) b; gint ret; - if ((ret = strcmp (left->category, right->category)) != 0) + if ((ret = g_strcmp0 (left->category, right->category)) != 0) return ret; - if ((ret = strcmp (left->type, right->type)) != 0) + if ((ret = g_strcmp0 (left->type, right->type)) != 0) return ret; - if ((ret = strcmp (left->lang, right->lang)) != 0) + if ((ret = g_strcmp0 (left->lang, right->lang)) != 0) return ret; - return strcmp (left->name, right->name); + return g_strcmp0 (left->name, right->name); } static gint @@ -88,7 +88,7 @@ fields_cmp (gconstpointer a, gconstpointer b) DataFormField *left = *(DataFormField **) a; DataFormField *right = *(DataFormField **) b; - return strcmp (left->field_name, right->field_name); + return g_strcmp0 (left->field_name, right->field_name); } static gint @@ -97,7 +97,7 @@ dataforms_cmp (gconstpointer a, gconstpointer b) DataForm *left = *(DataForm **) a; DataForm *right = *(DataForm **) b; - return strcmp (left->form_type, right->form_type); + return g_strcmp0 (left->form_type, right->form_type); } static void -- 1.7.10.4