From: Yu Watanabe Date: Mon, 29 Oct 2018 06:24:14 +0000 (+0900) Subject: udev-rules: make import_property_from_string() take sd_device X-Git-Tag: v240~392^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=29b5eb5adf081fd599713ab577fb9ab034ea57e5;p=thirdparty%2Fsystemd.git udev-rules: make import_property_from_string() take sd_device Also, this makes the function return negative errno, though its return value is always ignored. --- diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index cf1c44236f3..5c046ea838f 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -16,6 +16,7 @@ #include "alloc-util.h" #include "conf-files.h" #include "def.h" +#include "device-private.h" #include "device-util.h" #include "dirent-util.h" #include "escape.h" @@ -557,7 +558,7 @@ static gid_t add_gid(struct udev_rules *rules, const char *group) { return gid; } -static int import_property_from_string(struct udev_device *dev, char *line) { +static int import_property_from_string(sd_device *dev, char *line) { char *key; char *val; size_t len; @@ -569,12 +570,12 @@ static int import_property_from_string(struct udev_device *dev, char *line) { /* comment or empty line */ if (IN_SET(key[0], '#', '\0')) - return -1; + return 0; /* split key/value */ val = strchr(key, '='); - if (val == NULL) - return -1; + if (!val) + return -EINVAL; val[0] = '\0'; val++; @@ -585,7 +586,7 @@ static int import_property_from_string(struct udev_device *dev, char *line) { /* terminate key */ len = strlen(key); if (len == 0) - return -1; + return -EINVAL; while (isspace(key[len-1])) len--; key[len] = '\0'; @@ -593,27 +594,25 @@ static int import_property_from_string(struct udev_device *dev, char *line) { /* terminate value */ len = strlen(val); if (len == 0) - return -1; + return -EINVAL; while (isspace(val[len-1])) len--; val[len] = '\0'; if (len == 0) - return -1; + return -EINVAL; /* unquote */ if (IN_SET(val[0], '"', '\'')) { if (len == 1 || val[len-1] != val[0]) { log_debug("inconsistent quoting: '%s', skip", line); - return -1; + return -EINVAL; } val[len-1] = '\0'; val++; } - udev_device_add_property(dev, key, val); - - return 0; + return device_add_property(dev, key, val); } static int import_file_into_properties(struct udev_device *dev, const char *filename) { @@ -633,7 +632,7 @@ static int import_file_into_properties(struct udev_device *dev, const char *file if (r == 0) break; - (void) import_property_from_string(dev, line); + (void) import_property_from_string(dev->device, line); } return 0; @@ -660,7 +659,7 @@ static int import_program_into_properties(struct udev_event *event, pos[0] = '\0'; pos = &pos[1]; } - (void) import_property_from_string(event->dev, line); + (void) import_property_from_string(event->dev->device, line); line = pos; } return 0;