logind,machined: various smaller cleanups

Use mfree() where we can.

Drop unnecessary {}.

Drop unnecessary variable declarations.

Cast syscall invocations where explicitly don't care for the return
value to (void).

Reword a comment.
This commit is contained in:
Lennart Poettering 2015-08-06 16:48:17 +03:00
parent 65d73cf042
commit 491ac9f2c4
5 changed files with 15 additions and 25 deletions

View File

@ -2520,8 +2520,7 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
/* Tell people that they now may take a lock again */
send_prepare_for(m, m->action_what, false);
free(m->action_job);
m->action_job = NULL;
m->action_job = mfree(m->action_job);
m->action_unit = NULL;
m->action_what = 0;
return 0;
@ -2530,10 +2529,8 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
session = hashmap_get(m->session_units, unit);
if (session) {
if (streq_ptr(path, session->scope_job)) {
free(session->scope_job);
session->scope_job = NULL;
}
if (streq_ptr(path, session->scope_job))
session->scope_job = mfree(session->scope_job);
session_jobs_reply(session, unit, result);
@ -2545,19 +2542,14 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
user = hashmap_get(m->user_units, unit);
if (user) {
if (streq_ptr(path, user->service_job)) {
free(user->service_job);
user->service_job = NULL;
}
if (streq_ptr(path, user->service_job))
user->service_job = mfree(user->service_job);
if (streq_ptr(path, user->slice_job)) {
free(user->slice_job);
user->slice_job = NULL;
}
if (streq_ptr(path, user->slice_job))
user->slice_job = mfree(user->slice_job);
LIST_FOREACH(sessions_by_user, session, user->sessions) {
LIST_FOREACH(sessions_by_user, session, user->sessions)
session_jobs_reply(session, unit, result);
}
user_save(user);
user_add_to_gc_queue(user);

View File

@ -656,7 +656,6 @@ int session_stop(Session *s, bool force) {
}
int session_finalize(Session *s) {
int r = 0;
SessionDevice *sd;
assert(s);
@ -682,7 +681,7 @@ int session_finalize(Session *s) {
while ((sd = hashmap_first(s->devices)))
session_device_free(sd);
unlink(s->state_file);
(void) unlink(s->state_file);
session_add_to_gc_queue(s);
user_add_to_gc_queue(s->user);
@ -702,7 +701,7 @@ int session_finalize(Session *s) {
user_save(s->user);
user_send_changed(s->user, "Sessions", "Display", NULL);
return r;
return 0;
}
static int release_timeout_callback(sd_event_source *es, uint64_t usec, void *userdata) {

View File

@ -907,8 +907,8 @@ static void manager_gc(Manager *m, bool drop_not_started) {
session_get_state(session) != SESSION_CLOSING)
session_stop(session, false);
/* Normally, this should make the session busy again,
* if it doesn't then let's get rid of it
/* Normally, this should make the session referenced
* again, if it doesn't then let's get rid of it
* immediately */
if (!session_check_gc(session, drop_not_started)) {
session_finalize(session);

View File

@ -231,11 +231,11 @@ static void machine_unlink(Machine *m) {
char *sl;
sl = strjoina("/run/systemd/machines/unit:", m->unit);
unlink(sl);
(void) unlink(sl);
}
if (m->state_file)
unlink(m->state_file);
(void) unlink(m->state_file);
}
int machine_load(Machine *m) {

View File

@ -1124,8 +1124,7 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
return 0;
if (streq_ptr(path, machine->scope_job)) {
free(machine->scope_job);
machine->scope_job = NULL;
machine->scope_job = mfree(machine->scope_job);
if (machine->started) {
if (streq(result, "done"))