Commit graph

132 commits

Author SHA1 Message Date
John Arbuckle
c8f8194d76 implement strnlen for systems that need it
Prior the Mac OS 10.7, the function strnlen() was not available. This patch
implements strnlen() on Mac OS X versions that are below 10.7.

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-10-27 15:47:52 +02:00
David Gibson
c8b38f65fd libfdt: Remove leading underscores from identifiers
In a lot of places libfdt uses a leading _ character to mark an identifier
as "internal" (not part of the published libfdt API).  This is a bad idea,
because identifiers with a leading _ are generally reserved by the C
library or system.  It's particularly dangerous for libfdt, because it's
designed to be able to be integrated into lots of different environments.

In some cases the leading _ has no purpose, so we simply drop it.  In most
cases we move it to the end, as our new convention for marking internal
identifiers.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-10-26 09:25:14 +02:00
David Gibson
2e6fe5a107 Fix some errors in comments
A comment in tests/stringlist.c refers to fdt_get_string(), which is not a
function that exists.  From the content, it's supposed to be referring to
fdt_getprop_string().

A comment in libfdt.h has an extraneous space in a function name.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-10-26 09:25:14 +02:00
Reiner Huober
48c91c08bc libfdt: add stringlist functions to linker script
The fdt_stringlist_count, fdt_stringslist_search, and fdt_stringlist_get
are added to the libfdt linker script as global symbols

Signed-off-by: Reiner Huober <reiner.huober@nokia.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-10-05 17:33:54 +11:00
Pantelis Antoniou
1bb00655d3 fdt: Allow stacked overlays phandle references
This patch enables an overlay to refer to a previous overlay's
labels by performing a merge of symbol information at application
time.

In a nutshell it allows an overlay to refer to a symbol that a previous
overlay has defined. It requires both the base and all the overlays
to be compiled with the -@ command line switch so that symbol
information is included.

base.dts
--------

	/dts-v1/;
	/ {
		foo: foonode {
			foo-property;
		};
	};

	$ dtc -@ -I dts -O dtb -o base.dtb base.dts

bar.dts
-------

	/dts-v1/;
	/plugin/;
	/ {
		fragment@1 {
			target = <&foo>;
			__overlay__ {
				overlay-1-property;
				bar: barnode {
					bar-property;
				};
			};
		};
	};

	$ dtc -@ -I dts -O dtb -o bar.dtb bar.dts

baz.dts
-------

	/dts-v1/;
	/plugin/;
	/ {
		fragment@1 {
			target = <&bar>;
			__overlay__ {
				overlay-2-property;
				baz: baznode {
					baz-property;
				};
			};
		};
	};

	$ dtc -@ -I dts -O dtb -o baz.dtb baz.dts

Applying the overlays:

	$ fdtoverlay -i base.dtb -o target.dtb bar.dtb baz.dtb

Dumping:

	$ fdtdump target.dtb
	/ {
            foonode {
                overlay-1-property;
                foo-property;
                linux,phandle = <0x00000001>;
                phandle = <0x00000001>;
                barnode {
                    overlay-2-property;
                    phandle = <0x00000002>;
                    linux,phandle = <0x00000002>;
                    bar-property;
                    baznode {
                        phandle = <0x00000003>;
                        linux,phandle = <0x00000003>;
                        baz-property;
                    };
                };
            };
            __symbols__ {
                baz = "/foonode/barnode/baznode";
                bar = "/foonode/barnode";
                foo = "/foonode";
            };
	};

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-08-09 17:18:47 +10:00
Pantelis Antoniou
a33c2247ac Introduce fdt_setprop_placeholder() method
In some cases you need to add a property but the contents of it
are not known at creation time, merely the extend of it.

This method allows you to create a property of a given size (filled
with garbage) while a pointer to the property data will be provided.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
[dwg: Corrected commit message]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-07-28 14:34:36 +10:00
Simon Glass
9067ee4be0 Fix a few whitespace and style nits
These were noticed when synching with U-Boot's downstream tree.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-04-09 20:56:37 +10:00
Simon Glass
580a9f6c28 Add a libfdt function to write a property placeholder
The existing function to add a new property to a tree being built requires
that the entire contents of the new property be passed in. For some
applications it is more convenient to be able to add the property contents
later, perhaps by reading from a file. This avoids double-buffering of the
contents.

