summaryrefslogtreecommitdiff
path: root/util.c
Commit message (Collapse)AuthorAgeFilesLines
* util: drop "long" from usage helpersMike Frysinger2013-05-241-3/+3
| | | | | | | | 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>
* fdtdump: make usage a bit more friendlyMike Frysinger2013-05-241-0/+54
| | | | | | | | 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>
* utilfdt_read: pass back up the length of data readMike Frysinger2013-04-221-3/+16
| | | | | | | | | For a follow up commit, we want to be able to scan the buffer that was returned to us. In order to do that safely, we need to know how big the buffer actually is, so create a new set of funcs to pass that back. Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* Revert "utilfdt_read: pass back up the length of data read"Jon Loeliger2013-04-221-5/+3
| | | | | This reverts commit cc2c178727cdeca4eb9756637c2e09e50e0856e7. It was the wrong version of the patch.
* util_version: new helper for displaying version infoMike Frysinger2013-04-211-0/+7
| | | | | | | This is so all utilities can have this flag and not just dtc. Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* utilfdt_read: pass back up the length of data readMike Frysinger2013-04-211-3/+5
| | | | | | | | For a follow up commit, we want to be able to scan the buffer that was returned to us. In order to do that safely, we need to know how big the buffer actually is, so pass that back if requested. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* utilfdt_read_err: use xmalloc funcsMike Frysinger2013-04-211-2/+2
| | | | | | | We've got these handy helpers, so let's use them. Acked-by: David Gibson <David@gibson.dropbear.id.au> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* Move property-printing into utilSimon Glass2013-01-271-0/+37
| | | | | | | | 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>
* Fix util_is_printable_stringPantelis Antoniou2013-01-061-7/+13
| | | | | | | The method used did not account for multi-part strings. Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com> Acked-by: David Gibson <david@gibson.dropbear.id.au>
* Fix uninitialized access bug in utilfdt_decode_typeDavid Gibson2012-02-031-1/+4
| | | | | | | | | I just found this little bug with valgrind. strchr() will return true if the given character is '\0'. This meant that utilfdt_decode_type() could take a path which accesses uninitialized data when given the (invalid) format string "L". Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Add fdt read/write utility functionsSimon Glass2011-09-221-0/+142
| | | | | | | | | | | | This adds higher-level libfdt operations for reading/writing an fdt blob from/to a file, as well as a function to decode a data type string as will be used by fdtget, fdtput. This also adds a few tests for the simple type argument supported by utilfdt_decode_type. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Refactor character literal parsing codeAnton Staaf2011-09-091-0/+99
| | | | | | | | | Move the parsing of hex, octal and escaped characters from data.c to util.c where it can be used for character literal parsing within strings as well as for stand alone C style character literals. Signed-off-by: Anton Staaf <robotboy@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
* Split out is_printable_string() into util.cSimon Glass2011-07-171-0/+28
| | | | | | | | This useful function is split out so it will be available to programs other than ftdump. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Correct headers in util.cDavid Gibson2010-03-031-1/+6
| | | | | | | | | | Since util.c is used in programs other than full dtc, it shouldn't include the full dtc.h, just util.h which has prototypes directly relevant to it. This patch makes the change, and also adds includes of the necessary system headers which were previously included indirectly by dtc.h. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Simpler interface to source file managementDavid Gibson2010-01-141-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | This patch cleans up our handling of input files, particularly dts source files, but also (to an extent) other input files such as those used by /incbin/ and those used in -I dtb and -I fs modes. We eliminate the current clunky mechanism which combines search paths (which we don't actually use at present) with the open relative to current source file behaviour, which we do. Instead there's a single srcfile_relative_open() entry point for callers which opens a new input file relative to the current source file (which the srcpos code tracks internally). It doesn't currently do search paths, but we can add that later without messing with the callers, by drawing the search path from a global (which makes sense anyway, rather than shuffling it around the rest of the processing code). That suffices for non-dts input files. For the actual dts files, srcfile_push() and srcfile_pop() wrappers open the file while also keeping track of it as the current source file for future opens. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Implement and use an xstrdup() functionJon Loeliger2008-10-031-0/+30
Many places in dtc use strdup(), but none of them actually check the return value to see if the implied allocation succeeded. This is a potential bug, which we fix in the patch below by replacing strdup() with an xstrdup() which in analogy to xmalloc() will quit with a fatal error if the allocation fails. I felt the introduciton of util.[ch] was a better choice for utility oriented code than directly using srcpos.c for the new string function. This patch is a re-factoring of Dave Gibson's similar patch. Signed-off-by: Jon Loeliger <jdl@freescale.com>