summaryrefslogtreecommitdiffstats
path: root/common/env.c
diff options
context:
space:
mode:
authorSascha Hauer <sha@octopus.labnet.pengutronix.de>2007-09-13 16:06:02 +0200
committerSascha Hauer <sha@octopus.labnet.pengutronix.de>2007-09-13 16:06:02 +0200
commit2a9c1de93fd9e74a79cc3fc66331d02797a98329 (patch)
treed8355e5597ef542d97b13d6758545f2528bdf48a /common/env.c
parent8c42a8f67c8ac14affd18c33e996b09197076f5e (diff)
downloadbarebox-2a9c1de93fd9e74a79cc3fc66331d02797a98329.tar.gz
whitespace cleanup
Diffstat (limited to 'common/env.c')
-rw-r--r--common/env.c110
1 files changed, 55 insertions, 55 deletions
diff --git a/common/env.c b/common/env.c
index 4bd0dee..b481854 100644
--- a/common/env.c
+++ b/common/env.c
@@ -28,8 +28,8 @@
#include <errno.h>
struct variable_d {
- struct variable_d *next;
- char data[0];
+ struct variable_d *next;
+ char data[0];
};
#define VARIABLE_D_SIZE(name, value) (sizeof(struct variable_d) + strlen(name) + strlen(value) + 2)
@@ -39,17 +39,17 @@ static struct variable_d *env_list = &_env_list;
static char *var_val(struct variable_d *var)
{
- return &var->data[strlen(var->data) + 1];
+ return &var->data[strlen(var->data) + 1];
}
static char *var_name(struct variable_d *var)
{
- return var->data;
+ return var->data;
}
const char *getenv (const char *name)
{
- struct variable_d *var;
+ struct variable_d *var;
if (strchr(name, '.')) {
const char *ret = 0;
@@ -66,11 +66,11 @@ const char *getenv (const char *name)
return ret;
}
- var = env_list->next;
+ var = env_list->next;
- while (var) {
- if (!strcmp(var_name(var), name))
- return var_val(var);
+ while (var) {
+ if (!strcmp(var_name(var), name))
+ return var_val(var);
var = var->next;
}
return 0;
@@ -78,8 +78,8 @@ const char *getenv (const char *name)
int setenv (const char *name, const char *value)
{
- struct variable_d *var = env_list;
- struct variable_d *newvar = NULL;
+ struct variable_d *var = env_list;
+ struct variable_d *newvar = NULL;
char *par;
if ((par = strchr(name, '.'))) {
@@ -92,60 +92,60 @@ int setenv (const char *name, const char *value)
perror("set parameter");
errno = 0;
} else {
- errno = -ENODEV;
- perror("set parameter");
- }
+ errno = -ENODEV;
+ perror("set parameter");
+ }
return errno;
}
- if (value) {
- newvar = xzalloc(VARIABLE_D_SIZE(name, value));
- strcpy(&newvar->data[0], name);
- strcpy(&newvar->data[strlen(name) + 1], value);
- }
-
- while (var->next) {
- if (!strcmp(var->next->data, name)) {
- if (value) {
- newvar->next = var->next->next;
- free(var->next);
- var->next = newvar;
- return 0;
- } else {
- struct variable_d *tmp;
- tmp = var->next;
- var->next = var->next->next;
- free(var->next);
- return 0;
- }
- }
- var = var->next;
- }
- var->next = newvar;
+ if (value) {
+ newvar = xzalloc(VARIABLE_D_SIZE(name, value));
+ strcpy(&newvar->data[0], name);
+ strcpy(&newvar->data[strlen(name) + 1], value);
+ }
+
+ while (var->next) {
+ if (!strcmp(var->next->data, name)) {
+ if (value) {
+ newvar->next = var->next->next;
+ free(var->next);
+ var->next = newvar;
+ return 0;
+ } else {
+ struct variable_d *tmp;
+ tmp = var->next;
+ var->next = var->next->next;
+ free(var->next);
+ return 0;
+ }
+ }
+ var = var->next;
+ }
+ var->next = newvar;
return 0;
}
int do_printenv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
- struct variable_d *var = env_list->next;
+ struct variable_d *var = env_list->next;
if (argc == 2) {
- const char *val = getenv(argv[1]);
- if (val) {
- printf("%s=%s\n", argv[1], val);
- return 0;
- }
- printf("## Error: \"%s\" not defined\n", argv[1]);
- return -EINVAL;
- }
-
- while (var) {
- printf("%s=%s\n", var_name(var), var_val(var));
- var = var->next;
- }
-
- return 0;
+ const char *val = getenv(argv[1]);
+ if (val) {
+ printf("%s=%s\n", argv[1], val);
+ return 0;
+ }
+ printf("## Error: \"%s\" not defined\n", argv[1]);
+ return -EINVAL;
+ }
+
+ while (var) {
+ printf("%s=%s\n", var_name(var), var_val(var));
+ var = var->next;
+ }
+
+ return 0;
}
U_BOOT_CMD_START(printenv)
@@ -168,7 +168,7 @@ int do_setenv ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
setenv(argv[1], argv[2]);
- return 0;
+ return 0;
}
U_BOOT_CMD_START(setenv)