mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
dtc: Disable semantic checks by default
At present, dtc makes a lot of semantic checks on the device tree by default, and will refuse to produce output if they fail. This means people tend to need -f to force output despite failing semantic checks rather a lot. This patch splits the device tree checks into structural checks (no bad or duplicate names or phandles) and semantic checks (everything else). By default, only the structural checks are performed, and are fatal. -f will force output even with structural errors (using this in -Idts mode would essentially always be a bad idea, but it might be useful in -Idtb mode for examining a malformed dtb). Semantic checks are only performed if the new -c command line option is supplied, and are always warnings only. Semantic checks will never be performed on a tree with structural errors. This patch is only a stopgap before implementing proper fine-grained error/warning handling, but it should at least get rid of the far-too-frequent need for -f for the time being. This patch removes the -f from the dtc testcases now that it's no longer necessary. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
394e47208d
commit
169f0b183d
4 changed files with 217 additions and 192 deletions
31
dtc.c
31
dtc.c
|
@ -112,19 +112,20 @@ int main(int argc, char *argv[])
|
|||
char *inform = "dts";
|
||||
char *outform = "dts";
|
||||
char *outname = "-";
|
||||
int force = 0;
|
||||
int force = 0, check = 0;
|
||||
char *arg;
|
||||
int opt;
|
||||
FILE *inf = NULL;
|
||||
FILE *outf = NULL;
|
||||
int outversion = DEFAULT_FDT_VERSION;
|
||||
int boot_cpuid_phys = 0xfeedbeef;
|
||||
int structure_ok;
|
||||
|
||||
quiet = 0;
|
||||
reservenum = 0;
|
||||
minsize = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:fqb:v")) != EOF) {
|
||||
while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:fcqb:v")) != EOF) {
|
||||
switch (opt) {
|
||||
case 'I':
|
||||
inform = optarg;
|
||||
|
@ -147,6 +148,9 @@ int main(int argc, char *argv[])
|
|||
case 'f':
|
||||
force = 1;
|
||||
break;
|
||||
case 'c':
|
||||
check = 1;
|
||||
break;
|
||||
case 'q':
|
||||
quiet++;
|
||||
break;
|
||||
|
@ -189,12 +193,25 @@ int main(int argc, char *argv[])
|
|||
if (! bi || ! bi->dt)
|
||||
die("Couldn't read input tree\n");
|
||||
|
||||
if (! check_device_tree(bi->dt, outversion, boot_cpuid_phys)) {
|
||||
if ((force) && (quiet < 3))
|
||||
fprintf(stderr, "Input tree has errors, output forced\n");
|
||||
if (! force) {
|
||||
fprintf(stderr, "Input tree has errors, not writing output (use -f to force output)\n");
|
||||
structure_ok = check_structure(bi->dt);
|
||||
if (!structure_ok) {
|
||||
if (!force) {
|
||||
fprintf(stderr, "ERROR: Input tree has structural errors, aborting (use -f to force output)\n");
|
||||
exit(1);
|
||||
} else if (quiet < 3) {
|
||||
fprintf(stderr, "Warning: Input tree has structural errors, output forced\n");
|
||||
}
|
||||
}
|
||||
|
||||
fixup_references(bi->dt);
|
||||
|
||||
if (check) {
|
||||
if (!structure_ok) {
|
||||
fprintf(stderr, "Warning: Skipping semantic checks due to structural errors\n");
|
||||
} else {
|
||||
if (!check_semantics(bi->dt, outversion,
|
||||
boot_cpuid_phys))
|
||||
fprintf(stderr, "Warning: Input tree has semantic errors\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue