Re: [PATCH] scripts/dtc: Fixed format mismatch in fprintf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On 05/25/18 20:24, David Gibson wrote:
> On Fri, May 25, 2018 at 09:32:56AM +0800, nixiaoming wrote:
>> format specifier "d" need arg type "int" , but the according arg
>> "fdt32_to_cpu(xxx)" has type "unsigned int"
>>
>> Signed-off-by: nixiaoming <nixiaoming@xxxxxxxxxx>
> 
> As Rob says this needs to be sent against upstream dtc.  But although
> the bug is real the fix is not correct.  The type here is actually
> uint32_t - that might be the same as unsigned int on your platform,
> but it's not guaranateed to be.  You should use the PRIu32 format
> string from inttypes.h instead.

nixiaoming might get a bit confused by Rob's and your responses.  His
email is to the upstream dtc project (he originally sent it to Rob, me,
and the devicetree list, then he sent this second email to David and
the devicetree-compiler list).

-Frank

> 
>> ---
>>  scripts/dtc/fdtdump.c  | 6 +++---
>>  scripts/dtc/flattree.c | 2 +-
>>  2 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/scripts/dtc/fdtdump.c b/scripts/dtc/fdtdump.c
>> index 7d460a5..851bb6f 100644
>> --- a/scripts/dtc/fdtdump.c
>> +++ b/scripts/dtc/fdtdump.c
>> @@ -66,12 +66,12 @@ static void dump_blob(void *blob)
>>  
>>  	printf("/dts-v1/;\n");
>>  	printf("// magic:\t\t0x%x\n", fdt32_to_cpu(bph->magic));
>> -	printf("// totalsize:\t\t0x%x (%d)\n", totalsize, totalsize);
>> +	printf("// totalsize:\t\t0x%x (%u)\n", totalsize, totalsize);
>>  	printf("// off_dt_struct:\t0x%x\n", off_dt);
>>  	printf("// off_dt_strings:\t0x%x\n", off_str);
>>  	printf("// off_mem_rsvmap:\t0x%x\n", off_mem_rsvmap);
>> -	printf("// version:\t\t%d\n", version);
>> -	printf("// last_comp_version:\t%d\n",
>> +	printf("// version:\t\t%u\n", version);
>> +	printf("// last_comp_version:\t%u\n",
>>  	       fdt32_to_cpu(bph->last_comp_version));
>>  	if (version >= 2)
>>  		printf("// boot_cpuid_phys:\t0x%x\n",
>> diff --git a/scripts/dtc/flattree.c b/scripts/dtc/flattree.c
>> index 8d268fb..28da281 100644
>> --- a/scripts/dtc/flattree.c
>> +++ b/scripts/dtc/flattree.c
>> @@ -393,7 +393,7 @@ void dt_to_blob(FILE *f, struct dt_info *dti, int version)
>>  			padlen = 0;
>>  			if (quiet < 1)
>>  				fprintf(stderr,
>> -					"Warning: blob size %d >= minimum size %d\n",
>> +					"Warning: blob size %u >= minimum size %d\n",
>>  					fdt32_to_cpu(fdt.totalsize), minsize);
>>  		}
>>  	}
> 

--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux