Skip to content

Commit

Permalink
logind-session-device: modernize session_device_free()
Browse files Browse the repository at this point in the history
  • Loading branch information
dtardon committed Apr 28, 2023
1 parent fc44792 commit 80e5205
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/login/logind-session-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,9 @@ int session_device_new(Session *s, dev_t dev, bool open_device, SessionDevice **
return r;
}

void session_device_free(SessionDevice *sd) {
assert(sd);
SessionDevice *session_device_free(SessionDevice *sd) {
if (!sd)
return NULL;

/* Make sure to remove the pushed fd. */
if (sd->pushed_fd)
Expand All @@ -391,7 +392,8 @@ void session_device_free(SessionDevice *sd) {
hashmap_remove(sd->session->devices, &sd->dev);

free(sd->node);
free(sd);

return mfree(sd);
}

void session_device_complete_pause(SessionDevice *sd) {
Expand Down
2 changes: 1 addition & 1 deletion src/login/logind-session-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct SessionDevice {
};

int session_device_new(Session *s, dev_t dev, bool open_device, SessionDevice **out);
void session_device_free(SessionDevice *sd);
SessionDevice *session_device_free(SessionDevice *sd);
void session_device_complete_pause(SessionDevice *sd);

void session_device_resume_all(Session *s);
Expand Down

0 comments on commit 80e5205

Please sign in to comment.