Add a new function to support this and adjust the existing fdt_property() to
use it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-04-02 13:38:46 +10:00
Simon Glass
8cb3896358 Adjust libfdt.h to work with swig
There are a few places where libfdt.h cannot be used as is with swig:

- macros like fdt_totalsize() have to be defined as C declarations
- fdt_offset_ptr() and fdt_getprop_namelen() need special treatment due to
    a TODO in the wrapper for fdt_getprop(). However they are not useful to
    Python so can be removed

Add #ifdefs to work around these problem.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-21 16:21:58 +11:00
Nicolas Iooss
921cc17fec libfdt: overlay: Check the value of the right variable
overlay_update_local_node_references() saves the result of
fdt_subnode_offset() into variable tree_child but checks for variable
ret afterwards. As this does not make sense, check tree_child instead of
ret.

This bug has been found by compiling with clang. The compiler reported
the following warning:

    libfdt/fdt_overlay.c:275:7: error: variable 'ret' may be
    uninitialized when used here
          [-Werror,-Wconditional-uninitialized]
                    if (ret == -FDT_ERR_NOTFOUND)
                        ^~~
    libfdt/fdt_overlay.c:210:9: note: initialize the variable 'ret' to
    silence this
          warning
            int ret;
                   ^
                    = 0

Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-06 14:19:26 +11:00
David Gibson
881012e443 libfdt: Change names of sparse helper macros
The default libfdt_env.h (for POSIXish userland builds) supports sparse
checking.  It has a couple of helper macros, __force and __bitwise which
expand the relevant sparse attributes to enable checking for incorrect
or missing endian conversions.

Those are bad names: for one, leading underscores are supposed to be
reserved for the system libraries, and worse, some systems (including
RHEL7) do define those names already.

So change them to FDT_FORCE and FDT_BITWISE which are far less likely to
have collisions.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-06 12:16:56 +11:00
David Gibson
bad5b28049 Fix assorted sparse warnings
This fixes a great many sparse warnings on the fdt and libfdt sources.
These are mostly due to incorrect mixing of endian annotated and native
integer types.

This includes fixing a couple of quasi-bugs where we had endian conversions
the wrong way around (this will have the right effect in practice, but is
certainly conceptually incorrect).

This doesn't make the whole tree sparse clean: there are many warnings in
bison and lex generated code, and there are a handful of other remaining
warnings that are (for now) more trouble than they're worth to fix (and
are not genuine bugs).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-03-06 12:08:53 +11:00
David Gibson
397d5ef020 libfdt: Add fdt_setprop_empty()
Device trees can contain empty (zero length) properties, which are often
used as boolean flags.  These can already be created using fdt_setprop()
passing a length of zero and a pointer which is ignored.  It is safe to
pass NULL, but that may not be obvious from the interface.  To make it
clearer, add an fdt_setprop_empty() helper macro.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-02-24 11:12:50 +11:00
David Gibson
69a1bd6ad3 libfdt: Remove undefined behaviour setting empty properties
The standard way of setting an empty property using libfdt is:
    fdt_setprop(fdt, nodeoffset, propname, NULL, 0);
However, the implementation of this includes an unconditional:
     memcpy(prop->data, NULL, 0);
Which although it will be a no-op (which is what we want) on many platforms
is technically undefined behaviour.  Correct this, so that when passing
a 0 length, passing a NULL pointer as the value to fdt_setprop() is
definitely safe.  This should quiet static checkers which complain about
this.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-02-24 10:51:05 +11:00
David Gibson
7d8ef6e1db tests: Correct fdt handling of overlays without fixups and base trees without symbols
The fdt_overlay_apply() function purports to support the edge cases where
an overlay has no fixups to be applied, or a base tree which has no
symbols (the latter can only work if the former is also true).  However it
gets it wrong in a couple of small ways:

  * In the no fixups case, it doesn't fail immediately, but will attempt
    fdt_for_each_property_offset() giving -FDT_ERR_NOTFOUND as the node
    offset, which will fail.  Instead it should succeed immediately, since
    there's nothing to do.
  * In the case of no symbols, it again doesn't fail immediately.  However
    if there is an actual fixup it will fail with an unexpected error,
    because -FDT_ERR_NOTFOUND is passed to fdt_getprop() when attempting to
    look up the symbols.  We should instead return -FDT_ERR_NOTFOUND
    directly.

