mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
logind-session-dbus: use _cleanup_
This commit is contained in:
parent
80e52052db
commit
360179ea46
@ -424,7 +424,7 @@ static int method_set_display(sd_bus_message *message, void *userdata, sd_bus_er
|
|||||||
static int method_take_device(sd_bus_message *message, void *userdata, sd_bus_error *error) {
|
static int method_take_device(sd_bus_message *message, void *userdata, sd_bus_error *error) {
|
||||||
Session *s = ASSERT_PTR(userdata);
|
Session *s = ASSERT_PTR(userdata);
|
||||||
uint32_t major, minor;
|
uint32_t major, minor;
|
||||||
SessionDevice *sd;
|
_cleanup_(session_device_freep) SessionDevice *sd = NULL;
|
||||||
dev_t dev;
|
dev_t dev;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -456,18 +456,16 @@ static int method_take_device(sd_bus_message *message, void *userdata, sd_bus_er
|
|||||||
|
|
||||||
r = session_device_save(sd);
|
r = session_device_save(sd);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto error;
|
return r;
|
||||||
|
|
||||||
r = sd_bus_reply_method_return(message, "hb", sd->fd, !sd->active);
|
r = sd_bus_reply_method_return(message, "hb", sd->fd, !sd->active);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto error;
|
return r;
|
||||||
|
|
||||||
session_save(s);
|
session_save(s);
|
||||||
return 1;
|
TAKE_PTR(sd);
|
||||||
|
|
||||||
error:
|
return 1;
|
||||||
session_device_free(sd);
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int method_release_device(sd_bus_message *message, void *userdata, sd_bus_error *error) {
|
static int method_release_device(sd_bus_message *message, void *userdata, sd_bus_error *error) {
|
||||||
|
@ -29,6 +29,8 @@ struct SessionDevice {
|
|||||||
|
|
||||||
int session_device_new(Session *s, dev_t dev, bool open_device, SessionDevice **out);
|
int session_device_new(Session *s, dev_t dev, bool open_device, SessionDevice **out);
|
||||||
SessionDevice *session_device_free(SessionDevice *sd);
|
SessionDevice *session_device_free(SessionDevice *sd);
|
||||||
|
DEFINE_TRIVIAL_CLEANUP_FUNC(SessionDevice*, session_device_free);
|
||||||
|
|
||||||
void session_device_complete_pause(SessionDevice *sd);
|
void session_device_complete_pause(SessionDevice *sd);
|
||||||
|
|
||||||
void session_device_resume_all(Session *s);
|
void session_device_resume_all(Session *s);
|
||||||
|
Loading…
Reference in New Issue
Block a user