]> git.ozlabs.org Git - petitboot/blobdiff - discover/grub2/grub2.c
ui/ncurses: Use pmenu_item destrutor to free ncurses ITEMs
[petitboot] / discover / grub2 / grub2.c
index 9a4612714312c419fcf1efc1cc0eeb7776f78632..5b3009a465f7d43ac8f351c00aac7b1075fbd24b 100644 (file)
@@ -1,5 +1,6 @@
 
 #include <assert.h>
+#include <string.h>
 
 #include <talloc/talloc.h>
 #include <url/url.h>
@@ -9,8 +10,6 @@
 #include <discover/parser-utils.h>
 
 #include "grub2.h"
-#include "parser.h"
-#include "lexer.h"
 
 static const char *const grub2_conf_files[] = {
        "/grub.cfg",
@@ -87,7 +86,7 @@ bool resolve_grub2_resource(struct device_handler *handler,
 }
 
 static int grub2_parse(struct discover_context *dc)
-       {
+{
        const char * const *filename;
        struct grub2_parser *parser;
        int len, rc;
@@ -97,18 +96,18 @@ static int grub2_parse(struct discover_context *dc)
        if (dc->event)
                return -1;
 
-       parser = grub2_parser_create(dc);
-
        for (filename = grub2_conf_files; *filename; filename++) {
                rc = parser_request_file(dc, dc->device, *filename, &buf, &len);
                if (rc)
                        continue;
 
-               grub2_parser_parse(parser, buf, len);
+               parser = grub2_parser_create(dc);
+               grub2_parser_parse(parser, *filename, buf, len);
                talloc_free(buf);
+               talloc_free(parser);
+               break;
        }
 
-       talloc_free(parser);
 
        return 0;
 }