r = sd_bus_message_append(reply, "s", sd_id128_to_string(id, sid));
} else {
- _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_INIT;
+ _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus_error_set(&error,
"org.freedesktop.DBus.Error.UnknownMethod",
}
static int process_object(sd_bus *bus, sd_bus_message *m) {
- _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_INIT;
+ _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
struct object_callback *c;
int r;
if (m->header->type == SD_BUS_MESSAGE_TYPE_METHOD_CALL) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
- _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_INIT;
+ _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus_error_set(&error, "org.freedesktop.DBus.Error.UnknownObject", "Unknown object '%s'.", m->path);
}
} else if (sd_bus_message_is_method_call(m, NULL, NULL)) {
- const sd_bus_error e = SD_BUS_ERROR_INIT_CONST("org.freedesktop.DBus.Error.UnknownMethod", "Unknown method.");
- r = sd_bus_message_new_method_error(bus, m, &e, &reply);
+ r = sd_bus_message_new_method_error(
+ bus, m,
+ &SD_BUS_ERROR_MAKE("org.freedesktop.DBus.Error.UnknownMethod", "Unknown method."),
+ &reply);
if (r < 0) {
log_error("Failed to allocate return: %s", strerror(-r));
goto fail;
static void* client1(void*p) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
sd_bus *bus = NULL;
- sd_bus_error error = SD_BUS_ERROR_INIT;
+ sd_bus_error error = SD_BUS_ERROR_NULL;
const char *hello;
int r;
int pp[2] = { -1, -1 };
static void* client2(void*p) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
sd_bus *bus = NULL;
- sd_bus_error error = SD_BUS_ERROR_INIT;
+ sd_bus_error error = SD_BUS_ERROR_NULL;
bool quit = false;
const char *mid;
int r;
quit = true;
} else if (sd_bus_message_is_method_call(m, NULL, NULL)) {
- const sd_bus_error e = SD_BUS_ERROR_INIT_CONST("org.freedesktop.DBus.Error.UnknownMethod", "Unknown method.");
-
- r = sd_bus_message_new_method_error(bus, m, &e, &reply);
+ r = sd_bus_message_new_method_error(
+ bus, m,
+ &SD_BUS_ERROR_MAKE("org.freedesktop.DBus.Error.UnknownMethod", "Unknown method."),
+ &reply);
if (r < 0) {
log_error("Failed to allocate return: %s", strerror(-r));
goto fail;
static int client(struct context *c) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
_cleanup_bus_unref_ sd_bus *bus = NULL;
- sd_bus_error error = SD_BUS_ERROR_INIT;
+ sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
assert_se(sd_bus_new(&bus) >= 0);
/* Error structures */
-#define SD_BUS_ERROR_INIT {NULL, NULL, 0}
-#define SD_BUS_ERROR_INIT_CONST(name, message) {(name), (message), 0}
+#define SD_BUS_ERROR_NULL ((sd_bus_error) {NULL, NULL, 0})
+#define SD_BUS_ERROR_MAKE(name, message) ((sd_bus_error) {(name), (message), 0})
void sd_bus_error_free(sd_bus_error *e);
int sd_bus_error_set(sd_bus_error *e, const char *name, const char *format, ...);