]> git.ozlabs.org Git - petitboot/commitdiff
discover: handle boot_option->device_id entirely within handler
authorJeremy Kerr <jk@ozlabs.org>
Wed, 8 May 2013 13:09:05 +0000 (21:09 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 9 May 2013 00:39:49 +0000 (08:39 +0800)
No need for parsers to populate (or forget to populate, in the case of
most parsers) opt->device_id, as we should do it on finalise.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/device-handler.c
discover/event-parser.c
discover/pxe-parser.c

index 0fc6d75b0e64db0ce0a01773a779fd269663acfc..43171eb7e1d7f0e2f6ec95392d364597dfa8c1cf 100644 (file)
@@ -75,6 +75,7 @@ static void boot_option_finalise(struct discover_boot_option *opt)
        assert(!opt->option->boot_image_file);
        assert(!opt->option->initrd_file);
        assert(!opt->option->icon_file);
+       assert(!opt->option->device_id);
 
        if (opt->boot_image)
                opt->option->boot_image_file = opt->boot_image->url->full;
@@ -82,6 +83,8 @@ static void boot_option_finalise(struct discover_boot_option *opt)
                opt->option->initrd_file = opt->initrd->url->full;
        if (opt->icon)
                opt->option->icon_file = opt->icon->url->full;
+
+       opt->option->device_id = opt->device->device->id;
 }
 
 static void process_boot_option_queue(struct device_handler *handler)
index 45d7b3a3ed56b24fee4f9af904696f530a0ff1ba..240f8976249c13decf3b720f740d2580560553c0 100644 (file)
@@ -64,7 +64,6 @@ int parse_user_event(struct discover_context *ctx, struct event *event)
        }
 
        opt->id = talloc_asprintf(opt, "%s#%s", dev->id, p);
-       opt->device_id = talloc_strdup(opt, dev->id);
        opt->name = talloc_strdup(opt, p);
 
        d_opt->boot_image = user_event_resource(d_opt, event, "image");
index 662716ac075cfe6fe73e6085de986bc08ec1b924..c300b697d0eeb769ab4986bc9e06397d4071cae6 100644 (file)
@@ -28,10 +28,9 @@ static void pxe_process_pair(struct conf_context *ctx,
                opt = discover_boot_option_create(ctx->dc, ctx->dc->device);
                ctx->parser_info = opt;
 
-               opt->option->device_id = ctx->dc->device->device->id;
                opt->option->name = talloc_strdup(opt, value);
                opt->option->id = talloc_asprintf(opt, "%s@%p",
-                               opt->option->device_id, opt);
+                               ctx->dc->device->device->id, opt);
                return;
        }