diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-09-17 09:34:34 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-09-24 13:14:59 +0800 |
commit | d808f5d2ec8e232d736a5f811d647df91e2a5b43 (patch) | |
tree | 1225debaa3284354c852ed480d1fae04946ab5a9 /discover/grub2 | |
parent | e651a16f85e9df51ed65d96ea32932f69cbf302d (diff) | |
download | talos-petitboot-d808f5d2ec8e232d736a5f811d647df91e2a5b43.tar.gz talos-petitboot-d808f5d2ec8e232d736a5f811d647df91e2a5b43.zip |
discover/grub2: Improve error handling
Only run the script if the parse succeeded, and and improve the
error reporting by enabling verbose errors and line numbers.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/grub2')
-rw-r--r-- | discover/grub2/lexer.l | 1 | ||||
-rw-r--r-- | discover/grub2/parser.y | 7 |
2 files changed, 6 insertions, 2 deletions
diff --git a/discover/grub2/lexer.l b/discover/grub2/lexer.l index 3e1f9fa..6c0a456 100644 --- a/discover/grub2/lexer.l +++ b/discover/grub2/lexer.l @@ -12,6 +12,7 @@ %option stack noyy_top_state %option reentrant %option bison-bridge +%option yylineno %option noyyalloc noyyfree noyyrealloc %option extra-type="struct grub2_parser *" %option header-file="lexer.h" diff --git a/discover/grub2/parser.y b/discover/grub2/parser.y index e13cd72..550c374 100644 --- a/discover/grub2/parser.y +++ b/discover/grub2/parser.y @@ -2,6 +2,7 @@ %pure-parser %lex-param { yyscan_t scanner } %parse-param { struct grub2_parser *parser } +%error-verbose %{ #include <talloc/talloc.h> @@ -244,13 +245,15 @@ struct grub2_parser *grub2_parser_create(struct discover_context *ctx) void grub2_parser_parse(struct grub2_parser *parser, char *buf, int len) { YY_BUFFER_STATE bufstate; + int rc; bufstate = yy_scan_bytes(buf, len - 1, parser->scanner); - yyparse(parser); + rc = yyparse(parser); yy_delete_buffer(bufstate, parser->scanner); - script_execute(parser->script); + if (!rc) + script_execute(parser->script); } |