Add and fix some more warnings

Fixes #216
This commit is contained in:
Wim Taymans 2020-03-17 11:37:56 +01:00
parent 4dcd0dacc9
commit 72d70b0f48
9 changed files with 34 additions and 18 deletions

View file

@ -176,8 +176,8 @@ struct spa_fraction {
#endif
#endif
#define SPA_STRINGIFY_1(x...) #x
#define SPA_STRINGIFY(x...) SPA_STRINGIFY_1(x)
#define SPA_STRINGIFY_1(...) #__VA_ARGS__
#define SPA_STRINGIFY(...) SPA_STRINGIFY_1(__VA_ARGS__)
#define spa_return_if_fail(expr) \
do { \

View file

@ -51,6 +51,9 @@ struct spa_callbacks {
void *data;
};
/** Check if a callback \c has method \m of version \v */
#define SPA_CALLBACK_CHECK(c,m,v) ((c) && ((v) == 0 || (c)->version > (v)-1) && (c)->m)
#define SPA_CALLBACKS_INIT(_funcs,_data) (struct spa_callbacks){ _funcs, _data, }
struct spa_interface {
@ -133,14 +136,14 @@ spa_hook_list_join(struct spa_hook_list *list,
#define spa_callbacks_call(callbacks,type,method,vers,...) \
({ \
const type *_f = (const type *) (callbacks)->funcs; \
if (SPA_LIKELY(_f && _f->version >= (vers) && _f->method)) \
if (SPA_LIKELY(SPA_CALLBACK_CHECK(_f,method,vers))) \
_f->method((callbacks)->data, ## __VA_ARGS__); \
})
#define spa_callbacks_call_res(callbacks,type,res,method,vers,...) \
({ \
const type *_f = (const type *) (callbacks)->funcs; \
if (SPA_LIKELY(_f && _f->version >= (vers) && _f->method)) \
if (SPA_LIKELY(SPA_CALLBACK_CHECK(_f,method,vers))) \
res = _f->method((callbacks)->data, ## __VA_ARGS__); \
res; \
})
@ -171,7 +174,7 @@ spa_hook_list_join(struct spa_hook_list *list,
spa_list_cursor_start(cursor, s, link); \
spa_list_for_each_cursor(ci, cursor, &list->list, link) { \
const type *_f = (const type *)ci->cb.funcs; \
if (SPA_LIKELY(_f && _f->version >= (vers) && _f->method)) { \
if (SPA_LIKELY(SPA_CALLBACK_CHECK(_f,method,vers))) { \
_f->method(ci->cb.data, ## __VA_ARGS__); \
count++; \
if (once) \