1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-12 13:18:14 +03:00

apply format char to variables exported by ENV

This commit is contained in:
Kay Sievers 2006-04-15 19:32:05 +02:00
parent 0c4a805bcc
commit 7ba2d2e6ae
4 changed files with 18 additions and 20 deletions

4
udev.h
View File

@ -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);

View File

@ -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] = "";

View File

@ -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);
}
}

View File

@ -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)