chiark / gitweb /
build-sys: fix build regarding SYSTEM_SYSVRCND_PATH
[elogind.git] / device.c
index c5901c95ff67697973ed4d22bc7bb65ddb1f5a9b..5739af9e1a5afe10af8c6965b6d5c782969fad71 100644 (file)
--- a/device.c
+++ b/device.c
@@ -162,9 +162,12 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u
                 }
 
                 if ((model = udev_device_get_property_value(dev, "ID_MODEL_FROM_DATABASE")) ||
-                    (model = udev_device_get_property_value(dev, "ID_MODEL")))
+                    (model = udev_device_get_property_value(dev, "ID_MODEL"))) {
                         if ((r = unit_set_description(u, model)) < 0)
                                 goto fail;
+                } else if (dn)
+                        if ((r = unit_set_description(u, dn)) < 0)
+                                goto fail;
 
                 unit_add_to_load_queue(u);
         } else {
@@ -183,8 +186,10 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u
 
         if (names) {
                 FOREACH_WORD(w, l, names, state) {
-                        if (!(e = strndup(w, l)))
+                        if (!(e = strndup(w, l))) {
+                                r = -ENOMEM;
                                 goto fail;
+                        }
 
                         r = unit_add_name(u, e);
                         free(e);
@@ -196,8 +201,10 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u
 
         if (wants) {
                 FOREACH_WORD(w, l, wants, state) {
-                        if (!(e = strndup(w, l)))
+                        if (!(e = strndup(w, l))) {
+                                r = -ENOMEM;
                                 goto fail;
+                        }
 
                         r = unit_add_dependency_by_name(u, UNIT_WANTS, e);
                         free(e);
@@ -343,8 +350,6 @@ void device_fd_event(Manager *m, int events) {
         assert(m);
         assert(events == EPOLLIN);
 
-        log_debug("got udev event");
-
         if (!(dev = udev_monitor_receive_device(m->udev_monitor))) {
                 log_error("Failed to receive device.");
                 return;
@@ -374,7 +379,7 @@ fail:
 const UnitVTable device_vtable = {
         .suffix = ".device",
 
-        .init = unit_load_fragment_and_dropin,
+        .init = unit_load_fragment_and_dropin_optional,
         .done = device_done,
         .coldplug = device_coldplug,