1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00

sd-bus,sd-event: unify error handling of object descriptions

a) When getting the description return ENXIO if none is set

b) Allow setting a description to NULL

c) return ECHILD on fork() like for other calls
This commit is contained in:
Lennart Poettering 2014-11-04 16:58:42 +01:00
parent d1b91c99d9
commit f4b2933ee7
2 changed files with 4 additions and 1 deletions

View File

@ -325,7 +325,6 @@ _public_ int sd_bus_set_trusted(sd_bus *bus, int b) {
_public_ int sd_bus_set_description(sd_bus *bus, const char *description) {
assert_return(bus, -EINVAL);
assert_return(description, -EINVAL);
assert_return(bus->state == BUS_UNSET, -EPERM);
assert_return(!bus_pid_changed(bus), -ECHILD);
@ -3316,6 +3315,7 @@ _public_ int sd_bus_try_close(sd_bus *bus) {
_public_ int sd_bus_get_description(sd_bus *bus, const char **description) {
assert_return(bus, -EINVAL);
assert_return(description, -EINVAL);
assert_return(bus->description, -ENXIO);
assert_return(!bus_pid_changed(bus), -ECHILD);
*description = bus->description;

View File

@ -1258,6 +1258,7 @@ _public_ sd_event_source* sd_event_source_unref(sd_event_source *s) {
_public_ int sd_event_source_set_description(sd_event_source *s, const char *description) {
assert_return(s, -EINVAL);
assert_return(!event_pid_changed(s->event), -ECHILD);
return free_and_strdup(&s->description, description);
}
@ -1265,6 +1266,8 @@ _public_ int sd_event_source_set_description(sd_event_source *s, const char *des
_public_ int sd_event_source_get_description(sd_event_source *s, const char **description) {
assert_return(s, -EINVAL);
assert_return(description, -EINVAL);
assert_return(s->description, -ENXIO);
assert_return(!event_pid_changed(s->event), -ECHILD);
*description = s->description;
return 0;