summaryrefslogtreecommitdiff
path: root/bus/signals.c
diff options
context:
space:
mode:
authorAlban Crequy <alban.crequy@collabora.co.uk>2014-09-24 14:15:44 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-09-25 12:59:50 +0100
commitf01bd748f4eb97d50ebd6a968eda6a6b44c89eea (patch)
tree41f5494e07cc8b6caa585e3e04b33c465b64d269 /bus/signals.c
parent2e7a24bbde74161ad810b0e56b20469287a62315 (diff)
downloaddbus-f01bd748f4eb97d50ebd6a968eda6a6b44c89eea.tar.gz
match_rule_to_string: returns NULL if no memory instead of looping
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=24307 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Diffstat (limited to 'bus/signals.c')
-rw-r--r--bus/signals.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/bus/signals.c b/bus/signals.c
index d81bf2cd..902066f3 100644
--- a/bus/signals.c
+++ b/bus/signals.c
@@ -122,6 +122,7 @@ bus_match_rule_unref (BusMatchRule *rule)
/* Note this function does not do escaping, so it's only
* good for debug spew at the moment
*/
+/* returns NULL if no memory */
static char*
match_rule_to_string (BusMatchRule *rule)
{
@@ -130,10 +131,7 @@ match_rule_to_string (BusMatchRule *rule)
if (!_dbus_string_init (&str))
{
- char *s;
- while ((s = _dbus_strdup ("nomem")) == NULL)
- ; /* only OK for debug spew... */
- return s;
+ return NULL;
}
if (rule->flags & BUS_MATCH_MESSAGE_TYPE)
@@ -272,12 +270,7 @@ match_rule_to_string (BusMatchRule *rule)
nomem:
_dbus_string_free (&str);
- {
- char *s;
- while ((s = _dbus_strdup ("nomem")) == NULL)
- ; /* only OK for debug spew... */
- return s;
- }
+ return NULL;
}
#endif /* defined(DBUS_ENABLE_VERBOSE_MODE) || defined(DBUS_ENABLE_STATS) */
@@ -1427,7 +1420,7 @@ bus_matchmaker_add_rule (BusMatchmaker *matchmaker,
char *s = match_rule_to_string (rule);
_dbus_verbose ("Added match rule %s to connection %p\n",
- s, rule->matches_go_to);
+ s ? s : "nomem", rule->matches_go_to);
dbus_free (s);
}
#endif
@@ -1520,7 +1513,7 @@ bus_matchmaker_remove_rule_link (DBusList **rules,
char *s = match_rule_to_string (rule);
_dbus_verbose ("Removed match rule %s for connection %p\n",
- s, rule->matches_go_to);
+ s ? s : "nomem", rule->matches_go_to);
dbus_free (s);
}
#endif
@@ -1557,7 +1550,7 @@ bus_matchmaker_remove_rule (BusMatchmaker *matchmaker,
char *s = match_rule_to_string (rule);
_dbus_verbose ("Removed match rule %s for connection %p\n",
- s, rule->matches_go_to);
+ s ? s : "nomem", rule->matches_go_to);
dbus_free (s);
}
#endif
@@ -2034,7 +2027,7 @@ get_recipients_from_list (DBusList **rules,
char *s = match_rule_to_string (rule);
_dbus_verbose ("Checking whether message matches rule %s for connection %p\n",
- s, rule->matches_go_to);
+ s ? s : "nomem", rule->matches_go_to);
dbus_free (s);
}
#endif