mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
treesource: Restore string list output when no type markers
When the DTS output has no type markers, we have to guess the type. Prior
to commit 32b9c61307
("Preserve datatype markers when emitting dts
format"), instances of string lists would be delimited. Since then, a
single string with embedded "\0"s are emitted. An embedded "\0" is valid
for DTS files, but that's a rare exception and lists of strings are the
overwhelming majority. Restore the prior behavior.
stringlist.dts is reused for testing this, but needs a couple of tweaks
in order to match the dts output.
Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Rob Herring <robh@kernel.org>
Message-ID: <20231027142901.2536622-1-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
2283dd78ef
commit
95c74d71f0
3 changed files with 30 additions and 2 deletions
24
treesource.c
24
treesource.c
|
@ -139,6 +139,28 @@ static const char *delim_end[] = {
|
|||
[TYPE_STRING] = "",
|
||||
};
|
||||
|
||||
static void add_string_markers(struct property *prop)
|
||||
{
|
||||
int l, len = prop->val.len;
|
||||
const char *p = prop->val.val;
|
||||
|
||||
for (l = strlen(p) + 1; l < len; l += strlen(p + l) + 1) {
|
||||
struct marker *m, **nextp;
|
||||
|
||||
m = xmalloc(sizeof(*m));
|
||||
m->offset = l;
|
||||
m->type = TYPE_STRING;
|
||||
m->ref = NULL;
|
||||
m->next = NULL;
|
||||
|
||||
/* Find the end of the markerlist */
|
||||
nextp = &prop->val.markers;
|
||||
while (*nextp)
|
||||
nextp = &((*nextp)->next);
|
||||
*nextp = m;
|
||||
}
|
||||
}
|
||||
|
||||
static enum markertype guess_value_type(struct property *prop)
|
||||
{
|
||||
int len = prop->val.len;
|
||||
|
@ -164,6 +186,8 @@ static enum markertype guess_value_type(struct property *prop)
|
|||
|
||||
if ((p[len-1] == '\0') && (nnotstring == 0) && (nnul <= (len-nnul))
|
||||
&& (nnotstringlbl == 0)) {
|
||||
if (nnul > 1)
|
||||
add_string_markers(prop);
|
||||
return TYPE_STRING;
|
||||
} else if (((len % sizeof(cell_t)) == 0) && (nnotcelllbl == 0)) {
|
||||
return TYPE_UINT32;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue