[U-Boot] [PATCH 23/30] km/common: replace env var checkboardidlist by function

Wolfgang Denk wd at denx.de
Sat Apr 30 10:29:53 CEST 2011


Dear Valentin Longchamp,

In message <e341fcb668eb67e1eb44ea638e96f9bb514c8bfb.1302272395.git.valentin.longchamp at keymile.com> you wrote:
> From: Thomas Herzmann <thomas.herzmann at keymile.com>
> 
> The environment variable (defining a checkboardidlist function)
> has been replaced by a u-boot function call. This call is much
> faster and the environment is a leaner.
...
> +	p = get_local_var("IVM_BoardId");
> +	strict_strtoul(p, 16, &ivmbid);
> +	p = get_local_var("IVM_HWKey");
> +	strict_strtoul(p, 16, &ivmhwkey);

Error handling missing.

> +			while (!found) {
> +				/* loop over each bid/hwkey pair in the list */
> +				unsigned long bid   = 0;
> +				unsigned long hwkey = 0;
> +				while (*rest && !isxdigit(*rest))
> +					rest++;
> +				bid = simple_strtoul(rest, &endp, 16);
> +				if (*endp == '_') {
> +					rest  = endp + 1;
> +					hwkey =	simple_strtoul(rest, &endp, 16);
> +					rest  = endp;
> +					while (*rest && !isxdigit(*rest))
> +						rest++;
> +				}
> +				if ((!bid) || (!hwkey)) {
> +					/* end of list */
> +					break;
> +				}
> +				if (verbose) {
> +					printf("trying bid=0x%lX, hwkey=%ld\n",
> +						bid, hwkey);
> +				}
> +				if ((bid == ivmbid) && (hwkey == ivmhwkey)) {
> +					char buf[10];
> +
> +					found = 1;
> +					envbid   = bid;
> +					envhwkey = hwkey;
> +					sprintf(buf, "%lx", bid);
> +					setenv("boardid", buf);
> +					sprintf(buf, "%lx", hwkey);
> +					setenv("hwkey", buf);
> +					saveenv();
> +				}

How well has this code been tested?  I may not understand it correctly
(which might be an indication that some comments are missing that
actually explain what you are doing), or there might be some unhandled
error cases.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
HANDLE WITH EXTREME CARE:  This Product Contains  Minute Electrically
Charged  Particles  Moving  at  Velocities  in Excess of Five Hundred
Million Miles Per Hour.


More information about the U-Boot mailing list