Both of these errors lead to the code returning misleading error codes in
failing cases.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-12-09 16:13:29 +11:00
Benjamin Fair
ea10f95387 libfdt: add missing errors to fdt_strerror()
Some error values were missing from the table which meant that they could
not be translated by fdt_strerror().

Signed-off-by: Benjamin Fair <b-fair@ti.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-11-04 07:17:20 +11:00
Masahiro Yamada
daa75e8fa5 libfdt: fix fdt_stringlist_search()
If fdt_getprop() fails, negative error code should be returned.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-10-17 20:56:58 +11:00
Masahiro Yamada
e28eff5b78 libfdt: fix fdt_stringlist_count()
If fdt_getprop() fails, negative error code should be returned.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-10-17 20:56:58 +11:00
Maxime Ripard
5ce8634733 libfdt: Add fdt_overlay_apply to the exported symbols
fdt_overlay_apply was not usable in the shared library. Export it to allow
its use.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-10-11 20:08:38 +11:00
Maxime Ripard
804a9db90a fdt: strerr: Remove spurious BADOVERLAY
There's one FDT_ERR_BADOVERLAY too many in the fdt error table.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-10-11 20:08:38 +11:00
Maxime Ripard
7a72d89d3f libfdt: overlay: Fix symbols and fixups nodes condition
Some base device tree might not have any __symbols__ nodes, since they
might not have any phandle at all.

Similarly, if an overlay doesn't use any base device tree phandles, its
__fixups__ node will be empty.

In such cases, we don't want to stop the phandle parsing, but rather just
ignore the error reported about the missing node.

If it's actually an issue for the overlay we're trying to apply on a given
base device tree, it will be caught later on, but we cannot make the
assumption that early in the application process.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-10-07 12:28:58 +11:00
Maxime Ripard
cabbaa972c libfdt: overlay: Report a bad overlay for mismatching local fixups
The __local_fixups__ node as a structure that mimics the structure of the
main overlay part.

This means that if we have a child node somewhere in the local fixups
sub-tree and if that node is not present in the main tree, the overlay is
poorly formatted, and we should report it as such.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-10-07 12:28:58 +11:00
Maxime Ripard
deb0a5c1ae libfdt: Add BADPHANDLE error string
The BADPHANDLE error was missing a string, leading to an <unknown error>
string being returned if you were to call fdt_strerror.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-10-07 12:28:58 +11:00
David Gibson
7b7a6be9ba libfdt: Don't use 'index' as a local variable name
Using 'index' as a local variable name shadows the standard library index()
function.  This causes warnings on at least some compiler versions.  The
recently added overlay code has a number of instances of this.

This patch replaces 'index' with 'poffset', since 'index' is being used to
mean "offset within a property value" in these cases.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-10-06 20:45:14 +11:00
Maxime Ripard
0cdd06c513 libfdt: Add overlay application function
The device tree overlays are a good way to deal with user-modifyable
boards or boards with some kind of an expansion mechanism where we can
easily plug new board in (like the BBB, the Raspberry Pi or the CHIP).

Add a new function to merge overlays with a base device tree.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-10-06 19:22:41 +11:00
Maxime Ripard
39240cc865 libfdt: Extend the reach of FDT_ERR_BADPHANDLE
So far, the BADPHANDLE error was only used for incorrect phandle values.
Extend that meaning to an improperly formatted phandle property.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-10-06 19:22:41 +11:00
Maxime Ripard
4aa3a6f5e6 libfdt: Add new errors for the overlay code
Add a few new error codes to report the failure conditions we might
encounter in the overlay application code:
   - FDT_ERR_BADOVERLAY, when an overlay cannot be parsed, even though its
     structure is correct
   - FDT_ERR_NOPHANDLES, when we ran out of available phandles and we
     cannot use a new phandle without either using an invalid one (-1 or
     0), or one already used.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-10-06 19:22:41 +11:00
