diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-03-20 13:10:12 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-03-20 23:00:10 +0100 |
commit | fbfa72b0a1276366d50dce223c06efe9db9d6585 (patch) | |
tree | 72fcc96368e8c49693ca04353df06848f261ff84 /src/libsystemd-bus/bus-error.c | |
parent | 80a46c7313b8fc4682881cb3a2ca9e4d743fcb2b (diff) |
bus: introduce bus_error_is_dirty() independently of sd_bus_error_is_set()
Diffstat (limited to 'src/libsystemd-bus/bus-error.c')
-rw-r--r-- | src/libsystemd-bus/bus-error.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/libsystemd-bus/bus-error.c b/src/libsystemd-bus/bus-error.c index 0832022ee9..015fae70ad 100644 --- a/src/libsystemd-bus/bus-error.c +++ b/src/libsystemd-bus/bus-error.c @@ -31,6 +31,13 @@ #include "sd-bus.h" #include "bus-error.h" +bool bus_error_is_dirty(sd_bus_error *e) { + if (!e) + return 0; + + return e->name || e->message || e->need_free; +} + void sd_bus_error_free(sd_bus_error *e) { if (!e) return; @@ -51,7 +58,7 @@ int sd_bus_error_set(sd_bus_error *e, const char *name, const char *format, ...) if (!e) return 0; - if (sd_bus_error_is_set(e)) + if (bus_error_is_dirty(e)) return -EINVAL; if (!name) return -EINVAL; @@ -81,7 +88,7 @@ int sd_bus_error_set(sd_bus_error *e, const char *name, const char *format, ...) int sd_bus_error_copy(sd_bus_error *dest, const sd_bus_error *e) { if (!dest) return 0; - if (sd_bus_error_is_set(dest)) + if (bus_error_is_dirty(dest)) return -EINVAL; if (!sd_bus_error_is_set(e)) return 0; @@ -113,18 +120,19 @@ int sd_bus_error_copy(sd_bus_error *dest, const sd_bus_error *e) { void sd_bus_error_set_const(sd_bus_error *e, const char *name, const char *message) { if (!e) return; - if (sd_bus_error_is_set(e)) + if (bus_error_is_dirty(e)) return; e->name = name; e->message = message; + e->need_free = false; } int sd_bus_error_is_set(const sd_bus_error *e) { if (!e) return 0; - return e->name || e->message || e->need_free; + return !!e->name; } int sd_bus_error_has_name(const sd_bus_error *e, const char *name) { |