Commit 2598090b7e17f8bdca95b22e7f27217054730e02

Authored by Joe Hershberger
Committed by Tom Rini
1 parent e080d545f8

env: Add environment variable flags

Currently just validates variable types as decimal, hexidecimal,
boolean, ip address, and mac address.

If the entry is not found in the env ".flags", then look in the static
one. This allows the env to override the static definitions, but prevents
the need to have every definition in the environment distracting you.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>

Showing 11 changed files with 447 additions and 58 deletions Side-by-side Diff

... ... @@ -2188,6 +2188,11 @@
2188 2188 serial# is unaffected by this, i. e. it remains
2189 2189 read-only.]
2190 2190  
  2191 + The same can be accomplished in a more flexible way
  2192 + for any variable by configuring the type of access
  2193 + to allow for those variables in the ".flags" variable
  2194 + or define CONFIG_ENV_FLAGS_LIST_STATIC.
  2195 +
2191 2196 - Protected RAM:
2192 2197 CONFIG_PRAM
2193 2198  
... ... @@ -3112,6 +3117,38 @@
3112 3117 setting is supposed to be generous and should work in most
3113 3118 cases. This setting can be used to tune behaviour; see
3114 3119 lib/hashtable.c for details.
  3120 +
  3121 +- CONFIG_ENV_FLAGS_LIST_DEFAULT
  3122 +- CONFIG_ENV_FLAGS_LIST_STATIC
  3123 + Enable validation of the values given to enviroment variables when
  3124 + calling env set. Variables can be restricted to only decimal,
  3125 + hexadecimal, or boolean. If CONFIG_CMD_NET is also defined,
  3126 + the variables can also be restricted to IP address or MAC address.
  3127 +
  3128 + The format of the list is:
  3129 + type_attribute = [s|d|x|b|i|m]
  3130 + attributes = type_attribute
  3131 + entry = variable_name[:attributes]
  3132 + list = entry[,list]
  3133 +
  3134 + The type attributes are:
  3135 + s - String (default)
  3136 + d - Decimal
  3137 + x - Hexadecimal
  3138 + b - Boolean ([1yYtT|0nNfF])
  3139 + i - IP address
  3140 + m - MAC address
  3141 +
  3142 + - CONFIG_ENV_FLAGS_LIST_DEFAULT
  3143 + Define this to a list (string) to define the ".flags"
  3144 + envirnoment variable in the default or embedded environment.
  3145 +
  3146 + - CONFIG_ENV_FLAGS_LIST_STATIC
  3147 + Define this to a list (string) to define validation that
  3148 + should be done if an entry is not found in the ".flags"
  3149 + environment variable. To override a setting in the static
  3150 + list, simply add an entry for the same variable name to the
  3151 + ".flags" variable.
3115 3152  
3116 3153 The following definitions that deal with the placement and management
3117 3154 of environment data (variable area); in general, we support the
... ... @@ -47,6 +47,7 @@
47 47 COBJS-y += env_attr.o
48 48 COBJS-y += env_callback.o
49 49 COBJS-y += env_common.o
  50 +COBJS-y += env_flags.o
50 51 COBJS-$(CONFIG_ENV_IS_IN_DATAFLASH) += env_dataflash.o
51 52 COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o
52 53 XCOBJS-$(CONFIG_ENV_IS_EMBEDDED) += env_embedded.o
... ... @@ -212,6 +213,7 @@
212 213 COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_attr.o
213 214 COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_callback.o
214 215 COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_common.o
  216 +COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_flags.o
