Include the unrecognized malloc conf option in the error message.

Previously the option causing trouble will not be printed, unless the option
key:value pair format is found.
This commit is contained in:
Qi Wang 2023-08-01 14:28:24 -07:00 committed by Qi Wang
parent 62648c88e5
commit 6816b23862

View File

@ -865,6 +865,14 @@ malloc_conf_multi_sizes_next(const char **slab_size_segment_cur,
return false;
}
static void
malloc_conf_format_error(const char *msg, const char *begin, const char *end) {
size_t len = end - begin + 1;
len = len > BUFERROR_BUF ? BUFERROR_BUF : len;
malloc_printf("<jemalloc>: %s -- %.*s\n", msg, (int)len, begin);
}
static bool
malloc_conf_next(char const **opts_p, char const **k_p, size_t *klen_p,
char const **v_p, size_t *vlen_p) {
@ -898,13 +906,15 @@ malloc_conf_next(char const **opts_p, char const **k_p, size_t *klen_p,
break;
case '\0':
if (opts != *opts_p) {
malloc_write("<jemalloc>: Conf string ends "
"with key\n");
malloc_conf_format_error(
"Conf string ends with key",
*opts_p, opts - 1);
had_conf_error = true;
}
return true;
default:
malloc_write("<jemalloc>: Malformed conf string\n");
malloc_conf_format_error(
"Malformed conf string", *opts_p, opts);
had_conf_error = true;
return true;
}
@ -922,8 +932,9 @@ malloc_conf_next(char const **opts_p, char const **k_p, size_t *klen_p,
* comma if one exists.
*/
if (*opts == '\0') {
malloc_write("<jemalloc>: Conf string ends "
"with comma\n");
malloc_conf_format_error(
"Conf string ends with comma",
*opts_p, opts - 1);
had_conf_error = true;
}
*vlen_p = (uintptr_t)opts - 1 - (uintptr_t)*v_p;