sd-bus: synthesize a description for user/system bus if otherwise unset

Let's make debugging easier, by synthesizing a name when we have some
indication what kind of bus this is.
This commit is contained in:
Lennart Poettering 2018-02-07 22:28:42 +01:00
parent 96cc44539b
commit 201e419aea
1 changed files with 9 additions and 1 deletions

View File

@ -3920,7 +3920,15 @@ _public_ int sd_bus_get_description(sd_bus *bus, const char **description) {
assert_return(bus->description, -ENXIO);
assert_return(!bus_pid_changed(bus), -ECHILD);
*description = bus->description;
if (bus->description)
*description = bus->description;
else if (bus->is_system)
*description = "system";
else if (bus->is_user)
*description = "user";
else
*description = NULL;
return 0;
}