glib-aux: assert that nm_utils_to_string_buffer_init() does not use the global buffer

For convenience, most to-string methods call nm_utils_to_string_buffer_init().
This allows to omit the string buffer and use a global (thread-local)
buffer.

That "convenience" seems error prone. Start drop it.

Start by adding a g_return_if_reached() assertion to catch the cases
that use it.
This commit is contained in:
Thomas Haller 2022-03-30 10:11:26 +02:00
parent b87afac8e8
commit 27752bfd5b
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -871,6 +871,11 @@ nm_utils_to_string_buffer_init(char **buf, gsize *len)
if (!*buf) {
*buf = _nm_utils_to_string_buffer;
*len = NM_UTILS_TO_STRING_BUFFER_SIZE;
/* We no longer want to support callers to omit the buffer
* and fallback to the global buffer. Callers should be fixed
* to always provide a valid buffer. */
g_return_if_reached();
}
}