From 5194209a4f77d52c5d404b10e5670cbb35558c44 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 20 Jul 2022 11:49:22 -0700 Subject: main: show --seed with print_setup_as_args() The purpose of printing the setup is to enable reproducing it, the seed is part of that reconstruction - especially when it's been autogenerated. --- src/main.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index f786818..7f6557b 100644 --- a/src/main.c +++ b/src/main.c @@ -248,27 +248,36 @@ _err: } +static char * seed_as_arg(unsigned seed) +{ + char arg[sizeof("0x") + sizeof(seed) * 2]; + + snprintf(arg, sizeof(arg), "0x%x", seed); + + return strdup(arg); +} + + static int print_setup_as_args(setup_t *setup) { - char *module_args, *video_args; + char *seed_arg, *module_args, *video_args; char buf[64]; - int r; - - module_args = til_settings_as_arg(setup->module_settings); - if (!module_args) { - r = -ENOMEM; + int r = -ENOMEM; + seed_arg = seed_as_arg(setup->seed); + if (!seed_arg) goto _out; - } - video_args = til_settings_as_arg(setup->video_settings); - if (!video_args) { - r = -ENOMEM; + module_args = til_settings_as_arg(setup->module_settings); + if (!module_args) + goto _out_seed; + video_args = til_settings_as_arg(setup->video_settings); + if (!video_args) goto _out_module; - } - r = printf("\nConfigured settings as flags:\n --module=%s --video=%s\n\nPress enter to continue, add --go to disable this notice...\n", + r = printf("\nConfigured settings as flags:\n --seed=%s --module=%s --video=%s\n\nPress enter to continue, add --go to disable this notice...\n", + seed_arg, module_args, video_args); @@ -281,6 +290,8 @@ _out_video: free(video_args); _out_module: free(module_args); +_out_seed: + free(seed_arg); _out: return r; } -- cgit v1.2.3