summaryrefslogtreecommitdiffstats
path: root/src/core/device.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-10-26 16:40:35 +0200
committerLennart Poettering <lennart@poettering.net>2017-11-10 19:45:29 +0100
commitde04054349713eb10757ad1de447f41941942447 (patch)
tree11d51bfc86c5c335c9187c74d3c1d59e0af36b4a /src/core/device.c
parentcore: add internal API to remove dependencies again, based on dependency mask (diff)
downloadsystemd-de04054349713eb10757ad1de447f41941942447.tar.xz
systemd-de04054349713eb10757ad1de447f41941942447.zip
device: Let's simplify device_add_udev_wants() a bit
Let's drop use of one variable and make the rest more explicit.
Diffstat (limited to 'src/core/device.c')
-rw-r--r--src/core/device.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/core/device.c b/src/core/device.c
index ad101a4197..565292605a 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -256,18 +256,22 @@ static int device_update_description(Unit *u, struct udev_device *dev, const cha
}
static int device_add_udev_wants(Unit *u, struct udev_device *dev) {
- const char *wants, *property, *p;
+ const char *wants, *property;
int r;
assert(u);
assert(dev);
property = MANAGER_IS_USER(u->manager) ? "SYSTEMD_USER_WANTS" : "SYSTEMD_WANTS";
+
wants = udev_device_get_property_value(dev, property);
- for (p = wants;;) {
+ if (!wants)
+ return 0;
+
+ for (;;) {
_cleanup_free_ char *word = NULL, *k = NULL;
- r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES);
+ r = extract_first_word(&wants, &word, NULL, EXTRACT_QUOTES);
if (r == 0)
return 0;
if (r == -ENOMEM)
@@ -281,7 +285,7 @@ static int device_add_udev_wants(Unit *u, struct udev_device *dev) {
r = unit_add_dependency_by_name(u, UNIT_WANTS, k, NULL, true, UNIT_DEPENDENCY_UDEV);
if (r < 0)
- return log_unit_error_errno(u, r, "Failed to add wants dependency: %m");
+ return log_unit_error_errno(u, r, "Failed to add Wants= dependency: %m");
}
}