From: Mikel Astiz <mikel.astiz@xxxxxxxxxxxx> The new function is a convenient way to create a D-Bus error message and automatically free the GError object. --- gdbus/gdbus.h | 4 ++++ gdbus/object.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h index a0583e6..485ee01 100644 --- a/gdbus/gdbus.h +++ b/gdbus/gdbus.h @@ -138,6 +138,10 @@ DBusMessage *g_dbus_create_error(DBusMessage *message, const char *name, __attribute__((format(printf, 3, 4))); DBusMessage *g_dbus_create_error_valist(DBusMessage *message, const char *name, const char *format, va_list args); + +DBusMessage *g_dbus_steal_from_gerror(DBusMessage *message, const char *name, + GError **err); + DBusMessage *g_dbus_create_reply(DBusMessage *message, int type, ...); DBusMessage *g_dbus_create_reply_valist(DBusMessage *message, int type, va_list args); diff --git a/gdbus/object.c b/gdbus/object.c index 8bc12f5..f4128b2 100644 --- a/gdbus/object.c +++ b/gdbus/object.c @@ -765,6 +765,20 @@ DBusMessage *g_dbus_create_error(DBusMessage *message, const char *name, return reply; } +DBusMessage *g_dbus_steal_from_gerror(DBusMessage *message, const char *name, + GError **err) +{ + DBusMessage *reply; + + if ((err == NULL) || (*err == NULL)) + return NULL; + + reply = g_dbus_create_error(message, name, "%s", (*err)->message); + g_clear_error(err); + + return reply; +} + DBusMessage *g_dbus_create_reply_valist(DBusMessage *message, int type, va_list args) { -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html