diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2022-07-20 11:49:22 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2022-07-20 17:50:38 -0700 |
commit | 5194209a4f77d52c5d404b10e5670cbb35558c44 (patch) | |
tree | c5829fa13ec387a18b3ab8b2f7ebc838e85eaec4 | |
parent | ebc59625f2fb8d63f0aaa6a519fb795b101e6003 (diff) |
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.
-rw-r--r-- | src/main.c | 35 |
1 files changed, 23 insertions, 12 deletions
@@ -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; } |