Commit 1b7427cd2ab6aae150559ee2edc8965fda113fdf
Committed by
Tom Rini
1 parent
fd4e3280e5
Exists in
v2017.01-smarct4x
and in
25 other branches
tools/env: move envmatch further up in file to avoid forward declarations
forward declaration not needed when re-ordered Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Andreas Fenkart <andreas.fenkart@digitalstrom.com>
Showing 1 changed file with 18 additions and 20 deletions Side-by-side Diff
tools/env/fw_env.c
... | ... | @@ -122,7 +122,6 @@ |
122 | 122 | #include <env_default.h> |
123 | 123 | |
124 | 124 | static int flash_io (int mode); |
125 | -static char *envmatch (char * s1, char * s2); | |
126 | 125 | static int parse_config(struct env_opts *opts); |
127 | 126 | |
128 | 127 | #if defined(CONFIG_FILE) |
... | ... | @@ -148,6 +147,24 @@ |
148 | 147 | } |
149 | 148 | |
150 | 149 | /* |
150 | + * s1 is either a simple 'name', or a 'name=value' pair. | |
151 | + * s2 is a 'name=value' pair. | |
152 | + * If the names match, return the value of s2, else NULL. | |
153 | + */ | |
154 | +static char *envmatch(char *s1, char *s2) | |
155 | +{ | |
156 | + if (s1 == NULL || s2 == NULL) | |
157 | + return NULL; | |
158 | + | |
159 | + while (*s1 == *s2++) | |
160 | + if (*s1++ == '=') | |
161 | + return s2; | |
162 | + if (*s1 == '\0' && *(s2 - 1) == '=') | |
163 | + return s2; | |
164 | + return NULL; | |
165 | +} | |
166 | + | |
167 | +/** | |
151 | 168 | * Search the environment for a variable. |
152 | 169 | * Return the value, if found, or NULL, if not found. |
153 | 170 | */ |
... | ... | @@ -1088,25 +1105,6 @@ |
1088 | 1105 | } |
1089 | 1106 | |
1090 | 1107 | return rc; |
1091 | -} | |
1092 | - | |
1093 | -/* | |
1094 | - * s1 is either a simple 'name', or a 'name=value' pair. | |
1095 | - * s2 is a 'name=value' pair. | |
1096 | - * If the names match, return the value of s2, else NULL. | |
1097 | - */ | |
1098 | - | |
1099 | -static char *envmatch (char * s1, char * s2) | |
1100 | -{ | |
1101 | - if (s1 == NULL || s2 == NULL) | |
1102 | - return NULL; | |
1103 | - | |
1104 | - while (*s1 == *s2++) | |
1105 | - if (*s1++ == '=') | |
1106 | - return s2; | |
1107 | - if (*s1 == '\0' && *(s2 - 1) == '=') | |
1108 | - return s2; | |
1109 | - return NULL; | |
1110 | 1108 | } |
1111 | 1109 | |
1112 | 1110 | /* |