chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bus: use C99 struct construction for error initializers
[elogind.git]
/
src
/
login
/
logind-dbus.c
diff --git
a/src/login/logind-dbus.c
b/src/login/logind-dbus.c
index 1dcdf04b2925462169d126a9d3a4ec7f87b75221..aa212d1fedfb4591ad96530cbf9f4ca2ccc4dd55 100644
(file)
--- a/
src/login/logind-dbus.c
+++ b/
src/login/logind-dbus.c
@@
-319,7
+319,7
@@
static int bus_manager_create_session(Manager *m, DBusMessage *message, DBusMess
int r;
uint32_t vtnr = 0;
_cleanup_close_ int fifo_fd = -1;
int r;
uint32_t vtnr = 0;
_cleanup_close_ int fifo_fd = -1;
- DBusMessage *reply = NULL;
+
_cleanup_dbus_message_unref_
DBusMessage *reply = NULL;
Session *session = NULL;
User *user = NULL;
Seat *seat = NULL;
Session *session = NULL;
User *user = NULL;
Seat *seat = NULL;
@@
-536,6
+536,7
@@
static int bus_manager_create_session(Manager *m, DBusMessage *message, DBusMess
}
*_reply = reply;
}
*_reply = reply;
+ reply = NULL;
return 0;
}
return 0;
}
@@
-681,6
+682,7
@@
static int bus_manager_create_session(Manager *m, DBusMessage *message, DBusMess
}
*_reply = reply;
}
*_reply = reply;
+ reply = NULL;
return 0;
return 0;
@@
-691,9
+693,6
@@
fail:
if (user)
user_add_to_gc_queue(user);
if (user)
user_add_to_gc_queue(user);
- if (reply)
- dbus_message_unref(reply);
-
return r;
}
return r;
}
@@
-712,7
+711,7
@@
static int bus_manager_inhibit(
InhibitMode mm;
unsigned long ul;
int r, fifo_fd = -1;
InhibitMode mm;
unsigned long ul;
int r, fifo_fd = -1;
- DBusMessage *reply = NULL;
+
_cleanup_dbus_message_unref_
DBusMessage *reply = NULL;
assert(m);
assert(connection);
assert(m);
assert(connection);
@@
-833,6
+832,7
@@
static int bus_manager_inhibit(
close_nointr_nofail(fifo_fd);
*_reply = reply;
close_nointr_nofail(fifo_fd);
*_reply = reply;
+ reply = NULL;
inhibitor_start(i);
inhibitor_start(i);
@@
-845,9
+845,6
@@
fail:
if (fifo_fd >= 0)
close_nointr_nofail(fifo_fd);
if (fifo_fd >= 0)
close_nointr_nofail(fifo_fd);
- if (reply)
- dbus_message_unref(reply);
-
return r;
}
return r;
}
@@
-889,7
+886,7
@@
static int trigger_device(Manager *m, struct udev_device *d) {
goto finish;
}
goto finish;
}
- write_
one_line
_file(t, "change");
+ write_
string
_file(t, "change");
free(t);
}
free(t);
}
@@
-904,7
+901,7
@@
finish:
static int attach_device(Manager *m, const char *seat, const char *sysfs) {
struct udev_device *d;
static int attach_device(Manager *m, const char *seat, const char *sysfs) {
struct udev_device *d;
- char *rule = NULL, *file = NULL;
+ char
_cleanup_free_
*rule = NULL, *file = NULL;
const char *id_for_seat;
int r;
const char *id_for_seat;
int r;
@@
-939,16
+936,13
@@
static int attach_device(Manager *m, const char *seat, const char *sysfs) {
mkdir_p_label("/etc/udev/rules.d", 0755);
label_init("/etc");
mkdir_p_label("/etc/udev/rules.d", 0755);
label_init("/etc");
- r = write_
one_line
_file_atomic_label(file, rule);
+ r = write_
string
_file_atomic_label(file, rule);
if (r < 0)
goto finish;
r = trigger_device(m, d);
finish:
if (r < 0)
goto finish;
r = trigger_device(m, d);
finish:
- free(rule);
- free(file);
-
if (d)
udev_device_unref(d);
if (d)
udev_device_unref(d);
@@
-956,7
+950,7
@@
finish:
}
static int flush_devices(Manager *m) {
}
static int flush_devices(Manager *m) {
- DIR *d;
+ DIR
_cleanup_closedir_
*d;
assert(m);
assert(m);
@@
-981,8
+975,6
@@
static int flush_devices(Manager *m) {
if (unlinkat(dirfd(d), de->d_name, 0) < 0)
log_warning("Failed to unlink %s: %m", de->d_name);
}
if (unlinkat(dirfd(d), de->d_name, 0) < 0)
log_warning("Failed to unlink %s: %m", de->d_name);
}
-
- closedir(d);
}
return trigger_device(m, NULL);
}
return trigger_device(m, NULL);
@@
-1126,7
+1118,7
@@
static int bus_manager_can_shutdown_or_sleep(
bool multiple_sessions, challenge, blocked, b;
const char *result;
bool multiple_sessions, challenge, blocked, b;
const char *result;
- DBusMessage *reply = NULL;
+
_cleanup_dbus_message_unref_
DBusMessage *reply = NULL;
int r;
unsigned long ul;
int r;
unsigned long ul;
@@
-1225,12
+1217,11
@@
finish:
reply,
DBUS_TYPE_STRING, &result,
DBUS_TYPE_INVALID);
reply,
DBUS_TYPE_STRING, &result,
DBUS_TYPE_INVALID);
- if (!b) {
- dbus_message_unref(reply);
+ if (!b)
return -ENOMEM;
return -ENOMEM;
- }
*_reply = reply;
*_reply = reply;
+ reply = NULL;
return 0;
}
return 0;
}
@@
-1430,7
+1421,7
@@
static DBusHandlerResult manager_message_handler(
Manager *m = userdata;
DBusError error;
Manager *m = userdata;
DBusError error;
- DBusMessage *reply = NULL;
+
_cleanup_dbus_message_unref_
DBusMessage *reply = NULL;
int r;
assert(connection);
int r;
assert(connection);
@@
-2338,16
+2329,11
@@
static DBusHandlerResult manager_message_handler(
if (reply) {
if (!bus_maybe_send_reply(connection, message, reply))
goto oom;
if (reply) {
if (!bus_maybe_send_reply(connection, message, reply))
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;
@@
-2413,25
+2399,20
@@
DBusHandlerResult bus_message_filter(
}
int manager_send_changed(Manager *manager, const char *properties) {
}
int manager_send_changed(Manager *manager, const char *properties) {
- DBusMessage *m;
- int r = -ENOMEM;
+ _cleanup_dbus_message_unref_ DBusMessage *m = NULL;
assert(manager);
assert(manager);
- m = bus_properties_changed_new("/org/freedesktop/login1", "org.freedesktop.login1.Manager", properties);
+ m = bus_properties_changed_new("/org/freedesktop/login1",
+ "org.freedesktop.login1.Manager",
+ properties);
if (!m)
if (!m)
-
goto finish
;
+
return -ENOMEM
;
if (!dbus_connection_send(manager->bus, m, NULL))
if (!dbus_connection_send(manager->bus, m, NULL))
- goto finish;
-
- r = 0;
-
-finish:
- if (m)
- dbus_message_unref(m);
+ return -ENOMEM;
- return
r
;
+ return
0
;
}
int manager_dispatch_delayed(Manager *manager) {
}
int manager_dispatch_delayed(Manager *manager) {