]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind,machined: various smaller cleanups
authorLennart Poettering <lennart@poettering.net>
Thu, 6 Aug 2015 13:48:17 +0000 (16:48 +0300)
committerLennart Poettering <lennart@poettering.net>
Thu, 6 Aug 2015 13:54:00 +0000 (16:54 +0300)
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.

src/login/logind-dbus.c
src/login/logind-session.c
src/login/logind.c
src/machine/machine.c
src/machine/machined-dbus.c

index cc1b868f51436d66387b46263d0159b4e6b5a758..992a9f5b4aae9d2baf15f6acb85da13fa4889762 100644 (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);
index fc92f7f73ba24ac3b986d6370c9f9933d0789605..e75c7c042e4cb8c500caace8b60ff0b8f55975b6 100644 (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) {
index 49a2811842668b1507a2e1915b096cfa226f53af..cf71c0ec5a4c8ccbad96493d0816a97b89d0abe7 100644 (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);
index ab26803683ec9b2dc433ff9ea4aafebf52cdb191..4fd56a11ae9d86ef3ea71dc69976fde2312fa829 100644 (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) {
index b1f5aebe0cb04b2551df7121c52be06c17740cde..49f41c62d7a49f183408f0975df51cbdf470d290 100644 (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"))