[U-Boot] [PATCH v3] hwconfig: Fix dummy initialization of {board, cpu}_hwconfig

Kumar Gala galak at kernel.crashing.org
Tue Nov 30 22:24:17 CET 2010


On Nov 30, 2010, at 3:12 PM, Scott Wood wrote:

> On Tue, 30 Nov 2010 15:01:28 -0600
> Kumar Gala <galak at kernel.crashing.org> wrote:
> 
>> diff --git a/common/hwconfig.c b/common/hwconfig.c
>> index 3c9759f..da8d3ed 100644
>> --- a/common/hwconfig.c
>> +++ b/common/hwconfig.c
>> @@ -68,8 +68,8 @@ next:
>> 	return NULL;
>> }
>> 
>> -const char *cpu_hwconfig __attribute__((weak));
>> -const char *board_hwconfig __attribute__((weak));
>> +const char cpu_hwconfig[] __attribute__((weak)) = "";
>> +const char board_hwconfig[] __attribute__((weak)) = "";
>> 
>> #define HWCONFIG_PRE_RELOC_BUF_SIZE	128
>> 
>> @@ -96,13 +96,11 @@ static const char *__hwconfig(const char *opt, size_t *arglen)
>> 		return hwconfig_parse(env_hwconfig, strlen(env_hwconfig),
>> 				      opt, ";", ':', arglen);
>> 
>> -	if (board_hwconfig)
>> -		return hwconfig_parse(board_hwconfig, strlen(board_hwconfig),
>> -				      opt, ";", ':', arglen);
>> +	return hwconfig_parse(board_hwconfig, strlen(board_hwconfig),
>> +			opt, ";", ':', arglen);
>> 
>> -	if (cpu_hwconfig)
>> -		return hwconfig_parse(cpu_hwconfig, strlen(cpu_hwconfig),
>> -				      opt, ";", ':', arglen);
>> +	return hwconfig_parse(cpu_hwconfig, strlen(cpu_hwconfig),
>> +			opt, ";", ':', arglen);
>> 
>> 	return NULL;
>> }
> 
> Hmm.  "return x; return y; return NULL;"
> 
> Was the presence of a board hwconfig really intended to override, rather
> than add to, the cpu hwconfig?  Should we check the return of the first
> hwconfig_parse to see if it found anything?

Yeah, I'll fix this - didn't even notice it before.

I'm going to make it:
	ret = hwconfig_parse(env_hwconfig, ...)
	if (ret)
		return ret;
	ret = hwconfig_parse(board_hwconfig, ...)
	if (ret)
		return ret;

	return hwconfig_parse(cpu_hwconfig, ...);

- k


More information about the U-Boot mailing list