Skip to content

Commit 1ca4821

Browse files
committed
small rewrite of pr #506
1 parent 6424cfa commit 1ca4821

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/options.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -545,19 +545,18 @@ static void mi_option_init(mi_option_desc_t* desc) {
545545
desc->init = INITIALIZED;
546546
}
547547
else {
548-
/* _mi_warning_message() will itself call mi_option_get() for some options,
549-
* so to avoid a possible infinite recursion it's important to mark the option as
550-
* "initialized" first */
548+
// set `init` first to avoid recursion through _mi_warning_message on mimalloc_verbose.
551549
desc->init = DEFAULTED;
552-
if (desc->option == mi_option_verbose) {
553-
/* Special case: if the 'mimalloc_verbose' env var has a bogus value we'd never know
554-
* (since the value default to 'off') - so in that one case briefly set the option to 'on' */
550+
if (desc->option == mi_option_verbose && desc->value == 0) {
551+
// if the 'mimalloc_verbose' env var has a bogus value we'd never know
552+
// (since the value defaults to 'off') so in that case briefly enable verbose
555553
desc->value = 1;
556-
}
557-
_mi_warning_message("environment option mimalloc_%s has an invalid value: %s\n", desc->name, buf);
558-
if (desc->option == mi_option_verbose) {
554+
_mi_warning_message("environment option mimalloc_%s has an invalid value: %s\n", desc->name, buf);
559555
desc->value = 0;
560556
}
557+
else {
558+
_mi_warning_message("environment option mimalloc_%s has an invalid value: %s\n", desc->name, buf);
559+
}
561560
}
562561
}
563562
mi_assert_internal(desc->init != UNINIT);

0 commit comments

Comments
 (0)