Re: [PATCH] treesource: Fix dts output for phandles in middle of a sequence of ints

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



On Wed, Oct 10, 2018 at 10:19:30AM -0500, Rob Herring wrote:
> If we have a phandle in the middle of a sequence of numbers and
> it is not bracketed (e.g. <0x1234 &phandle 0x5678>), the dts output will
> be corrupted due to missing a space between the phandle value and the
> following number.
> 
> Fixes: 8c59a97ce096 ("Fix missing labels when emitting dts format")
> Cc: Grant Likely <grant.likely@xxxxxxx>
> Signed-off-by: Rob Herring <robh@xxxxxxxxxx>

Applied, thanks.

> ---
> Well, I was wrong with the previous fix that REF_PHANDLE didn't have 
> problems... 
> 
> IMO, this code is fragile due the mixture of type and non-type markers. 
> I'd re-written Grant's original code to only iterate on type markers. 
> That got reverted back to iterate thru all markers to fix label output. 
> I think this needs to be re-thought on how to make it robust. Perhaps 
> type and non-type markers should be split into 2 lists. 
> 
>  treesource.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/treesource.c b/treesource.c
> index 09f0512060a9..8d4a617a361b 100644
> --- a/treesource.c
> +++ b/treesource.c
> @@ -270,10 +270,10 @@ static void write_propval(FILE *f, struct property *prop)
>  		if (has_data_type_information(m)) {
>  			emit_type = m->type;
>  			fprintf(f, " %s", delim_start[emit_type]);
> -		}
> -
> -		if (m->type == LABEL)
> +		} else if (m->type == LABEL)
>  			fprintf(f, " %s:", m->ref);
> +		else if (m->offset)
> +			fputc(' ', f);
>  
>  		if (emit_type == TYPE_NONE) {
>  			assert(chunk_len == 0);

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[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