mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
dtc: Make dt_from_blob() open its own input file, like the other input formats
Currently, main() has a variable for the input file. It used to be that main() would open the input based on command line arguments before passing it to the dt_from_*() function. However, only dt_from_blob() uses this. dt_from_source() opens its own file, and dt_from_fs() interprets the argument as as a directory and does its own opendir() call. Furthermore, main() opened the file with dtc_open_file() but closed it with a direct call to fclose(). Therefore, to improve the interface consistency between the dt_from_*() functions, make dt_from_blob() open and close its own files like the other dt_from_*() functions. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
c26015443a
commit
a742aade6a
3 changed files with 22 additions and 22 deletions
16
dtc.c
16
dtc.c
|
@ -118,7 +118,6 @@ int main(int argc, char *argv[])
|
|||
int force = 0, check = 0;
|
||||
const char *arg;
|
||||
int opt;
|
||||
struct dtc_file *inf = NULL;
|
||||
FILE *outf = NULL;
|
||||
int outversion = DEFAULT_FDT_VERSION;
|
||||
int boot_cpuid_phys = 0xfeedbeef;
|
||||
|
@ -186,19 +185,14 @@ int main(int argc, char *argv[])
|
|||
fprintf(stderr, "DTC: %s->%s on file \"%s\"\n",
|
||||
inform, outform, arg);
|
||||
|
||||
if (streq(inform, "dts")) {
|
||||
if (streq(inform, "dts"))
|
||||
bi = dt_from_source(arg);
|
||||
} else if (streq(inform, "fs")) {
|
||||
else if (streq(inform, "fs"))
|
||||
bi = dt_from_fs(arg);
|
||||
} else if(streq(inform, "dtb")) {
|
||||
inf = dtc_open_file(arg, NULL);
|
||||
bi = dt_from_blob(inf->file);
|
||||
} else {
|
||||
else if(streq(inform, "dtb"))
|
||||
bi = dt_from_blob(arg);
|
||||
else
|
||||
die("Unknown input format \"%s\"\n", inform);
|
||||
}
|
||||
|
||||
if (inf && inf->file != stdin)
|
||||
fclose(inf->file);
|
||||
|
||||
fill_fullpaths(bi->dt, "");
|
||||
process_checks(force, bi);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue