summaryrefslogtreecommitdiffstats
path: root/commands/printenv.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 /commands/printenv.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 'commands/printenv.c')
-rw-r--r--commands/printenv.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/commands/printenv.c b/commands/printenv.c
index b18c7a1..10e882a 100644
--- a/commands/printenv.c
+++ b/commands/printenv.c
@@ -27,8 +27,8 @@
static int do_printenv(int argc, char *argv[])
{
- struct variable_d *var;
- struct env_context *c, *current_c;
+ struct variable_d *v;
+ struct env_context *c;
if (argc == 2) {
const char *val = getenv(argv[1]);
@@ -40,22 +40,16 @@ static int do_printenv(int argc, char *argv[])
return 1;
}
- current_c = get_current_context();
- var = current_c->local->next;
+ c = get_current_context();
printf("locals:\n");
- while (var) {
- printf("%s=%s\n", var_name(var), var_val(var));
- var = var->next;
- }
+ list_for_each_entry(v, &c->local, list)
+ printf("%s=%s\n", var_name(v), var_val(v));
printf("globals:\n");
c = get_current_context();
- while(c) {
- var = c->global->next;
- while (var) {
- printf("%s=%s\n", var_name(var), var_val(var));
- var = var->next;
- }
+ while (c) {
+ list_for_each_entry(v, &c->global, list)
+ printf("%s=%s\n", var_name(v), var_val(v));
c = c->parent;
}