commit 04d86af8d57dd8c16283ea6acc6d6798053cf2a0
Author: Andrew Beekhof <andrew@beekhof.net>
Date: Wed Feb 5 10:56:51 2014 +1100
Refactor: dbus: Use native function for adding arguments to messages
(cherry picked from commit bab144c83e90785c7df01423d3b239cbd4a2cd55)
diff --git a/lib/services/dbus.c b/lib/services/dbus.c
index 66a98a0..b424c0b 100644
--- a/lib/services/dbus.c
+++ b/lib/services/dbus.c
@@ -33,19 +33,6 @@ void pcmk_dbus_disconnect(DBusConnection *connection)
{
}
-bool pcmk_dbus_append_arg(DBusMessage *msg, int dtype, const void *value)
-{
- DBusMessageIter args;
-
- dbus_message_iter_init_append(msg, &args);
- if (!dbus_message_iter_append_basic(&args, dtype, value)) {
- crm_err("dbus_message_iter_append_basic(%c) failed", dtype);
- return FALSE;
- }
-
- return TRUE;
-}
-
bool
pcmk_dbus_find_error(const char *method, DBusPendingCall* pending, DBusMessage *reply, DBusError *ret)
{
@@ -235,7 +222,7 @@ pcmk_dbus_get_property(
return NULL;
}
- pcmk_dbus_append_arg(msg, DBUS_TYPE_STRING, &iface);
+ CRM_LOG_ASSERT(dbus_message_append_args(msg, DBUS_TYPE_STRING, &iface, DBUS_TYPE_INVALID));
reply = pcmk_dbus_send_recv(msg, connection, &error);
dbus_message_unref(msg);
diff --git a/lib/services/pcmk-dbus.h b/lib/services/pcmk-dbus.h
index c8d2234..3b7a598 100644
--- a/lib/services/pcmk-dbus.h
+++ b/lib/services/pcmk-dbus.h
@@ -5,7 +5,6 @@ void pcmk_dbus_disconnect(DBusConnection *connection);
bool pcmk_dbus_send(DBusMessage *msg, DBusConnection *connection,
void(*done)(DBusPendingCall *pending, void *user_data), void *user_data);
DBusMessage *pcmk_dbus_send_recv(DBusMessage *msg, DBusConnection *connection, DBusError *error);
-bool pcmk_dbus_append_arg(DBusMessage *msg, int dtype, const void *value);
bool pcmk_dbus_type_check(DBusMessage *msg, DBusMessageIter *field, int expected, const char *function, int line);
char *pcmk_dbus_get_property(DBusConnection *connection, const char *target, const char *obj, const gchar * iface, const char *name);
diff --git a/lib/services/systemd.c b/lib/services/systemd.c
index b461c5f..374a03e 100644
--- a/lib/services/systemd.c
+++ b/lib/services/systemd.c
@@ -146,7 +146,7 @@ systemd_unit_by_name(const gchar * arg_name, gchar ** out_unit)
msg = systemd_new_method(BUS_NAME".Manager", method);
CRM_ASSERT(msg != NULL);
- pcmk_dbus_append_arg(msg, DBUS_TYPE_STRING, &name);
+ CRM_LOG_ASSERT(dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID));
dbus_error_init(&error);
reply = pcmk_dbus_send_recv(msg, systemd_proxy, &error);
@@ -477,8 +477,8 @@ systemd_unit_exec(svc_action_t * op, gboolean synchronous)
CRM_ASSERT(msg != NULL);
/* (ss) */
- pcmk_dbus_append_arg(msg, DBUS_TYPE_STRING, &name);
- pcmk_dbus_append_arg(msg, DBUS_TYPE_STRING, &replace_s);
+ CRM_LOG_ASSERT(dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID));
+ CRM_LOG_ASSERT(dbus_message_append_args(msg, DBUS_TYPE_STRING, &replace_s, DBUS_TYPE_INVALID));
if (synchronous == FALSE) {
free(unit);