215 217 COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_nowhere.o
216 218 COBJS-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o
217 219 endif
... ... @@ -192,57 +192,9 @@
192 192 #endif /* CONFIG_SPL_BUILD */
193 193  
194 194 /*
195   - * Perform consistency checking before setting, replacing, or deleting an
196   - * environment variable, then (if successful) apply the changes to internals so
197   - * to make them effective. Code for this function was taken out of
198   - * _do_env_set(), which now calls it instead.
199   - * Also called as a callback function by himport_r().
200   - * Returns 0 in case of success, 1 in case of failure.
201   - * When (flag & H_FORCE) is set, do not print out any error message and force
202   - * overwriting of write-once variables.
203   - */
204   -
205   -int env_change_ok(const ENTRY *item, const char *newval, enum env_op op,
206   - int flag)
207   -{
208   -#ifndef CONFIG_ENV_OVERWRITE
209   - const char *name;
210   -#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
211   - const char *oldval = NULL;
212   -
213   - if (op != env_op_create)
214   - oldval = item->data;
215   -#endif
216   -
217   - name = item->key;
218   -#endif
219   -
220   -#ifndef CONFIG_ENV_OVERWRITE
221   - /*
222   - * Some variables like "ethaddr" and "serial#" can be set only once and
223   - * cannot be deleted, unless CONFIG_ENV_OVERWRITE is defined.
224   - */
225   - if (op != env_op_create && /* variable exists */
226   - (flag & H_FORCE) == 0) { /* and we are not forced */
227   - if (strcmp(name, "serial#") == 0 ||
228   - (strcmp(name, "ethaddr") == 0
229   -#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
230   - && strcmp(oldval, __stringify(CONFIG_ETHADDR)) != 0
231   -#endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
232   - )) {
233   - printf("Can't overwrite \"%s\"\n", name);
234   - return 1;
235   - }
236   - }
237   -#endif
238   -
239   - return 0;
240   -}
241   -
242   -/*
243 195 * Set a new environment variable,
244 196 * or replace or delete an existing one.
245   -*/
  197 + */
246 198 static int _do_env_set(int flag, int argc, char * const argv[])
247 199 {
248 200 int i, len;
... ... @@ -40,7 +40,7 @@
40 40 #include <env_default.h>
41 41  
42 42 struct hsearch_data env_htab = {
43   - .change_ok = env_change_ok,
  43 + .change_ok = env_flags_validate,
44 44 };
45 45  
46 46 static uchar __env_get_char_spec(int index)
  1 +/*
  2 + * (C) Copyright 2012
  3 + * Joe Hershberger, National Instruments, joe.hershberger@ni.com
  4 + *
  5 + * See file CREDITS for list of people who contributed to this
  6 + * project.
  7 + *
  8 + * This program is free software; you can redistribute it and/or
  9 + * modify it under the terms of the GNU General Public License as
  10 + * published by the Free Software Foundation; either version 2 of
  11 + * the License, or (at your option) any later version.
  12 + *
  13 + * This program is distributed in the hope that it will be useful,
  14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16 + * GNU General Public License for more details.
  17 + *
  18 + * You should have received a copy of the GNU General Public License
  19 + * along with this program; if not, write to the Free Software
  20 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21 + * MA 02111-1307 USA
  22 + */
  23 +
  24 +#include <linux/string.h>
  25 +#include <linux/ctype.h>
  26 +
  27 +#include <common.h>
  28 +#include <environment.h>
  29 +
  30 +#ifdef CONFIG_CMD_NET
  31 +#define ENV_FLAGS_NET_VARTYPE_REPS "im"
  32 +#else
  33 +#define ENV_FLAGS_NET_VARTYPE_REPS ""
  34 +#endif
  35 +
  36 +static const char env_flags_vartype_rep[] = "sdxb" ENV_FLAGS_NET_VARTYPE_REPS;
  37 +
  38 +/*
  39 + * Parse the flags string from a .flags attribute list into the vartype enum.
  40 + */
  41 +enum env_flags_vartype env_flags_parse_vartype(const char *flags)
  42 +{
  43 + char *type;
  44 +
  45 + if (strlen(flags) <= ENV_FLAGS_VARTYPE_LOC)
  46 + return env_flags_vartype_string;
  47 +
  48 + type = strchr(env_flags_vartype_rep,
  49 + flags[ENV_FLAGS_VARTYPE_LOC]);
  50 +
  51 + if (type != NULL)
  52 + return (enum env_flags_vartype)
  53 + (type - &env_flags_vartype_rep[0]);
  54 +
  55 + printf("## Warning: Unknown environment variable type '%c'\n",
  56 + flags[ENV_FLAGS_VARTYPE_LOC]);
  57 + return env_flags_vartype_string;
  58 +}
  59 +
  60 +static inline int is_hex_prefix(const char *value)
  61 +{
  62 + return value[0] == '0' && (value[1] == 'x' || value[1] == 'X');
  63 +}
  64 +
  65 +static void skip_num(int hex, const char *value, const char **end,
  66 + int max_digits)
  67 +{
  68 + int i;
  69 +
  70 + if (hex && is_hex_prefix(value))
  71 + value += 2;
  72 +
  73 + for (i = max_digits; i != 0; i--) {
  74 + if (hex && !isxdigit(*value))
  75 + break;
  76 + if (!hex && !isdigit(*value))
  77 + break;
  78 + value++;
  79 + }
  80 + if (end != NULL)
  81 + *end = value;
  82 +}
  83 +
  84 +/*
  85 + * Based on the declared type enum, validate that the value string complies
  86 + * with that format
  87 + */
  88 +static int _env_flags_validate_type(const char *value,
  89 + enum env_flags_vartype type)
  90 +{
  91 + const char *end;
  92 +#ifdef CONFIG_CMD_NET
  93 + const char *cur;
  94 + int i;
  95 +#endif
  96 +
  97 + switch (type) {
  98 + case env_flags_vartype_string:
  99 + break;
  100 + case env_flags_vartype_decimal:
  101 + skip_num(0, value, &end, -1);
  102 + if (*end != '\0')
  103 + return -1;
  104 + break;
  105 + case env_flags_vartype_hex:
  106 + skip_num(1, value, &end, -1);
  107 + if (*end != '\0')
  108 + return -1;
  109 + if (value + 2 == end && is_hex_prefix(value))
  110 + return -1;
  111 + break;
  112 + case env_flags_vartype_bool:
  113 + if (value[0] != '1' && value[0] != 'y' && value[0] != 't' &&
  114 + value[0] != 'Y' && value[0] != 'T' &&
  115 + value[0] != '0' && value[0] != 'n' && value[0] != 'f' &&
  116 + value[0] != 'N' && value[0] != 'F')
  117 + return -1;
  118 + if (value[1] != '\0')
  119 + return -1;
  120 + break;
  121 +#ifdef CONFIG_CMD_NET
  122 + case env_flags_vartype_ipaddr:
  123 + cur = value;
  124 + for (i = 0; i < 4; i++) {
  125 + skip_num(0, cur, &end, 3);
  126 + if (cur == end)
  127 + return -1;
  128 + if (i != 3 && *end != '.')
  129 + return -1;
  130 + if (i == 3 && *end != '\0')
  131 + return -1;
  132 + cur = end + 1;
  133 + }
  134 + break;
  135 + case env_flags_vartype_macaddr:
  136 + cur = value;
  137 + for (i = 0; i < 6; i++) {
  138 + skip_num(1, cur, &end, 2);
  139 + if (cur == end)
  140 + return -1;
  141 + if (cur + 2 == end && is_hex_prefix(cur))
  142 + return -1;
  143 + if (i != 5 && *end != ':')
  144 + return -1;
  145 + if (i == 5 && *end != '\0')
  146 + return -1;
  147 + cur = end + 1;
  148 + }
  149 + break;
  150 +#endif
  151 + case env_flags_vartype_end:
  152 + return -1;
  153 + }
  154 +
  155 + /* OK */
  156 + return 0;
  157 +}
  158 +
  159 +/*
  160 + * Look for flags in a provided list and failing that the static list
  161 + */
  162 +static inline int env_flags_lookup(const char *flags_list, const char *name,
  163 + char *flags)
  164 +{
  165 + int ret = 1;
  166 +
  167 + if (!flags)
  168 + /* bad parameter */
  169 + return -1;
  170 +
  171 + /* try the env first */
  172 + if (flags_list)
  173 + ret = env_attr_lookup(flags_list, name, flags);
  174 +
  175 + if (ret != 0)
  176 + /* if not found in the env, look in the static list */
  177 + ret = env_attr_lookup(ENV_FLAGS_LIST_STATIC, name, flags);
  178 +
  179 + return ret;
  180 +}
  181 +
  182 +/*
  183 + * Parse the flag charachters from the .flags attribute list into the binary
  184 + * form to be stored in the environment entry->flags field.
  185 + */
  186 +static int env_parse_flags_to_bin(const char *flags)
  187 +{
  188 + return env_flags_parse_vartype(flags) & ENV_FLAGS_VARTYPE_BIN_MASK;
  189 +}
  190 +
  191 +/*
  192 + * Look for possible flags for a newly added variable
  193 + * This is called specifically when the variable did not exist in the hash
  194 + * previously, so the blanket update did not find this variable.
  195 + */
  196 +void env_flags_init(ENTRY *var_entry)
  197 +{
  198 + const char *var_name = var_entry->key;
  199 + const char *flags_list = getenv(ENV_FLAGS_VAR);
  200 + char flags[ENV_FLAGS_ATTR_MAX_LEN + 1] = "";
  201 + int ret = 1;
  202 +
  203 + /* look in the ".flags" and static for a reference to this variable */
  204 + ret = env_flags_lookup(flags_list, var_name, flags);
  205 +
  206 + /* if any flags were found, set the binary form to the entry */
  207 + if (!ret && strlen(flags))
  208 + var_entry->flags = env_parse_flags_to_bin(flags);
  209 +}
  210 +
  211 +/*
  212 + * Called on each existing env var prior to the blanket update since removing
  213 + * a flag in the flag list should remove its flags.
  214 + */
  215 +static int clear_flags(ENTRY *entry)
  216 +{
  217 + entry->flags = 0;
  218 +
  219 + return 0;
  220 +}
  221 +
  222 +/*
  223 + * Call for each element in the list that defines flags for a variable
  224 + */
  225 +static int set_flags(const char *name, const char *value)
  226 +{
  227 + ENTRY e, *ep;
  228 +
  229 + e.key = name;
  230 + e.data = NULL;
  231 + hsearch_r(e, FIND, &ep, &env_htab, 0);
  232 +
  233 + /* does the env variable actually exist? */
  234 + if (ep != NULL) {
  235 + /* the flag list is empty, so clear the flags */
  236 + if (value == NULL || strlen(value) == 0)
  237 + ep->flags = 0;
  238 + else
  239 + /* assign the requested flags */
  240 + ep->flags = env_parse_flags_to_bin(value);
  241 + }
  242 +
  243 + return 0;
  244 +}
  245 +
  246 +static int on_flags(const char *name, const char *value, enum env_op op,
  247 + int flags)
  248 +{
  249 + /* remove all flags */
  250 + hwalk_r(&env_htab, clear_flags);
  251 +
  252 + /* configure any static flags */
  253 + env_attr_walk(ENV_FLAGS_LIST_STATIC, set_flags);
  254 + /* configure any dynamic flags */
  255 + env_attr_walk(value, set_flags);
  256 +
  257 + return 0;
  258 +}
  259 +U_BOOT_ENV_CALLBACK(flags, on_flags);
  260 +
  261 +/*
  262 + * Perform consistency checking before creating, overwriting, or deleting an
  263 + * environment variable. Called as a callback function by hsearch_r() and
  264 + * hdelete_r(). Returns 0 in case of success, 1 in case of failure.
  265 + * When (flag & H_FORCE) is set, do not print out any error message and force
  266 + * overwriting of write-once variables.
  267 + */
  268 +
  269 +int env_flags_validate(const ENTRY *item, const char *newval, enum env_op op,
  270 + int flag)
  271 +{
  272 + const char *name;
  273 +#if !defined(CONFIG_ENV_OVERWRITE) && defined(CONFIG_OVERWRITE_ETHADDR_ONCE) \
  274 +&& defined(CONFIG_ETHADDR)
  275 + const char *oldval = NULL;
  276 +
  277 + if (op != env_op_create)
  278 + oldval = item->data;
  279 +#endif
  280 +
  281 + name = item->key;
  282 +
  283 + /* Default value for NULL to protect string-manipulating functions */
  284 + newval = newval ? : "";
  285 +
  286 +#ifndef CONFIG_ENV_OVERWRITE
  287 + /*
  288 + * Some variables like "ethaddr" and "serial#" can be set only once and
  289 + * cannot be deleted, unless CONFIG_ENV_OVERWRITE is defined.
  290 + */
  291 + if (op != env_op_create && /* variable exists */
  292 + (flag & H_FORCE) == 0) { /* and we are not forced */
  293 + if (strcmp(name, "serial#") == 0 ||
  294 + (strcmp(name, "ethaddr") == 0
  295 +#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
  296 + && strcmp(oldval, __stringify(CONFIG_ETHADDR)) != 0
  297 +#endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
  298 + )) {
  299 + printf("Can't overwrite \"%s\"\n", name);
  300 + return 1;
  301 + }
  302 + }
  303 +#endif
  304 +
  305 + /* validate the value to match the variable type */
  306 + if (op != env_op_delete) {
  307 + enum env_flags_vartype type = (enum env_flags_vartype)
  308 + (ENV_FLAGS_VARTYPE_BIN_MASK & item->flags);
  309 +
  310 + if (_env_flags_validate_type(newval, type) < 0) {
  311 + printf("## Error: flags type check failure for "
  312 + "\"%s\" <= \"%s\" (type: %c)\n",
  313 + name, newval, env_flags_vartype_rep[type]);
  314 + return -1;
  315 + }
  316 + }
  317 +
  318 + return 0;
  319 +}
include/env_callback.h
... ... @@ -24,6 +24,7 @@
24 24 #ifndef __ENV_CALLBACK_H__
25 25 #define __ENV_CALLBACK_H__
26 26  
  27 +#include <env_flags.h>
27 28 #include <linker_lists.h>
28 29 #include <search.h>
29 30  
... ... @@ -45,6 +46,7 @@
45 46 * a new association in the ".callbacks" environment variable.
46 47 */
47 48 #define ENV_CALLBACK_LIST_STATIC ENV_CALLBACK_VAR ":callbacks," \
  49 + ENV_FLAGS_VAR ":flags," \
48 50 "baudrate:baudrate," \
49 51 "bootfile:bootfile," \
50 52 "loadaddr:loadaddr," \
include/env_default.h
... ... @@ -41,6 +41,9 @@
41 41 #ifdef CONFIG_ENV_CALLBACK_LIST_DEFAULT
42 42 ENV_CALLBACK_VAR "=" CONFIG_ENV_CALLBACK_LIST_DEFAULT "\0"
43 43 #endif
  44 +#ifdef CONFIG_ENV_FLAGS_LIST_DEFAULT
  45 + ENV_FLAGS_VAR "=" CONFIG_ENV_FLAGS_LIST_DEFAULT "\0"
  46 +#endif
44 47 #ifdef CONFIG_BOOTARGS
45 48 "bootargs=" CONFIG_BOOTARGS "\0"
46 49 #endif
  1 +/*
  2 + * (C) Copyright 2012
  3 + * Joe Hershberger, National Instruments, joe.hershberger@ni.com
  4 + *
  5 + * See file CREDITS for list of people who contributed to this
  6 + * project.
  7 + *
  8 + * This program is free software; you can redistribute it and/or
  9 + * modify it under the terms of the GNU General Public License as
  10 + * published by the Free Software Foundation; either version 2 of
  11 + * the License, or (at your option) any later version.
  12 + *
  13 + * This program is distributed in the hope that it will be useful,
  14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16 + * GNU General Public License for more details.
  17 + *
  18 + * You should have received a copy of the GNU General Public License
  19 + * along with this program; if not, write to the Free Software
  20 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21 + * MA 02111-1307 USA
  22 + */
  23 +
  24 +#ifndef __ENV_FLAGS_H__
  25 +#define __ENV_FLAGS_H__
  26 +
  27 +enum env_flags_vartype {
  28 + env_flags_vartype_string,
  29 + env_flags_vartype_decimal,
  30 + env_flags_vartype_hex,
  31 + env_flags_vartype_bool,
  32 +#ifdef CONFIG_CMD_NET
  33 + env_flags_vartype_ipaddr,
  34 + env_flags_vartype_macaddr,
  35 +#endif
  36 + env_flags_vartype_end
  37 +};
  38 +
  39 +#define ENV_FLAGS_VAR ".flags"
  40 +#define ENV_FLAGS_ATTR_MAX_LEN 2
  41 +#define ENV_FLAGS_VARTYPE_LOC 0
  42 +
  43 +#ifndef CONFIG_ENV_FLAGS_LIST_STATIC
  44 +#define CONFIG_ENV_FLAGS_LIST_STATIC ""
  45 +#endif
  46 +
  47 +#define ENV_FLAGS_LIST_STATIC \
  48 + CONFIG_ENV_FLAGS_LIST_STATIC
  49 +
  50 +/*
  51 + * Parse the flags string from a .flags attribute list into the vartype enum.
  52 + */
  53 +enum env_flags_vartype env_flags_parse_vartype(const char *flags);
  54 +
  55 +#include <search.h>
  56 +
  57 +/*
  58 + * When adding a variable to the environment, initialize the flags for that
  59 + * variable.
  60 + */
  61 +void env_flags_init(ENTRY *var_entry);
  62 +
  63 +/*
  64 + * Validate the newval for to conform with the requirements defined by its flags
  65 + */
  66 +int env_flags_validate(const ENTRY *item, const char *newval, enum env_op op,
  67 + int flag);
  68 +
  69 +/*
  70 + * These are the binary flags used in the environment entry->flags variable to
  71 + * decribe properties of veriables in the table
  72 + */
  73 +#define ENV_FLAGS_VARTYPE_BIN_MASK 0x00000007
  74 +/* The actual variable type values use the enum value (within the mask) */
  75 +
  76 +#endif /* __ENV_FLAGS_H__ */
include/environment.h
... ... @@ -166,6 +166,7 @@
166 166  
167 167 #include <env_attr.h>
168 168 #include <env_callback.h>
  169 +#include <env_flags.h>
169 170 #include <search.h>
170 171  
171 172 extern struct hsearch_data env_htab;
... ... @@ -188,14 +189,6 @@
188 189  
189 190 /* Import from binary representation into hash table */
190 191 int env_import(const char *buf, int check);
191   -
192   -/*
193   - * Check if variable "item" can be changed to newval
194   - * When (flag & H_FORCE) is set, it does not print out any error
195   - * message and forces overwriting of write-once variables.
196   - */
197   -int env_change_ok(const ENTRY *item, const char *newval, enum env_op op,
198   - int flag);
199 192  
200 193 #endif /* DO_DEPS_ONLY */
201 194  
... ... @@ -49,6 +49,7 @@
49 49 char *data;
50 50 int (*callback)(const char *name, const char *value, enum env_op op,
51 51 int flags);
  52 + int flags;
52 53 } ENTRY;
53 54  
54 55 /* Opaque type for internal use. */
... ... @@ -55,6 +55,7 @@
55 55 #endif
56 56  
57 57 #include <env_callback.h>
  58 +#include <env_flags.h>
58 59 #include <search.h>
59 60  
60 61 /*
... ... @@ -412,6 +413,8 @@
412 413  
413 414 /* This is a new entry, so look up a possible callback */
414 415 env_callback_init(&htab->table[idx].entry);
  416 + /* Also look for flags */
  417 + env_flags_init(&htab->table[idx].entry);
415 418  
416 419 /* check for permission */
417 420 if (htab->change_ok != NULL && htab->change_ok(
... ... @@ -465,6 +468,7 @@
465 468 free((void *)ep->key);
466 469 free(ep->data);
467 470 ep->callback = NULL;
  471 + ep->flags = 0;
468 472 htab->table[idx].used = -1;
469 473  
470 474 --htab->filled;