]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/core/device.c
util-lib: split our string related calls from util.[ch] into its own file string...
[thirdparty/systemd.git] / src / core / device.c
index e7efcf0f0a755b8a50cb32c840f5889f2b70966f..9127d2d225285e7d80f076a7ce7696cca5018bf4 100644 (file)
 
 #include <errno.h>
 #include <sys/epoll.h>
-#include <libudev.h>
 
-#include "log.h"
-#include "unit-name.h"
+#include "libudev.h"
+
 #include "dbus-device.h"
+#include "log.h"
 #include "path-util.h"
+#include "string-util.h"
+#include "swap.h"
 #include "udev-util.h"
+#include "unit-name.h"
 #include "unit.h"
-#include "swap.h"
 #include "device.h"
 
 static const UnitActiveState state_translation_table[_DEVICE_STATE_MAX] = {
@@ -60,8 +62,7 @@ static void device_unset_sysfs(Device *d) {
         else
                 hashmap_remove(devices, d->sysfs);
 
-        free(d->sysfs);
-        d->sysfs = NULL;
+        d->sysfs = mfree(d->sysfs);
 }
 
 static int device_set_sysfs(Device *d, const char *sysfs) {
@@ -595,8 +596,7 @@ static void device_shutdown(Manager *m) {
                 m->udev_monitor = NULL;
         }
 
-        hashmap_free(m->devices_by_sysfs);
-        m->devices_by_sysfs = NULL;
+        m->devices_by_sysfs = hashmap_free(m->devices_by_sysfs);
 }
 
 static int device_enumerate(Manager *m) {
@@ -818,14 +818,6 @@ int device_found_node(Manager *m, const char *node, bool add, DeviceFound found,
         return device_update_found_by_name(m, node, add, found, now);
 }
 
-static const char* const device_state_table[_DEVICE_STATE_MAX] = {
-        [DEVICE_DEAD] = "dead",
-        [DEVICE_TENTATIVE] = "tentative",
-        [DEVICE_PLUGGED] = "plugged",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(device_state, DeviceState);
-
 const UnitVTable device_vtable = {
         .object_size = sizeof(Device),
         .sections =
@@ -849,7 +841,6 @@ const UnitVTable device_vtable = {
         .active_state = device_active_state,
         .sub_state_to_string = device_sub_state_to_string,
 
-        .bus_interface = "org.freedesktop.systemd1.Device",
         .bus_vtable = bus_device_vtable,
 
         .following = device_following,