Thomas Huth
45fd440a95 Fix some typing errors in libfdt.h and livetree.c
Correct some typos discovered with the codespell utility.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-09-27 11:32:46 +10:00
Masahiro Yamada
36fd7331fb libfdt: simplify fdt_del_mem_rsv()
The variable "err" is unneeded.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-08-22 06:53:54 -04:00
Maxime Ripard
d877364e4a libfdt: Add fdt_setprop_inplace_namelen_partial
Add a function to modify inplace only a portion of a property..

This is especially useful when the property is an array of values, and you
want to update one of them without changing the DT size.

Acked-by: Simon Glass <sjg@chromium.org>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
[dwg: Remove unnecessary unsigned qualifier, correct a comment]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-08-01 13:34:39 +10:00
Maxime Ripard
3e9037aaad libfdt: Add fdt_getprop_namelen_w
Add a function to retrieve a writeable property only by the first
characters of its name.

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-07-28 15:29:16 +10:00
Maxime Ripard
84e0e1346c libfdt: Add max phandle retrieval function
Add a function to retrieve the highest phandle in a given device tree.

Acked-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Agner <stefan@agner.ch>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-07-28 15:29:16 +10:00
Maxime Ripard
d29126c90a libfdt: Add iterator over properties
Implement a macro based on fdt_first_property_offset and
fdt_next_property_offset that provides a convenience to iterate over all
the properties of a given node.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Simon Glass <sjg@chromium.org>
[dwg: Removed a stray trailing blank line]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-07-28 15:29:13 +10:00
Thierry Reding
902d0f0953 libfdt: Add a subnodes iterator macro
The fdt_for_each_subnode() iterator macro provided by this patch can be
used to iterate over a device tree node's subnodes. At each iteration a
loop variable will be set to the next subnode.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-07-28 15:27:57 +10:00
Simon Glass
beef80b8b5 Correct a missing space in a fdt_header cast
The code style here is slightly incorrect. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-03-07 15:34:00 +11:00
Simon Glass
68d43cec12 Correct line lengths in libfdt.h
There are a few lines that are over 80 columns. Fix these.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-03-07 15:33:59 +11:00
Simon Glass
b0dbceafd4 Correct space-after-tab in libfdt.h
There are a few places with a space before a tab in this file. Fix them.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-03-07 15:33:59 +11:00
Masahiro Yamada
53bf130b1c libfdt: simplify fdt_node_check_compatible()
Because fdt_stringlist_contains() returns 1 or 0,
fdt_node_check_compatible() can just return the inverted value.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-02-20 11:29:14 +11:00
David Gibson
d0b3ab0a0f libfdt: Fix undefined behaviour in fdt_offset_ptr()
Using pointer arithmetic to generate a pointer outside a known object is,
technically, undefined behaviour in C.  Unfortunately, we were using that
in fdt_offset_ptr() to detect overflows.

To fix this we need to do our bounds / overflow checking on the offsets
before constructing pointers from them.

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-12-17 17:19:11 +11:00
Courtney Cavin
d4c7c25c9e libfdt: check for potential overrun in _fdt_splice()
This patch catches the conditions where:
 - 'splicepoint' is set to a point outside of [ fdt, fdt_totalsize(fdt) )
 - 'newlen' is negative, or 'splicepoint' plus 'newlen' results in overflow

Either of these cases can be caused by math which overflows in calling
functions, or by sizes specified through dynamic means.

Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
2015-12-02 13:11:11 +11:00
David Gibson
f58799be13 libfdt: Add some missing symbols to version.lds
Several functions in the header file were missing from the version.lds
script, meaning that they couldn't be used from a libfdt shared library.

Reported by Ken Aaker, via github issue tracker.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-12-01 12:55:21 +11:00
Thierry Reding
604e61e081 fdt: Add functions to retrieve strings
Given a device tree node, a property name and an index, the new function
fdt_stringlist_get() will return a pointer to the index'th string in the
property's value and return its length (or an error code on failure) in
an output argument.

