summaryrefslogtreecommitdiff
path: root/fstree.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix a filehandle leakMartin Ettl2010-07-141-0/+1
| | | | | | | | | | | | | | | During a check of the current git head of the linux kernel with the static code analysis tool cppcheck (http://sourceforge.net/apps/mediawiki/cppcheck/index.php?title=Main_Page) the tool discovered a resource leak in linux-2.6/scripts/dtc/fstree.c. Please refer the attached patch, that fixes the issue. Fixes https://bugzilla.kernel.org/show_bug.cgi?id=15363 Signed-off-by: Martin Ettl <ettl.martin@gmx.de> Signed-off-by: Michal Marek <mmarek@suse.cz> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Allow multiple labels on nodes and propertiesDavid Gibson2010-02-241-5/+3
| | | | | | | | | | | | | | | | | At present, both the grammar and our internal data structures mean that there can be only one label on a node or property. This is a fairly arbitrary constraint, given that any number of value labels can appear at the same point, and that in C you can have any number of labels on the same statement. This is pretty much a non-issue now, but it may become important with some of the extensions that Grant and I have in mind. It's not that hard to change, so this patch does so, allowing an arbitrary number of labels on any given node or property. As usual a testcase is added too. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Acked-by: Grant Likely <grant.likely@secretlab.ca>
* dtc: Automatically pick a sensible boot_cpuid_physDavid Gibson2010-02-191-1/+1
| | | | | | | | | | | | | | | | | | | | | Currently, when in -Idts -Odtb or -Ifs -Odtb modes, dtc always defaults to using 0 as the value for the boot_cpuid_phys header field. That's correct quite often, but there are some systems where there is no CPU with hardware ID of 0, or where we don't want to use the CPU with hardware ID 0 at all (e.g. for AMP-style partitioning). The only way to override this default currently, is with the -b command line option. This patch improves dtc to instead base the default boot_cpuid_phys value on the reg property of the first listed subnode of /cpus. This means that dtc will get boot_cpuid_phys correct by default in a greater proportion of cases (since the boot cpu is usually listed first, and this way at least the boot_cpuid_phys default will match some existing cpu node). If the node doesn't exist or has an invalid 'reg' property (missing or not 4 bytes in length), then boot_cpuid_phys is set to 0. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Implement and use an xstrdup() functionJon Loeliger2008-10-031-2/+2
| | | | | | | | | | | | | | | | 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>
* dtc: Rework handling of boot_cpuid_physDavid Gibson2008-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, dtc will put the nonsense value 0xfeedbeef into the boot_cpuid_phys field of an output blob, unless explicitly given another value with the -b command line option. As well as being a totally unuseful default value, this also means that dtc won't properly preserve the boot_cpuid_phys field in -I dtb -O dtb mode. This patch reworks things to improve the boot_cpuid handling. The new semantics are that the output's boot_cpuid_phys value is: the value given on the command line if -b is used otherwise the value from the input, if in -I dtb mode otherwise 0 Implementation-wise we do the following: - boot_cpuid_phys is added to struct boot_info, so that structure now contains all of the blob's semantic information. - dt_to_blob() and dt_to_asm() output the cpuid given in boot_info - dt_from_blob() fills in boot_info based on the input blob - The other dt_from_*() functions just record 0, but we can change this easily if e.g. we invent a way of specifying the boot cpu in the source format. - main() overrides the cpuid in the boot_info between input and output if -b is given We add some testcases to check this new behaviour. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Make dtc_open_file() die() if unable to open requested fileDavid Gibson2008-03-231-2/+2
| | | | | | | | | | | | | | | All current callers of dtc_open_file() immediately die() if it returns an error. In a non-interative tool like dtc, it's hard to see what you could sensibly do to recover from a failure to open an input file in any case. Therefore, make dtc_open_file() itself die() if there's an error opening the requested file. This removes the need for error checking at the callsites, and ensures a consistent error message in all cases. While we're at it, change the rror message from fstree.c when we fail to open the input directory to match dtc_open_file()'s error message. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Make -I dtb mode use fill_fullpaths()David Gibson2008-03-231-2/+0
| | | | | | | | | | | | At present -I dts and -I fs modes both use the fill_fullpaths() helper function to fill in the fullpath and basenamelen fields of struct node, which are useful in later parts of the code. -I dtb mode, however, fills these in itself. This patch simplifies flattree.c by making -I dtb mode use fill_fullpaths() like the others. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Add many const qualificationsDavid Gibson2007-12-041-2/+2
| | | | | | | | This adds 'const' qualifiers to many variables and functions. In particular it's now used for passing names to the tree accesor functions. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Whitespace cleanupDavid Gibson2007-09-181-7/+7
| | | | | | | | | | | | This large patch removes all trailing whitespace from dtc (including libfdt, the testsuite and documentation). It also removes a handful of redundant blank lines (at the end of functions, or when there are two blank lines together for no particular reason). As well as anything else, this means that quilt won't whinge when I go to convert the whole of libfdt into a patch to apply to the kernel. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Rework tracking of reserve entries during processing. This is initial workDavid Gibson2005-10-241-1/+1
| | | | to allow more powerful handling of reserve entries.
* Support for specifying memreserve ranges in the source format, based onDavid Gibson2005-07-151-2/+2
| | | | | a patch by Jon Loeliger <jdl AT freescale.com>, although tweaked substantially.
* Initial label support. Also switch to glr-parser mode and get rid ofDavid Gibson2005-06-161-3/+5
| | | | hacks that were necessary without it.
* Initial commitDavid Gibson2005-06-081-0/+92