Replace instances in tests of mostly LGPL-2.1 license boilerplate
with SPDX tags.
Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20190620211944.9378-5-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Paths with multiple '/' characters in a row (e.g. //somenode//somsubnode),
or trailing '/' characters (e.g. '/somenode/somesubnode/') should be
handled by fdt_path_offset(), and treated as equivalent to
/somenode/somesubnode.
Our current path_offset testcase doesn't check for these cases, so extend
it so it does.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This introduces a check_path_offset() helper function into the path_offset
testcase to simplify it. This will also make extending the test case with
tests for path_offset_namelen() and some edge cases easier.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
tests will need fdt type definitions provided in a subsequent patch
to libfdt_env.h. Since libfdt.h includes libfdt_env.h in the right
order anyway, just remove the fdt.h include.
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
A number of the dtc testcases trigger the new "variable set but not
used" warning from gcc 4.6. That is they have variables which are
assigned, but then never read after that point.
In a couple of cases this is just because the variables aren't needed,
so this patch removes them. In subnode_offset.c, it's because one
pair of variables we clearly intended to test we don't actually test.
This patch also adds this missing check.
This patch makes the testsuite compile clean with gcc 4.6.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This patch marks various functions not shared between c files
'static', as they should be. There are a couple of functions in dtc,
and many in the testsuite.
This is *almost* enough to enable the -Wmissing-prototypes warning.
It's not quite enough, because there's a mess of junk in the flex
generated code which triggers that warning which I'm not yet sure how
to deal with.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
The fdt_offset_ptr_typed() macro seemed like a good idea at the time.
However, it's not actually used all that often, it can silently throw
away const qualifications and it uses a gcc extension (typeof) which
I'd prefer to avoid for portability.
Therefore, this patch gets rid of it (and the fdt_offset_ptr_typed_w()
variant which was never used at all). It also makes a few variables
const in testcases, which always should have been const, but weren't
caught before because of the aforementioned silent discards.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
At present, the fdt_subnode_offset() and fdt_path_offset() functions
in libfdt require the exact name of the nodes in question be passed,
including unit address.
This is contrary to traditional OF-like finddevice() behaviour, which
allows the unit address to be omitted (which is useful when the device
name is unambiguous without the address).
This patch introduces similar behaviour to
fdt_subnode_offset_namelen(), and hence to fdt_subnode_offset() and
fdt_path_offset() which are implemented in terms of the former. The
unit address can be omitted from the given node name. If this is
ambiguous, the first such node in the flattened tree will be selected
(this behaviour is consistent with IEEE1275 which specifies only that
an arbitrary node matching the given information be selected).
This very small change is then followed by many more diffs which
change the test examples and testcases to exercise this behaviour.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Currently, fdt_path_offset() returns FDL_ERR_BADOFFSET if given a path
with a trailing '/'. In particular this means that
fdt_path_offset("/") returns FDT_ERR_BADOFFSET rather than 0 as one
would expect.
This patch fixes the function to accept and ignore trailing '/'
characters. As well as allowing fdt_path_offset("/") this means that
fdt_path_offset("/foo/") will return the same as
fdt_path_offset("/foo") which seems in keeping with the principle of
least surprise.
This also adds a testcase to ensure that fdt_path_offset("/") returns
0 as it should.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>