Use the standard FOREACH_WORD* macros.
The current code was broken in the devlink case so the last one received
was being dropped, causing https://bugs.freedesktop.org/show_bug.cgi?id=89894
if (r < 0)
return log_debug_errno(r, "sd-device: could not set devgid to '%s': %m", value);
} else if (streq(key, "DEVLINKS")) {
if (r < 0)
return log_debug_errno(r, "sd-device: could not set devgid to '%s': %m", value);
} else if (streq(key, "DEVLINKS")) {
+ const char *word, *state;
+ size_t l;
- devlinks = strdupa(value);
+ FOREACH_WORD(word, l, value, state) {
+ char *devlink;
- while ((next = strchr(devlinks, ' '))) {
- next[0] = '\0';
+ devlink = strndupa(word, l);
- r = device_add_devlink(device, devlinks);
+ r = device_add_devlink(device, devlink);
- return log_debug_errno(r, "sd-device: could not add devlink '%s': %m", devlinks);
-
- devlinks = next + 1;
+ return log_debug_errno(r, "sd-device: could not add devlink '%s': %m", devlink);
}
} else if (streq(key, "TAGS")) {
}
} else if (streq(key, "TAGS")) {
+ const char *word, *state;
+ size_t l;
+ FOREACH_WORD_SEPARATOR(word, l, value, ":", state) {
+ char *tag;
- while ((next = strchr(tags, ':'))) {
- next[0] = '\0';
+ tag = strndupa(word, l);
- r = device_add_tag(device, tags);
+ r = device_add_tag(device, tag);
- return log_debug_errno(r, "sd-device: could not add tag '%s': %m", tags);
-
- tags = next + 1;
+ return log_debug_errno(r, "sd-device: could not add tag '%s': %m", tag);
}
} else {
r = device_add_property_internal(device, key, value);
}
} else {
r = device_add_property_internal(device, key, value);