mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-03-21 05:34:00 -04:00
tests: Avoid calling function with wrong type
Calling a function with the wrong type is immediate undefined behavior, even if the ABI says it should be harmless. UBSAN picks it up immediately, and any decent control-flow integrity mechanism will as well. Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
This commit is contained in:
parent
4273a5edc8
commit
290c36bc50
3 changed files with 23 additions and 11 deletions
|
|
@ -118,5 +118,17 @@ struct client_info *client_create_with_name(struct display *d,
|
|||
void *data,
|
||||
const char *name);
|
||||
#define client_create(d, c, data) client_create_with_name((d), (c), data, (#c))
|
||||
static inline void noarg_cb(void *data)
|
||||
{
|
||||
void (*cb)(void) = data;
|
||||
cb();
|
||||
}
|
||||
static inline struct client_info *client_create_with_name_noarg(struct display *d,
|
||||
void (*client_main)(void),
|
||||
const char *name)
|
||||
{
|
||||
return client_create_with_name(d, noarg_cb, client_main, name);
|
||||
}
|
||||
|
||||
#define client_create_noarg(d, c) \
|
||||
client_create_with_name((d), (void(*)(void *)) (c), NULL, (#c))
|
||||
client_create_with_name_noarg((d), (c), (#c))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue