* [PATCH] write_propval_string: Use a list of strings instead of "\0" in a string
@ 2023-04-26 18:24 Uwe Kleine-König
[not found] ` <20230426182405.572729-1-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Uwe Kleine-König @ 2023-04-26 18:24 UTC (permalink / raw)
To: David Gibson; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA
A string that contains '\0' can be written as a list of strings e.g.
clock-names = "di0_pll\0di1_pll\0di0_sel\0di1_sel\0di2_sel\0di3_sel\0di0\0di1";
is equivalent to
clock-names = "di0_pll", "di1_pll", "di0_sel", "di1_sel", "di2_sel", "di3_sel", "di0", "di1";
The latter is easier to read, to use this format instead.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
treesource.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/treesource.c b/treesource.c
index 33fedee82d58..de30188189fb 100644
--- a/treesource.c
+++ b/treesource.c
@@ -87,7 +87,7 @@ static void write_propval_string(FILE *f, const char *s, size_t len)
fprintf(f, "\\\"");
break;
case '\0':
- fprintf(f, "\\0");
+ fprintf(f, "\", \"");
break;
default:
if (isprint((unsigned char)c))
--
2.39.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] write_propval_string: Use a list of strings instead of "\0" in a string
[not found] ` <20230426182405.572729-1-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2023-04-28 5:48 ` David Gibson
0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2023-04-28 5:48 UTC (permalink / raw)
To: Uwe Kleine-König; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 1308 bytes --]
On Wed, Apr 26, 2023 at 08:24:05PM +0200, Uwe Kleine-König wrote:
> A string that contains '\0' can be written as a list of strings e.g.
>
> clock-names = "di0_pll\0di1_pll\0di0_sel\0di1_sel\0di2_sel\0di3_sel\0di0\0di1";
>
> is equivalent to
>
> clock-names = "di0_pll", "di1_pll", "di0_sel", "di1_sel", "di2_sel", "di3_sel", "di0", "di1";
>
> The latter is easier to read, to use this format instead.
I agree, however this breaks the type-preservation.dts test, so that
will need to be corrected to match.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> ---
> treesource.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/treesource.c b/treesource.c
> index 33fedee82d58..de30188189fb 100644
> --- a/treesource.c
> +++ b/treesource.c
> @@ -87,7 +87,7 @@ static void write_propval_string(FILE *f, const char *s, size_t len)
> fprintf(f, "\\\"");
> break;
> case '\0':
> - fprintf(f, "\\0");
> + fprintf(f, "\", \"");
> break;
> default:
> if (isprint((unsigned char)c))
--
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 --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-28 5:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-26 18:24 [PATCH] write_propval_string: Use a list of strings instead of "\0" in a string Uwe Kleine-König
[not found] ` <20230426182405.572729-1-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2023-04-28 5:48 ` David Gibson
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).