summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-08-06 16:48:17 +0300
committerLennart Poettering <lennart@poettering.net>2015-08-06 16:54:00 +0300
commit491ac9f2c4aeda8c40edde35112404b737e38b60 (patch)
tree55a5dded7bd23a9e079a92de97c3c7628494b3a3
parent65d73cf042ba7de11d254f5c4714f467db64b7c3 (diff)
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.
-rw-r--r--src/login/logind-dbus.c24
-rw-r--r--src/login/logind-session.c5
-rw-r--r--src/login/logind.c4
-rw-r--r--src/machine/machine.c4
-rw-r--r--src/machine/machined-dbus.c3
5 files changed, 15 insertions, 25 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index cc1b868f51..992a9f5b4a 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -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);
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index fc92f7f73b..e75c7c042e 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -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) {
diff --git a/src/login/logind.c b/src/login/logind.c
index 49a2811842..cf71c0ec5a 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -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);
diff --git a/src/machine/machine.c b/src/machine/machine.c
index ab26803683..4fd56a11ae 100644
--- a/src/machine/machine.c
+++ b/src/machine/machine.c
@@ -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) {
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c
index b1f5aebe0c..49f41c62d7 100644
--- a/src/machine/machined-dbus.c
+++ b/src/machine/machined-dbus.c
@@ -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"))