glib-aux: use different name for local variables in nm_g_array_index_p() macro

This doesn't use NM_UNIQ_T() to create a truly unique name.

Instead, it avoids "_arr" as local variable name, which other
macros also use. By choosing a different name, we can nest such
macro calls, without getting a "-Wshadow" warning.
This commit is contained in:
Thomas Haller
2022-07-27 18:25:52 +02:00
parent 8153b3ff0c
commit fdebcfa0a0

View File

@@ -2252,16 +2252,16 @@ nm_g_array_unref(GArray *arr)
/* Similar to g_array_index(). The differences are /* Similar to g_array_index(). The differences are
* - this does nm_assert() checks that the arguments are valid. * - this does nm_assert() checks that the arguments are valid.
* - returns a pointer to the element. */ * - returns a pointer to the element. */
#define nm_g_array_index_p(arr, Type, idx) \ #define nm_g_array_index_p(arr, Type, idx) \
({ \ ({ \
GArray *const _arr = (arr); \ GArray *const _arr_55 = (arr); \
const guint _idx = (idx); \ const guint _idx_55 = (idx); \
\ \
nm_assert(_arr); \ nm_assert(_arr_55); \
nm_assert(sizeof(Type) == g_array_get_element_size(_arr)); \ nm_assert(sizeof(Type) == g_array_get_element_size(_arr_55)); \
nm_assert(_idx < _arr->len); \ nm_assert(_idx_55 < _arr_55->len); \
\ \
&g_array_index(_arr, Type, _idx); \ &g_array_index(_arr_55, Type, _idx_55); \
}) })
#define nm_g_array_append_new(arr, Type) \ #define nm_g_array_append_new(arr, Type) \