Commit graph

5 commits

Author SHA1 Message Date
Ahmad Fatoum
26c54f840d tests: add test cases for label-relative path references
Newly added &{label/path} feature doesn't yet have any tests. Add some.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
2022-01-25 17:10:47 +11:00
Rob Herring
522d81d572 Fix dts output with a REF_PATH marker
Commit 8c59a97ce0 ("Fix missing labels when emitting dts format")
fixed label output, but broke output when there is a REF_PATH marker.

The problem is a REF_PATH marker causes a zero length string to be
emitted. The write_propval_string() function requires a length of at
least 1 (including the terminating '\0'), but that was not being
checked.

For the integer output, a length of 0 is valid as it is possible to have
labels inside the starting '<':

int-prop = < start: 0x1234>;

REF_PHANDLE is another marker that we don't explicitly handle, but it
doesn't cause a problem as it is fundamentally just an int.

Fixes: 8c59a97ce0 ("Fix missing labels when emitting dts format")
Reported-by: Kumar Gala <kumar.gala@linaro.org>
Cc: Grant Likely <grant.likely@arm.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-09-27 10:58:35 +10:00
Tim Montague
a10cb3c818 Fix get_node_by_path string equality check
When determining if to recurse into a node, get_node_by_path does not
check if the length of each node name is equal.  If searching for
/foo/baz, this can result in recursing into /foobar because
strneq("foo", "foobar", 3) is true.

This can result in a reference to /foo/baz to be incorrectly set to
/foobar/baz.  A test for this was added.

Signed-off-by: Tim Montague <tmontague@ghs.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-04-19 11:25:32 +10:00
David Gibson
f240527e54 Fix bug with references to root node
At present, the lexer token for references to a path doesn't permit a
reference to the root node &{/}.  Fixing the lexer exposes another bug
handling this case.

This patch fixes both bugs and adds testcases.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-05-09 20:48:49 +10:00
David Gibson
efbbef8e4f dtc: Implement path references
This patch extends dtc syntax to allow references (&label, or
&{/full/path}) directly within property definitions, rather than
inside a cell list.  Such references are expanded to the full path of
the referenced node, as a string, instead of to a phandle as
references within cell lists are evaluated.

A testcase is also included.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-12-05 08:28:44 -06:00