1
0
Fork 0
Commit Graph

13 Commits (zero-gravitas)

Author SHA1 Message Date
Lubomir Rintel ed0f40a673 tools: fix env_flags build
$ make tools-all
  ...
  In file included from tools/env/env_flags.c:1:0:
  tools/env/../../common/env_flags.c: In function
    ‘env_flags_parse_varaccess_from_binflags’:
    tools/env/../../common/env_flags.c:156:18: warning: implicit declaration
    of function ‘ARRAY_SIZE’ [-Wimplicit-function-declaration]
      for (i = 0; i < ARRAY_SIZE(env_flags_varaccess_mask); i++)
                      ^
Seems like the other utilities just add a copy of ARRAY_SIZE since
there's nowhere to include it from (tools/imagetool.h,
tools/mxsimage.h). Let's do the same here.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
2016-02-15 20:58:25 +00:00
Andreas Fenkart 167f525871 tools: env validate: pass values as 0-based array
passing argv/argc can produce off-by-one errors

Signed-off-by: Andreas Fenkart <andreas.fenkart@digitalstrom.com>
2016-02-08 10:10:29 -05:00
Peng Fan db18f548cb common: env_flags: fix loop condition when using env_flags_varaccess_mask
We should use ARRAY_SIZE, but not sizeof. The size of
env_flags_varaccess_mask is 16bytes, but we only need 4 loops.
If using 16 as the end condition, we may access memory that
not belong to array env_flags_varaccess_mask.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: York Sun <yorksun@freescale.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2016-01-13 21:05:26 -05:00
Peng Fan 5a6894397a common: env: initialize scalar variable
Before calling hsearch_r, initialize callback entry to NULL.

Coverity log:
"
Uninitialized scalar variable (UNINIT)
uninit_use_in_call: Using uninitialized value e.
Field e.callback is uninitialized when calling hsearch_r.
"

Reported-by: Coverity
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
2016-01-04 12:25:35 -05:00
Codrin Ciubotariu 0118e83ba4 common/env_flags.c: Add function to validate a MAC address
The code that checks if a string has the format of a MAC address has been
moved to a separate function called eth_validate_ethaddr_str().

This has been done to allow other components (such as vsc9953 driver)
to validate a MAC address.

Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@freescale.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: York Sun <yorksun@freescale.com>
2015-09-21 08:29:47 -07:00
Joe Hershberger cca98fd6aa env: Allow env_attr_walk to pass a priv * to callback
In some cases it can be helpful to have context in the callback about
the calling situation. This is needed for following patches.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2015-05-21 09:13:19 -04:00
Heiko Schocher 1b6102718b common, env: optimize boottime
when creating the hashtable, for each environmentvariable
getenv(ENV_CALLBACK_VAR) and getenv(ENV_FLAGS_VAR) is called,
which costs at this point a lot of time. So call this two
getenv() calls only once.

Boottime on the ids8313 board without this patch:

2013-12-19 13:38:22,894:  NAND:  128 MiB
2013-12-19 13:38:27,659:  In:    serial
(~4.8 sec)

Bootime with this patch on the ids8313 board:

2013-12-19 13:40:25,332:  NAND:  128 MiB
2013-12-19 13:40:25,546:  In:    serial
(~0.2 sec)

Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Tom Rini <trini@ti.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Wolfgang Denk <wd@denx.de>
2014-01-14 09:01:06 -05:00
Wolfgang Denk 1a4596601f Add GPL-2.0+ SPDX-License-Identifier to source files
Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>
2013-07-24 09:44:38 -04:00
Joe Hershberger 1d6cd0a3f6 env: Handle write-once ethaddr and serial# generically
Use the variable access flags to implement the protection for ethaddr
and serial# instead of hard-coding them.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-12-13 11:46:57 -07:00
Joe Hershberger 267541f776 env: Add support for access control to .flags
Add support for read-only, write-once, and change-default.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-12-13 11:46:56 -07:00
Joe Hershberger fffad71bc4 env: Add a command to display details about env flags
Similar to the env callback command, this will show details about the
options available, the static list, and the currently active variables.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-12-13 11:46:56 -07:00
Joe Hershberger 30fd4fadb3 tools/env: Add environment variable flags support
Currently just validates variable types as decimal, hexidecimal,
boolean, ip address, and mac address.  Call
env_acl_validate_setenv_params() from setenv() in fw_env.c.

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.

Need to build in _ctype for isdigit for Linux.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2012-12-13 11:46:56 -07:00
Joe Hershberger 2598090b7e 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>
2012-12-13 11:46:56 -07:00