X-Git-Url: https://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fboot.c;h=6095cd8d865f8e02cc350b7665371b9771472e50;hp=8ad83beb6a98673ecfea8844406da4c0f662078f;hb=748bd3f1bd8ffff60653f7a54f51cc5f63696c68;hpb=51c6aaf7864eb65779d548ee2549caa357f71e2c diff --git a/discover/boot.c b/discover/boot.c index 8ad83be..6095cd8 100644 --- a/discover/boot.c +++ b/discover/boot.c @@ -121,17 +121,23 @@ static int kexec_reboot(struct boot_task *task) return result; } -static void update_status(boot_status_fn fn, void *arg, int type, - char *message) +static void __attribute__((format(__printf__, 4, 5))) update_status( + boot_status_fn fn, void *arg, int type, char *fmt, ...) { struct boot_status status; + va_list ap; + + va_start(ap, fmt); + status.message = talloc_vasprintf(NULL, fmt, ap); + va_end(ap); status.type = type; - status.message = message; status.progress = -1; status.detail = NULL; fn(arg, &status); + + talloc_free(status.message); } static void boot_hook_update_param(void *ctx, struct boot_task *task, @@ -290,7 +296,7 @@ int boot(void *ctx, struct discover_boot_option *opt, struct boot_command *cmd, } else if (opt && opt->boot_image) { image = opt->boot_image->url; } else { - pb_log("%s: no image specified", __func__); + pb_log("%s: no image specified\n", __func__); return -1; } @@ -371,8 +377,6 @@ no_load: if (clean_dtb) unlink(boot_task->local_dtb); - talloc_free(boot_task); - if (!result) { update_status(status_fn, status_arg, BOOT_STATUS_INFO, "performing kexec reboot"); @@ -385,5 +389,7 @@ no_load: } } + talloc_free(boot_task); + return result; }