summaryrefslogtreecommitdiffstats
path: root/common/complete.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-10-14 13:39:10 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-10-30 10:24:12 +0100
commit87feda4eb17229ec10dbc919cf3ee3d39959037b (patch)
treeb23819854709bdcb943a2651bb59868e2d4f6ad4 /common/complete.c
parent19bd0bc9dbe40e4953adeabd3efa2846489b1700 (diff)
downloadbarebox-87feda4eb17229ec10dbc919cf3ee3d39959037b.tar.gz
environment variables: use linux list
This switches environment variables to use linux list. This is easier to read. An additional plus is that the environment variables no longer need an initcall, so malloc is the only requirement for them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/complete.c')
-rw-r--r--common/complete.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/common/complete.c b/common/complete.c
index 32d0d19..9206ef0 100644
--- a/common/complete.c
+++ b/common/complete.c
@@ -208,7 +208,7 @@ static int env_param_complete(struct string_list *sl, char *instr, int eval)
{
struct device_d *dev;
struct variable_d *var;
- struct env_context *c, *current_c;
+ struct env_context *c;
char *instr_param;
int len;
char end = '=';
@@ -225,21 +225,23 @@ static int env_param_complete(struct string_list *sl, char *instr, int eval)
instr_param = strchr(instr, '.');
len = strlen(instr);
- current_c = get_current_context();
- for(var = current_c->local->next; var; var = var->next) {
+ c = get_current_context();
+ list_for_each_entry(var, &c->local, list) {
if (strncmp(instr, var_name(var), len))
continue;
string_list_add_asprintf(sl, "%s%s%c",
begin, var_name(var), end);
}
- for (c = get_current_context(); c; c = c->parent) {
- for (var = c->global->next; var; var = var->next) {
+ c = get_current_context();
+ while (c) {
+ list_for_each_entry(var, &c->global, list) {
if (strncmp(instr, var_name(var), len))
continue;
string_list_add_asprintf(sl, "%s%s%c",
begin, var_name(var), end);
}
+ c = c->parent;
}
if (instr_param) {