[U-Boot] [PATCH 1/8] cmd: cpu: fix NULL cpu feature prints

Álvaro Fernández Rojas noltari at gmail.com
Sat Apr 15 17:16:03 UTC 2017


Hi Daniel,

El 14/04/2017 a las 19:43, Daniel Schwierzeck escribió:
> +cc Simon
> 
> Am 13.04.2017 um 17:52 schrieb Álvaro Fernández Rojas:
>> Commit 740d5d3 added two new features but only one feature name,
>> which results in NULL prints when device_id feature is selected.
>> Fix this by not printing features without a corresponding name.
>>
>> Before:
>> 	HG556a # cpu detail
>> 	 -1: cpu at 0	BCM6358A1
>> 		ID = 0, freq = 300 MHz: L1 cache, MMU, NULL
>> 		Device ID 0x2a010
>> 	 -1: cpu at 1	BCM6358A1
>> 		ID = 1, freq = 300 MHz: L1 cache, MMU, NULL
>> 		Device ID 0x2a010
>> After:
>> 	HG556a # cpu detail
>> 	 -1: cpu at 0	BCM6358A1
>> 		ID = 0, freq = 300 MHz: L1 cache, MMU
>> 		Device ID 0x2a010
>> 	 -1: cpu at 1	BCM6358A1
>> 		ID = 1, freq = 300 MHz: L1 cache, MMU
>> 		Device ID 0x2a010
>>
>> Signed-off-by: Álvaro Fernández Rojas <noltari at gmail.com>
>> ---
>>  cmd/cpu.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/cmd/cpu.c b/cmd/cpu.c
>> index bc4dc5c..14053d2 100644
>> --- a/cmd/cpu.c
>> +++ b/cmd/cpu.c
>> @@ -52,7 +52,8 @@ static int print_cpu_list(bool detail)
>>  		print_freq(info.cpu_freq, "");
>>  		first = true;
>>  		for (i = 0; i < CPU_FEAT_COUNT; i++) {
>> -			if (info.features & (1 << i)) {
>> +			if (info.features & (1 << i) &&
>> +			    cpu_feature_name[i] != NULL) {
>>  				printf("%s%s", first ? ": " : ", ",
>>  				       cpu_feature_name[i]);
>>  				first = false;
>>
> 
> wouldn't be adding the missing feature name the better fix?
The thing is I wouldn't print Microcode feature either, because it's printed right below if it's really avaiable and I don't see the point of printing it twice (first just a description and then the actual device id too, and the same goes for microcode).
If I fix it like you suggest we will have the following:
	HG556a # cpu detail
	 -1: cpu at 0	BCM6358A1
		ID = 0, freq = 300 MHz: L1 cache, MMU, *Device ID*
		*Device ID 0x2a010*
	 -1: cpu at 1	BCM6358A1
		ID = 1, freq = 300 MHz: L1 cache, MMU, *Device ID*
		*Device ID 0x2a010*

> 


More information about the U-Boot mailing list