From 1ca48210fb7bae627799c3a894ed9e029cf95fb3 Mon Sep 17 00:00:00 2001 From: Daan Date: Sun, 19 Dec 2021 10:01:53 -0800 Subject: [PATCH] small rewrite of pr #506 --- src/options.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/options.c b/src/options.c index a2ffcbf1..8b4d07e8 100644 --- a/src/options.c +++ b/src/options.c @@ -545,19 +545,18 @@ static void mi_option_init(mi_option_desc_t* desc) { desc->init = INITIALIZED; } else { - /* _mi_warning_message() will itself call mi_option_get() for some options, - * so to avoid a possible infinite recursion it's important to mark the option as - * "initialized" first */ + // set `init` first to avoid recursion through _mi_warning_message on mimalloc_verbose. desc->init = DEFAULTED; - if (desc->option == mi_option_verbose) { - /* Special case: if the 'mimalloc_verbose' env var has a bogus value we'd never know - * (since the value default to 'off') - so in that one case briefly set the option to 'on' */ + if (desc->option == mi_option_verbose && desc->value == 0) { + // if the 'mimalloc_verbose' env var has a bogus value we'd never know + // (since the value defaults to 'off') so in that case briefly enable verbose desc->value = 1; - } - _mi_warning_message("environment option mimalloc_%s has an invalid value: %s\n", desc->name, buf); - if (desc->option == mi_option_verbose) { + _mi_warning_message("environment option mimalloc_%s has an invalid value: %s\n", desc->name, buf); desc->value = 0; } + else { + _mi_warning_message("environment option mimalloc_%s has an invalid value: %s\n", desc->name, buf); + } } } mi_assert_internal(desc->init != UNINIT);