From 67f3c40265471056d1e532c6d6e36a521b0a780a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 14 Sep 2012 15:11:07 +0200 Subject: systemctl: show unit name when a job fails https://bugzilla.redhat.com/show_bug.cgi?id=845028 https://bugzilla.redhat.com/show_bug.cgi?id=846483 --- src/shared/dbus-common.c | 19 +++++++++++-------- src/shared/hashmap.c | 10 ++++++++-- 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'src/shared') diff --git a/src/shared/dbus-common.c b/src/shared/dbus-common.c index bcbef77b53..b8229bd663 100644 --- a/src/shared/dbus-common.c +++ b/src/shared/dbus-common.c @@ -1253,14 +1253,16 @@ bool bus_error_is_no_service(const DBusError *error) { return startswith(error->name, "org.freedesktop.DBus.Error.Spawn."); } -int bus_method_call_with_reply(DBusConnection *bus, - const char *destination, - const char *path, - const char *interface, - const char *method, - DBusMessage **return_reply, - DBusError *return_error, - int first_arg_type, ...) { +int bus_method_call_with_reply( + DBusConnection *bus, + const char *destination, + const char *path, + const char *interface, + const char *method, + DBusMessage **return_reply, + DBusError *return_error, + int first_arg_type, ...) { + DBusError error; DBusMessage *m, *reply; va_list ap; @@ -1287,6 +1289,7 @@ int bus_method_call_with_reply(DBusConnection *bus, if (!reply) { if (!return_error) log_error("Failed to issue method call: %s", bus_error_message(&error)); + if (bus_error_is_no_service(&error)) r = -ENOENT; else if (dbus_error_has_name(&error, DBUS_ERROR_ACCESS_DENIED)) diff --git a/src/shared/hashmap.c b/src/shared/hashmap.c index 0a044b85ad..eb5c549e40 100644 --- a/src/shared/hashmap.c +++ b/src/shared/hashmap.c @@ -265,6 +265,8 @@ static void remove_entry(Hashmap *h, struct hashmap_entry *e) { void hashmap_free(Hashmap*h) { + /* Free the hashmap, but nothing in it */ + if (!h) return; @@ -277,6 +279,10 @@ void hashmap_free(Hashmap*h) { } void hashmap_free_free(Hashmap *h) { + + /* Free the hashmap and all data objects in it, but not the + * keys */ + if (!h) return; @@ -371,8 +377,8 @@ void* hashmap_get(Hashmap *h, const void *key) { return NULL; hash = h->hash_func(key) % NBUCKETS; - - if (!(e = hash_scan(h, hash, key))) + e = hash_scan(h, hash, key); + if (!e) return NULL; return e->value; -- cgit v1.2.3-54-g00ecf