mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 07:30:10 +01:00
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:
parent
5abf61f53a
commit
17be7ea72e
1 changed files with 9 additions and 2 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue