dtc: Simplify error handling for unparseable input [resend]
Currently, main() tests if it got a valid input tree from whichever dt_from_*() function it invoked and if not, die()s. For one thing, this test has, for no good reason, three different ways for those functions to communicate a failure to provide input (bi NULL, bi->dt NULL, or bi->error non-zero). For another, in every case save one, if the dt_from_*() functions are unable to provide input they will immediately die() (with a more specific error message) rather than proceeding to the test in main().
Therefore, this patch removes this test, making the one case that could have triggered it (in dt_from_source()) call die() directly instead. With this change, the error field in struct boot_info is now unused, so remove it.
Signed-off-by David Gibson <[email protected]>
--- dtc.c | 3 --- dtc.h | 1 - livetree.c | 1 - treesource.c | 6 ++++-- 4 files changed, 4 insertions(+), 7 deletions(-)
dtc.h +0 -1
@@ -232,7 +232,6 @@struct boot_info {struct reserve_info *reservelist;struct node *dt;/* the device tree */ -int error; }; struct boot_info *build_boot_info(struct reserve_info *reservelist,
livetree.c +0 -1
@@ -172,7 +172,6 @@ bi =xmalloc (sizeof (*bi)); bi->reservelist = reservelist; bi->dt = tree; - bi->error =0 ;return bi; }
dtc.c +0 -3
@@ -201,9 +201,6 @@if (inf && inf->file != stdin)fclose (inf->file); -if (! bi || ! bi->dt || bi->error) -die ("Couldn't read input tree\n" ); -fill_fullpaths (bi->dt,"" );process_checks (force, bi);
treesource.c +4 -2
@@ -36,9 +36,11 @@ yyin = srcpos_file->file;if (yyparse () !=0 ) -return NULL ; +die ("Unable to parse input tree\n" ); + +if (treesource_error) +die ("Syntax error parsing input tree\n" ); - the_boot_info->error = treesource_error;return the_boot_info; }
Signature · 8 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson _______________________________________________ Linuxppc-dev mailing list [email protected] https://ozlabs.org/mailman/listinfo/linuxppc-dev