X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fdevice.c;h=9fca82ab169f52dd341b42b1176ec35ea09ec326;hb=da7e457c5b9339721454ae8401a03ffdd781e6a9;hp=fb948688b66650875e37adb6baf3f290abd1fa2d;hpb=b92bea5d2a9481de69bb627a7b442a9f58fca43d;p=elogind.git diff --git a/src/core/device.c b/src/core/device.c index fb948688b..9fca82ab1 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -124,13 +124,13 @@ static void device_dump(Unit *u, FILE *f, const char *prefix) { prefix, strna(d->sysfs)); } -static UnitActiveState device_active_state(Unit *u) { +_pure_ static UnitActiveState device_active_state(Unit *u) { assert(u); return state_translation_table[DEVICE(u)->state]; } -static const char *device_sub_state_to_string(Unit *u) { +_pure_ static const char *device_sub_state_to_string(Unit *u) { assert(u); return device_state_to_string(DEVICE(u)->state); @@ -281,16 +281,22 @@ static int device_update_unit(Manager *m, struct udev_device *dev, const char *p size_t l; FOREACH_WORD_QUOTED(w, l, wants, state) { - char *e; + char *e, *n; e = strndup(w, l); if (!e) { r = -ENOMEM; goto fail; } - - r = unit_add_dependency_by_name(u, UNIT_WANTS, e, NULL, true); + n = unit_name_mangle(e); + if (!n) { + r = -ENOMEM; + goto fail; + } free(e); + + r = unit_add_dependency_by_name(u, UNIT_WANTS, n, NULL, true); + free(n); if (r < 0) goto fail; } @@ -312,6 +318,7 @@ fail: static int device_process_new_device(Manager *m, struct udev_device *dev, bool update_state) { const char *sysfs, *dn; struct udev_list_entry *item = NULL, *first = NULL; + int r; assert(m); @@ -319,7 +326,9 @@ static int device_process_new_device(Manager *m, struct udev_device *dev, bool u return -ENOMEM; /* Add the main unit named after the sysfs path */ - device_update_unit(m, dev, sysfs, true); + r = device_update_unit(m, dev, sysfs, true); + if (r < 0) + return r; /* Add an additional unit for the device node */ if ((dn = udev_device_get_devnode(dev)))