]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/machine/machine.c
tree-wide: use mfree more
[thirdparty/systemd.git] / src / machine / machine.c
index 406d5a4b854dc6273b8904db16fb5d4b3298e45c..a02b9d7575f4c98fec8711758fc63772049742d0 100644 (file)
@@ -80,16 +80,14 @@ Machine* machine_new(Manager *manager, MachineClass class, const char *name) {
 fail:
         free(m->state_file);
         free(m->name);
-        free(m);
-
-        return NULL;
+        return mfree(m);
 }
 
 void machine_free(Machine *m) {
         assert(m);
 
         while (m->operations)
-                machine_operation_unref(m->operations);
+                operation_free(m->operations);
 
         if (m->in_gc_queue)
                 LIST_REMOVE(gc_queue, m->manager->machine_gc_queue, m);
@@ -181,7 +179,7 @@ int machine_save(Machine *m) {
                 fprintf(f, "ROOT=%s\n", escaped);
         }
 
-        if (!sd_id128_equal(m->id, SD_ID128_NULL))
+        if (!sd_id128_is_null(m->id))
                 fprintf(f, "ID=" SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(m->id));
 
         if (m->leader != 0)
@@ -299,17 +297,10 @@ int machine_load(Machine *m) {
                         m->class = c;
         }
 
-        if (realtime) {
-                unsigned long long l;
-                if (sscanf(realtime, "%llu", &l) > 0)
-                        m->timestamp.realtime = l;
-        }
-
-        if (monotonic) {
-                unsigned long long l;
-                if (sscanf(monotonic, "%llu", &l) > 0)
-                        m->timestamp.monotonic = l;
-        }
+        if (realtime)
+                timestamp_deserialize(realtime, &m->timestamp.realtime);
+        if (monotonic)
+                timestamp_deserialize(monotonic, &m->timestamp.monotonic);
 
         if (netif) {
                 size_t allocated = 0, nr = 0;
@@ -317,7 +308,7 @@ int machine_load(Machine *m) {
                 int *ni = NULL;
 
                 p = netif;
-                for(;;) {
+                for (;;) {
                         _cleanup_free_ char *word = NULL;
                         int ifi;
 
@@ -603,28 +594,6 @@ int machine_open_terminal(Machine *m, const char *path, int mode) {
         }
 }
 
-MachineOperation *machine_operation_unref(MachineOperation *o) {
-        if (!o)
-                return NULL;
-
-        sd_event_source_unref(o->event_source);
-
-        safe_close(o->errno_fd);
-
-        if (o->pid > 1)
-                (void) kill(o->pid, SIGKILL);
-
-        sd_bus_message_unref(o->message);
-
-        if (o->machine) {
-                LIST_REMOVE(operations, o->machine->operations, o);
-                o->machine->n_operations--;
-        }
-
-        free(o);
-        return NULL;
-}
-
 void machine_release_unit(Machine *m) {
         assert(m);