Commit graph

20 commits

Author SHA1 Message Date
Dan Horák
49903aed77 use ptrdiff_t modifier for printing pointer differences
Use ptrdiff_t modifier (%tx) for printing a difference between 2 pointers. Currently
%zx (size_t) is used, but it fails on platforms where size_t and ptrdiff_t are
defined differently (like s390).

Comes from
f3da2d1b00
originally.

Signed-off-by: Dan Horák <dan@danny.cz>
2018-10-23 15:26:52 +02:00
David Gibson
180a939240 Use <inttypes.h> format specifiers in a bunch of places we should
Rather than assuming that uint32_t is the same thing as unsigned.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-06-07 11:49:17 +10:00
nixiaoming
b9af3b3965 scripts/dtc: Fixed format mismatch in fprintf
format specifier "d" need arg type "int" , but the according arg
"fdt32_to_cpu(xxx)" has type "unsigned int"

Signed-off-by: nixiaoming <nixiaoming@huawei.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-06-07 11:49:17 +10:00
David Gibson
fb9c6abdda Use size_t for blob lengths in utilfdt_read*
It's more appropriate than off_t since it is, after all, a size not an
offset.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2018-06-07 11:49:17 +10:00
David Gibson
6473a21d8b Consolidate utilfdt_read_len() variants
There are no less than _four_ variants on utilfdt_read() which is a bit
excessive.  The _len() variants are particularly pointless, since we can
achieve the same thing with very little extra verbosity by using the usual
convention of ignoring return parameters if they're NULL.  So, get rid of
them (we keep the shorter names without _len, but add now-optional len
parameters).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2018-06-07 11:48:20 +10:00
David Gibson
548aea2c43 fdtdump: Discourage use of fdtdump
fdtdump is, and always has been, a quick-and-dirty debugging tool.  However
I keep getting reports of people using it for real work.  For production
decompiling of a dtb, dtc in -I dtb -O dts mode is the right tool. In the
hopes of getting that message out there, add a warning message to fdtdump
to discourage its use.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-04-18 13:05:08 +10:00
David Gibson
c2258841a7 fdtdump: Fix over-zealous version check
It's perfectly valid for a dtb to have version and last compat version set
to the same value, and that value can be 17 (the latest defined version).
However, since 0931cea "dtc: fdtdump: check fdt if not in scanning mode"
fdtdump will refuse to process such a dtb.  We get away with this in many
cases because dtc's typical output has last compat version equal to 16,
rather than 17, but it's still a bug.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-04-18 12:52:08 +10: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
Heinrich Schuchardt
0931cea3ba dtc: fdtdump: check fdt if not in scanning mode
Running fdtdump without scan mode for an invalid file often
results in a segmentation fault because the fdt header is
not checked.

With the patch the header is checked both in scanning as
well as in non-scanning mode.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[dwg: Removed unnecessary inline, changed type from int to bool]
Reviewed-by: Simon Glass <sjg@chromium.org>
2016-12-27 09:44:17 +11:00
Jean-Christophe Dubois
e24d39a024 fdtdump.c: make sure size_t argument to memchr is always unsigned.
CID 132817 (#1 of 1): Integer overflowed argument (INTEGER_OVERFLOW)
15. overflow_sink: Overflowed or truncated value (or a value computed from an overflowed or truncated value) endp - p - 4L used as critical argument to function.

Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-07-24 00:38:00 +10:00
Phil Elwell
242c264270 Improve portability
1) Remove the double parentheses around two comparisons in checks.c.
   The OSX LLVM-based C compiler warns about them.
2) Put an explicit "=" in the TN() macro, in accordance with c99.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2014-10-24 11:45:41 +02:00
Simon Glass
dfcfb7f169 Correct output from memreserve in fdtdump
This currently displays a hex value without the 0x prefix. Add the prefix
as dtc requires it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2014-06-18 21:02:51 +10:00
Mike Frysinger
8ec013ae63 fdtdump: add a debug mode
When hacking raw fdt files, it's useful to know the actual offsets into
the file each node appears.  Add a --debug mode that includes this.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2013-05-24 18:20:53 +10:00
Mike Frysinger
b9e80656f2 util: drop "long" from usage helpers
Now that all utils have converted to the new usage framework, we can
rename to just plain "usage()" and avoid naming conflicts.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2013-05-24 18:20:53 +10:00
Mike Frysinger
fdc7387845 fdtdump: add a --scan option
Often times, fdts get embedded in other larger files.  Rather than force
people to `dd` the blob out themselves, make the fdtdump file smarter.

It can now scan the blob looking for the fdt magic.  Once locate, it does
a little validation on the main struct to make sure we didn't hit random
binary data.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2013-05-24 18:20:53 +10:00
Mike Frysinger
be8d1c82cb fdtdump: make usage a bit more friendly
This starts a new usage framework and then cuts fdtdump over to it.
Now we can do `fdtdump -h` and get something useful back.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2013-05-24 18:20:53 +10:00
Simon Glass
d20391d6ff Move property-printing into util
The function that prints a property can be useful to other programs,
so move it into util.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
2013-01-27 14:20:56 -06:00
Kim Phillips
20b866a7ce dtc/fdtdump: include libfdt_env.h prior to fdt.h
in order to get the upcoming fdt type definitions.

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
2013-01-06 15:50:25 -06:00
Pantelis Antoniou
94a4799b20 fdtdump: properly handle multi-string properties
Device tree can store multiple strings in a single property.
We didn't handle that case properly.

Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
2013-01-06 15:35:10 -06:00
Mike Frysinger
8f459c5d72 fdtdump: rename from ftdump
The freetype package already installs a binary named "ftdump", so the dtc
package conflicts with that.  So rename the newer dtc tool to "fdtdump".
This even makes a bit more sense:
	ftdump: [F]lat device [T]ree [dump]
	fdtdump: [F]lat [D]evice [T]ree [dump]

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
2011-10-26 08:07:51 -05:00
Renamed from ftdump.c (Browse further)