Skip to content

Commit b9ca02c

Browse files
sjg20trini
authored andcommitted
env: Move envmatch() to env.h
Move envmatch() over to the new header file. Also rename it to env_match() to better line up with other functions. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
1 parent 3f989e7 commit b9ca02c

4 files changed

Lines changed: 15 additions & 14 deletions

File tree

cmd/nvedit.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ int env_get_f(const char *name, char *buf, unsigned len)
709709
return -1;
710710
}
711711

712-
val = envmatch((uchar *)name, i);
712+
val = env_match((uchar *)name, i);
713713
if (val < 0)
714714
continue;
715715

@@ -785,15 +785,7 @@ U_BOOT_CMD(
785785
#endif
786786
#endif /* CONFIG_SPL_BUILD */
787787

788-
789-
/*
790-
* Match a name / name=value pair
791-
*
792-
* s1 is either a simple 'name', or a 'name=value' pair.
793-
* i2 is the environment index for a 'name2=value2' pair.
794-
* If the names match, return the index for the value2, else -1.
795-
*/
796-
int envmatch(uchar *s1, int i2)
788+
int env_match(uchar *s1, int i2)
797789
{
798790
if (s1 == NULL)
799791
return -1;

examples/api/glue.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
#include <common.h>
7+
#include <env.h>
78
#include <linux/types.h>
89
#include <api_public.h>
910

@@ -365,7 +366,7 @@ const char * ub_env_enum(const char *last)
365366

366367
/*
367368
* It's OK to pass only the name piece as last (and not the whole
368-
* 'name=val' string), since the API_ENUM_ENV call uses envmatch()
369+
* 'name=val' string), since the API_ENUM_ENV call uses env_match()
369370
* internally, which handles such case
370371
*/
371372
if (!syscall(API_ENV_ENUM, NULL, last, &env))

include/common.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,6 @@ int do_fat_fsload(cmd_tbl_t *, int, int, char * const []);
145145
/* common/cmd_ext2.c */
146146
int do_ext2load(cmd_tbl_t *, int, int, char * const []);
147147

148-
/* common/cmd_nvedit.c */
149-
int envmatch (uchar *, int);
150-
151148
/**
152149
* env_get() - Look up the value of an environment variable
153150
*

include/env.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ int env_init(void);
3939
*/
4040
void env_relocate(void);
4141

42+
/**
43+
* env_match() - Match a name / name=value pair
44+
*
45+
* This is used prior to relocation for finding envrionment variables
46+
*
47+
* @name: A simple 'name', or a 'name=value' pair.
48+
* @index: The environment index for a 'name2=value2' pair.
49+
* @return index for the value if the names match, else -1.
50+
*/
51+
int env_match(unsigned char *name, int index);
52+
4253
/**
4354
* env_get_f() - Look up the value of an environment variable (early)
4455
*

0 commit comments

Comments
 (0)