chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Move bus_error to dbus-common and remove bus_error_message_or_strerror
[elogind.git]
/
src
/
login
/
logind-user-dbus.c
diff --git
a/src/login/logind-user-dbus.c
b/src/login/logind-user-dbus.c
index 21b608d526be2a58382f1742374b961cceaacc6f..8cc1dd49fde26500ad877a6a82ed13cdeb696137 100644
(file)
--- a/
src/login/logind-user-dbus.c
+++ b/
src/login/logind-user-dbus.c
@@
-65,7
+65,7
@@
static int bus_user_append_display(DBusMessageIter *i, const char *property, voi
DBusMessageIter sub;
User *u = data;
const char *id, *path;
DBusMessageIter sub;
User *u = data;
const char *id, *path;
- char *p = NULL;
+ char
_cleanup_free_
*p = NULL;
assert(i);
assert(property);
assert(i);
assert(property);
@@
-86,12
+86,8
@@
static int bus_user_append_display(DBusMessageIter *i, const char *property, voi
}
if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &id) ||
}
if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &id) ||
- !dbus_message_iter_append_basic(&sub, DBUS_TYPE_OBJECT_PATH, &path)) {
- free(p);
+ !dbus_message_iter_append_basic(&sub, DBUS_TYPE_OBJECT_PATH, &path))
return -ENOMEM;
return -ENOMEM;
- }
-
- free(p);
if (!dbus_message_iter_close_container(i, &sub))
return -ENOMEM;
if (!dbus_message_iter_close_container(i, &sub))
return -ENOMEM;
@@
-189,9
+185,9
@@
static int bus_user_append_idle_hint_since(DBusMessageIter *i, const char *prope
return 0;
}
return 0;
}
-static bus_user_append_default_cgroup(DBusMessageIter *i, const char *property, void *data) {
+static
int
bus_user_append_default_cgroup(DBusMessageIter *i, const char *property, void *data) {
User *u = data;
User *u = data;
- char
*t
;
+ char
_cleanup_free_ *t = NULL
;
int r;
bool success;
int r;
bool success;
@@
-204,8
+200,6
@@
static bus_user_append_default_cgroup(DBusMessageIter *i, const char *property,
return r;
success = dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t);
return r;
success = dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t);
- free(t);
-
return success ? 0 : -ENOMEM;
}
return success ? 0 : -ENOMEM;
}
@@
-257,7
+251,7
@@
static DBusHandlerResult user_message_dispatch(
DBusMessage *message) {
DBusError error;
DBusMessage *message) {
DBusError error;
- DBusMessage *reply = NULL;
+
_cleanup_dbus_message_unref_
DBusMessage *reply = NULL;
int r;
assert(u);
int r;
assert(u);
@@
-304,18
+298,13
@@
static DBusHandlerResult user_message_dispatch(
}
if (reply) {
}
if (reply) {
- if (!
dbus_connection_send(connection, reply, NULL
))
+ if (!
bus_maybe_send_reply(connection, message, reply
))
goto oom;
goto oom;
-
- dbus_message_unref(reply);
}
return DBUS_HANDLER_RESULT_HANDLED;
oom:
}
return DBUS_HANDLER_RESULT_HANDLED;
oom:
- if (reply)
- dbus_message_unref(reply);
-
dbus_error_free(&error);
return DBUS_HANDLER_RESULT_NEED_MEMORY;
dbus_error_free(&error);
return DBUS_HANDLER_RESULT_NEED_MEMORY;
@@
-366,9
+355,8
@@
char *user_bus_path(User *u) {
}
int user_send_signal(User *u, bool new_user) {
}
int user_send_signal(User *u, bool new_user) {
- DBusMessage *m;
- int r = -ENOMEM;
- char *p = NULL;
+ _cleanup_dbus_message_unref_ DBusMessage *m = NULL;
+ _cleanup_free_ char *p = NULL;
uint32_t uid;
assert(u);
uint32_t uid;
assert(u);
@@
-382,7
+370,7
@@
int user_send_signal(User *u, bool new_user) {
p = user_bus_path(u);
if (!p)
p = user_bus_path(u);
if (!p)
-
goto finish
;
+
return -ENOMEM
;
uid = u->uid;
uid = u->uid;
@@
-391,24
+379,17
@@
int user_send_signal(User *u, bool new_user) {
DBUS_TYPE_UINT32, &uid,
DBUS_TYPE_OBJECT_PATH, &p,
DBUS_TYPE_INVALID))
DBUS_TYPE_UINT32, &uid,
DBUS_TYPE_OBJECT_PATH, &p,
DBUS_TYPE_INVALID))
-
goto finish
;
+
return -ENOMEM
;
if (!dbus_connection_send(u->manager->bus, m, NULL))
if (!dbus_connection_send(u->manager->bus, m, NULL))
- goto finish;
-
- r = 0;
-
-finish:
- dbus_message_unref(m);
- free(p);
+ return -ENOMEM;
- return
r
;
+ return
0
;
}
int user_send_changed(User *u, const char *properties) {
}
int user_send_changed(User *u, const char *properties) {
- DBusMessage *m;
- int r = -ENOMEM;
- char *p = NULL;
+ _cleanup_dbus_message_unref_ DBusMessage *m = NULL;
+ _cleanup_free_ char *p = NULL;
assert(u);
assert(u);
@@
-421,17
+402,10
@@
int user_send_changed(User *u, const char *properties) {
m = bus_properties_changed_new(p, "org.freedesktop.login1.User", properties);
if (!m)
m = bus_properties_changed_new(p, "org.freedesktop.login1.User", properties);
if (!m)
-
goto finish
;
+
return -ENOMEM
;
if (!dbus_connection_send(u->manager->bus, m, NULL))
if (!dbus_connection_send(u->manager->bus, m, NULL))
- goto finish;
-
- r = 0;
-
-finish:
- if (m)
- dbus_message_unref(m);
- free(p);
+ return -ENOMEM;
- return
r
;
+ return
0
;
}
}