Signed-off-by: Thierry Reding <treding@nvidia.com>
[Fix some -Wshadow warnings --dwg]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-09-30 13:26:31 +10:00
Thierry Reding
8702bd1d3b fdt: Add a function to get the index of a string
The new fdt_stringlist_search() function will look up a given string in
the list contained in the value of a named property of a given device
tree node and return its index.

Signed-off-by: Thierry Reding <treding@nvidia.com>
[Fix some -Wshadow warnings --dwg]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-09-30 13:26:18 +10:00
Thierry Reding
2218387a8c fdt: Add a function to count strings
Given a device tree node and a property name, the fdt_stringlist_count()
function counts the number of strings found in the property value.

This also adds a new error code, FDT_ERR_BADVALUE, that the function
returns when it encounters a non-NUL-terminated string list.

Signed-off-by: Thierry Reding <treding@nvidia.com>
[Changed testcase name --dwg]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-09-30 13:16:35 +10:00
Masahiro Yamada
554fde2c77 libfdt: fix comment block of fdt_get_property_namelen()
The statement "Identical to fdt_get_property_namelen() ..." does not
make sense for the comment of fdt_get_property_namelen() itself.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-08-27 17:14:15 +10:00
Peter Hurley
b4150b59ae libfdt: Add fdt_path_offset_namelen()
Properties may contain path names which are not NUL-terminated.
For example, the 'stdout-path' property allows the form 'path:options',
where the ':' character terminates the path specifier.

Allow these path names to be used in-place for path descending;
add fdt_path_offset_namelen(), which limits the path name to 'namelen'
characters.

Reimplement fdt_path_offset() as a trivial wrapper.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
2015-04-07 14:11:47 +10:00
Julien Grall
a4b093f736 libfdt: Add missing functions to shared library
The commit 4e76ec7 "libfdt: Add fdt_next_subnode() to permit easy
subnode iteration" adds new functions (fdt_{first,next}_subnode) but
forgot to mark them as 'global' in the shared library.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
2015-03-18 11:40:19 +11:00
David Gibson
40f7f576c8 libfdt: Add helpers to read #address-cells and #size-cells
This patch makes a small start on libfdt functions which actually help to
parse the contents of device trees, rather than purely manipulating the
tree's structure.

We add simple helpers to read and sanity check the #address-cells and
#size-cells values for a given node.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-05-12 16:01:09 +10:00
Florian Fainelli
3a584d4760 libfdt: avoid shadowing "err" in FDT_RW_CHECK_HEADER
FDT_RW_CHECK_HEADER declares an internal variable named "err" which is
far too generic and will produce the following -Wshadow warnings:

libfdt/fdt_rw.c: In function 'fdt_add_mem_rsv':
libfdt/fdt_rw.c:177:2: error: declaration of 'err' shadows a previous
local [-Werror=shadow]
libfdt/fdt_rw.c:175:6: error: shadowed declaration is here
[-Werror=shadow]
libfdt/fdt_rw.c: In function 'fdt_del_mem_rsv':
libfdt/fdt_rw.c:194:2: error: declaration of 'err' shadows a previous
local [-Werror=shadow]
libfdt/fdt_rw.c:192:6: error: shadowed declaration is here
[-Werror=shadow]
libfdt/fdt_rw.c: In function 'fdt_set_name':
...

Since this variable is only used internally in the macro, rename to
__err which should be prefixed enough not to cause new shadow warnings.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
2014-01-25 15:11:20 +11:00
Florian Fainelli
89c9af5481 libfdt: avoid shadowing "err" in FDT_CHECK_HEADER
FDT_CHECK_HEADER declares an internal variable named "err" whose name is
far too generic and will produce the following -Wshadow warnings:

libfdt/fdt_ro.c: In function 'fdt_node_offset_by_compatible':
libfdt/fdt_ro.c:555:2: error: declaration of 'err' shadows a previous
local [-Werror=shadow]
libfdt/fdt_ro.c:553:14: error: shadowed declaration is here
[-Werror=shadow]
cc1: all warnings being treated as errors

Since this variable is only used internally in the macro, rename to
__err which should be prefixed enough not to cause new shadow warnings.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
2014-01-25 15:11:20 +11:00