glib-aux: mark result of nm_g_slice_free_fcn() as warn_unused_result

It's tempting to mix up

    nm_g_slice_free(arg)

with

    nm_g_slice_free_fcn(arg)

Use __attribute((__warn_unused_result__)) to catch such bugs.
This commit is contained in:
Thomas Haller 2021-06-10 10:24:58 +02:00
parent 5abf61f53a
commit 17be7ea72e
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -1092,8 +1092,14 @@ _nm_g_slice_free_fcn_define(12);
_nm_g_slice_free_fcn_define(16);
_nm_g_slice_free_fcn_define(32);
_nm_warn_unused_result static inline GDestroyNotify
_nm_get_warn_unused_result_gdestroynotify(GDestroyNotify f)
{
return f;
}
#define nm_g_slice_free_fcn1(mem_size) \
({ \
_nm_get_warn_unused_result_gdestroynotify(({ \
void (*_fcn)(gpointer); \
\
/* If mem_size is a compile time constant, the compiler
@ -1132,8 +1138,9 @@ _nm_g_slice_free_fcn_define(32);
_fcn = NULL; \
break; \
} \
\
_fcn; \
})
}))
/**
* nm_g_slice_free_fcn: