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

Holger Brunck holger.brunck at keymile.com
Mon May 2 10:30:09 CEST 2011


Hello,

On 04/30/2011 10:29 AM, Wolfgang Denk wrote:
> 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.
> 

Ok.

>> +			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.
> 

It is tested on our boards. But indeed the commit message should be better to be
able to understand the functionality. Additionaly we check if additionaly some
error cases are not handled.

Best regards
Holger Brunck



More information about the U-Boot mailing list