devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Geert Uytterhoeven
	<geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
Cc: Jon Loeliger <jdl-CYoMK+44s/E@public.gmane.org>,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] dtc: Consider one-character strings as strings
Date: Thu, 25 Jun 2020 11:42:46 +1000	[thread overview]
Message-ID: <20200625014246.GD69292@umbus.fritz.box> (raw)
In-Reply-To: <20200623094343.26010-1-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 1779 bytes --]

On Tue, Jun 23, 2020 at 11:43:43AM +0200, Geert Uytterhoeven wrote:
> When using overlays, a target-path property pointing to the root node is
> quite common.  However, "dtc -O dts" prints it as a byte array:
> 
>     target-path = [2f 00];
> 
> instead of a string:
> 
>     target-path = "/";
> 
> For guess_value_type() to consider a value to be a string, it must
> contain less nul bytes than non-nul bytes, thus ruling out strings
> containing only a single character.  Allow printing such strings by
> relaxing the condition slightly.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>

Makes sense.  Applied, thanks.

> ---
> Alternatively, guess_value_type() could check explicitly for "/",
> reducing the number of false positives.
> 
> However, there seem to be plenty of other uses of one-character strings
> in DTS files.  The most common one is 'type = "a"' for HDMI connectors.
> ---
>  treesource.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/treesource.c b/treesource.c
> index 2acb920d77752410..061ba8c9c5e83265 100644
> --- a/treesource.c
> +++ b/treesource.c
> @@ -183,7 +183,7 @@ static enum markertype guess_value_type(struct property *prop)
>  			nnotcelllbl++;
>  	}
>  
> -	if ((p[len-1] == '\0') && (nnotstring == 0) && (nnul < (len-nnul))
> +	if ((p[len-1] == '\0') && (nnotstring == 0) && (nnul <= (len-nnul))
>  	    && (nnotstringlbl == 0)) {
>  		return TYPE_STRING;
>  	} else if (((len % sizeof(cell_t)) == 0) && (nnotcelllbl == 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      parent reply	other threads:[~2020-06-25  1:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23  9:43 [PATCH] dtc: Consider one-character strings as strings Geert Uytterhoeven
     [not found] ` <20200623094343.26010-1-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2020-06-25  1:42   ` David Gibson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200625014246.GD69292@umbus.fritz.box \
    --to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
    --cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org \
    --cc=jdl-CYoMK+44s/E@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).