diff options
-rw-r--r-- | udev.h | 4 | ||||
-rw-r--r-- | udev_node.c | 1 | ||||
-rw-r--r-- | udev_rules.c | 9 | ||||
-rw-r--r-- | udev_utils.c | 24 |
4 files changed, 18 insertions, 20 deletions
@@ -136,8 +136,8 @@ struct name_entry { char name[PATH_SIZE]; }; extern int log_priority(const char *priority); -extern int name_list_add(struct list_head *name_list, const char *name, int sort); -extern int name_list_key_add(struct list_head *name_list, const char *key, const char *value); +extern char *name_list_add(struct list_head *name_list, const char *name, int sort); +extern char *name_list_key_add(struct list_head *name_list, const char *key, const char *value); extern void name_list_cleanup(struct list_head *name_list); extern int add_matching_files(struct list_head *name_list, const char *dirname, const char *suffix); diff --git a/udev_node.c b/udev_node.c index d2889a329e..86fdcd3a41 100644 --- a/udev_node.c +++ b/udev_node.c @@ -231,7 +231,6 @@ void udev_node_remove_symlinks(struct udevice *udev) char filename[PATH_SIZE]; struct name_entry *name_loop; struct stat stats; - int retval; if (!list_empty(&udev->symlink_list)) { char symlinks[512] = ""; diff --git a/udev_rules.c b/udev_rules.c index 623ca46858..5b1e6889ec 100644 --- a/udev_rules.c +++ b/udev_rules.c @@ -903,10 +903,13 @@ try_parent: if (pair->key.operation == KEY_OP_ASSIGN) { const char *key_name = key_pair_name(rule, pair); const char *value = key_val(rule, &pair->key); + char *key_value = name_list_key_add(&udev->env_list, key_name, value); + if (key_value == NULL) + break; - name_list_key_add(&udev->env_list, key_name, value); - setenv(key_name, value, 1); - dbg("export ENV '%s=%s'", key_name, value); + udev_rules_apply_format(udev, key_value, NAME_SIZE); + putenv(key_value); + dbg("export ENV '%s'", key_value); } } diff --git a/udev_utils.c b/udev_utils.c index a37c4dfe74..003d7bded9 100644 --- a/udev_utils.c +++ b/udev_utils.c @@ -53,7 +53,7 @@ int log_priority(const char *priority) return 0; } -int name_list_add(struct list_head *name_list, const char *name, int sort) +char *name_list_add(struct list_head *name_list, const char *name, int sort) { struct name_entry *loop_name; struct name_entry *new_name; @@ -62,7 +62,7 @@ int name_list_add(struct list_head *name_list, const char *name, int sort) /* avoid doubles */ if (strcmp(loop_name->name, name) == 0) { dbg("'%s' is already in the list", name); - return 0; + return loop_name->name; } } @@ -73,19 +73,17 @@ int name_list_add(struct list_head *name_list, const char *name, int sort) } new_name = malloc(sizeof(struct name_entry)); - if (new_name == NULL) { - dbg("error malloc"); - return -ENOMEM; - } + if (new_name == NULL) + return NULL; strlcpy(new_name->name, name, sizeof(new_name->name)); dbg("adding '%s'", new_name->name); list_add_tail(&new_name->node, &loop_name->node); - return 0; + return new_name->name; } -int name_list_key_add(struct list_head *name_list, const char *key, const char *value) +char *name_list_key_add(struct list_head *name_list, const char *key, const char *value) { struct name_entry *loop_name; struct name_entry *new_name; @@ -95,22 +93,20 @@ int name_list_key_add(struct list_head *name_list, const char *key, const char * dbg("key already present '%s', replace it", loop_name->name); snprintf(loop_name->name, sizeof(loop_name->name), "%s=%s", key, value); loop_name->name[sizeof(loop_name->name)-1] = '\0'; - return 0; + return loop_name->name; } } new_name = malloc(sizeof(struct name_entry)); - if (new_name == NULL) { - dbg("error malloc"); - return -ENOMEM; - } + if (new_name == NULL) + return NULL; snprintf(new_name->name, sizeof(new_name->name), "%s=%s", key, value); new_name->name[sizeof(new_name->name)-1] = '\0'; dbg("adding '%s'", new_name->name); list_add_tail(&new_name->node, &loop_name->node); - return 0; + return new_name->name; } void name_list_cleanup(struct list_head *name_list) |