Fix some badly-behaved macros

Some macros evaluated their arguments more than once when it was not
needed, or were missing parentheses.
This commit is contained in:
Demi Marie Obenour 2022-09-01 17:02:44 -04:00
parent bb4f274ae0
commit 671a7102ff
46 changed files with 162 additions and 156 deletions

View file

@ -66,7 +66,7 @@ struct spa_meta {
#define spa_meta_first(m) ((m)->data)
#define spa_meta_end(m) SPA_PTROFF((m)->data,(m)->size,void)
#define spa_meta_check(p,m) (SPA_PTROFF(p,sizeof(*p),void) <= spa_meta_end(m))
#define spa_meta_check(p,m) (SPA_PTROFF(p,sizeof(*(p)),void) <= spa_meta_end(m))
/**
* Describes essential buffer header metadata such as flags and
@ -92,11 +92,14 @@ struct spa_meta_region {
struct spa_region region;
};
#define spa_meta_region_is_valid(m) ((m)->region.size.width != 0 && (m)->region.size.height != 0)
static inline bool spa_meta_region_is_valid(const struct spa_meta_region *m) {
return m->region.size.width != 0 && m->region.size.height != 0;
}
#define spa_meta_region_is_valid spa_meta_region_is_valid
/** iterate all the items in a metadata */
#define spa_meta_for_each(pos,meta) \
for (pos = (__typeof(pos))spa_meta_first(meta); \
for ((pos) = (__typeof(pos))spa_meta_first(meta); \
spa_meta_check(pos, meta); \
(pos)++)

View file

@ -36,10 +36,10 @@ extern "C" {
*/
#ifndef spa_debug
#define spa_debug(fmt,...) ({ printf(fmt"\n", ## __VA_ARGS__); })
#define spa_debug(fmt,...) ({ printf((fmt"\n"), ## __VA_ARGS__); })
#endif
#ifndef spa_debugn
#define spa_debugn(fmt,...) ({ printf(fmt, ## __VA_ARGS__); })
#define spa_debugn(fmt,...) ({ printf((fmt), ## __VA_ARGS__); })
#endif
/**

View file

@ -121,12 +121,12 @@ struct spa_graph_node {
int __res = 0; \
spa_callbacks_call_res(&(n)->callbacks, \
struct spa_graph_node_callbacks, __res, \
method, version, ##__VA_ARGS__); \
method, (version), ##__VA_ARGS__); \
__res; \
})
#define spa_graph_node_process(n) spa_graph_node_call(n, process, 0, n)
#define spa_graph_node_reuse_buffer(n,p,i) spa_graph_node_call(n, reuse_buffer, 0, n, p, i)
#define spa_graph_node_process(n) spa_graph_node_call((n), process, 0, (n))
#define spa_graph_node_reuse_buffer(n,p,i) spa_graph_node_call((n), reuse_buffer, 0, (n), (p), (i))
struct spa_graph_port {
struct spa_list link; /**< link in node port list */

View file

@ -80,10 +80,10 @@ struct spa_audio_aec_methods {
#define spa_audio_aec_method(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
struct spa_audio_aec *_o = o; \
struct spa_audio_aec *_o = (o); \
spa_interface_call_res(&_o->iface, \
struct spa_audio_aec_methods, _res, \
method, version, ##__VA_ARGS__); \
method, (version), ##__VA_ARGS__); \
_res; \
})

View file

@ -71,7 +71,7 @@ struct spa_device_info {
uint32_t n_params; /**< number of elements in params */
};
#define SPA_DEVICE_INFO_INIT() (struct spa_device_info){ SPA_VERSION_DEVICE_INFO, }
#define SPA_DEVICE_INFO_INIT() ((struct spa_device_info){ SPA_VERSION_DEVICE_INFO, })
/**
* Information about a device object
@ -92,7 +92,7 @@ struct spa_device_object_info {
const struct spa_dict *props; /**< extra object properties */
};
#define SPA_DEVICE_OBJECT_INFO_INIT() (struct spa_device_object_info){ SPA_VERSION_DEVICE_OBJECT_INFO, }
#define SPA_DEVICE_OBJECT_INFO_INIT() ((struct spa_device_object_info){ SPA_VERSION_DEVICE_OBJECT_INFO, })
/** the result of spa_device_enum_params() */
#define SPA_RESULT_TYPE_DEVICE_PARAMS 1
@ -243,10 +243,10 @@ struct spa_device_methods {
#define spa_device_method(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
struct spa_device *_o = o; \
struct spa_device *_o = (o); \
spa_interface_call_res(&_o->iface, \
struct spa_device_methods, _res, \
method, version, ##__VA_ARGS__); \
method, (version), ##__VA_ARGS__); \
_res; \
})

View file

@ -100,7 +100,7 @@ struct spa_io_buffers {
uint32_t buffer_id; /**< a buffer id */
};
#define SPA_IO_BUFFERS_INIT (struct spa_io_buffers) { SPA_STATUS_OK, SPA_ID_INVALID, }
#define SPA_IO_BUFFERS_INIT ((struct spa_io_buffers) { SPA_STATUS_OK, SPA_ID_INVALID, })
/**
* IO area to exchange a memory region
@ -110,7 +110,7 @@ struct spa_io_memory {
uint32_t size; /**< the size of \a data */
void *data; /**< a memory pointer */
};
#define SPA_IO_MEMORY_INIT (struct spa_io_memory) { SPA_STATUS_OK, 0, NULL, }
#define SPA_IO_MEMORY_INIT ((struct spa_io_memory) { SPA_STATUS_OK, 0, NULL, })
/** A range, suitable for input ports that can suggest a range to output ports */
struct spa_io_range {

View file

@ -85,7 +85,7 @@ struct spa_node_info {
uint32_t n_params; /**< number of items in \a params */
};
#define SPA_NODE_INFO_INIT() (struct spa_node_info) { 0, }
#define SPA_NODE_INFO_INIT() ((struct spa_node_info) { 0, })
/**
* Port information structure
@ -124,7 +124,7 @@ struct spa_port_info {
uint32_t n_params; /**< number of items in \a params */
};
#define SPA_PORT_INFO_INIT() (struct spa_port_info) { 0, }
#define SPA_PORT_INFO_INIT() ((struct spa_port_info) { 0, })
#define SPA_RESULT_TYPE_NODE_ERROR 1
#define SPA_RESULT_TYPE_NODE_PARAMS 2

View file

@ -68,7 +68,7 @@ struct spa_audio_info_dsd {
uint32_t position[SPA_AUDIO_MAX_CHANNELS]; /*< channel position from enum spa_audio_channel */
};
#define SPA_AUDIO_INFO_DSD_INIT(...) (struct spa_audio_info_dsd) { __VA_ARGS__ }
#define SPA_AUDIO_INFO_DSD_INIT(...) ((struct spa_audio_info_dsd) { __VA_ARGS__ })
/**
* \}

View file

@ -56,7 +56,7 @@ struct spa_audio_info_iec958 {
uint32_t rate; /*< sample rate */
};
#define SPA_AUDIO_INFO_IEC958_INIT(...) (struct spa_audio_info_iec958) { __VA_ARGS__ }
#define SPA_AUDIO_INFO_IEC958_INIT(...) ((struct spa_audio_info_iec958) { __VA_ARGS__ })
/**
* \}

View file

@ -294,7 +294,7 @@ struct spa_audio_info_raw {
uint32_t position[SPA_AUDIO_MAX_CHANNELS]; /*< channel position from enum spa_audio_channel */
};
#define SPA_AUDIO_INFO_RAW_INIT(...) (struct spa_audio_info_raw) { __VA_ARGS__ }
#define SPA_AUDIO_INFO_RAW_INIT(...) ((struct spa_audio_info_raw) { __VA_ARGS__ })
#define SPA_KEY_AUDIO_FORMAT "audio.format" /**< an audio format as string,
* Ex. "S16LE" */
@ -311,7 +311,7 @@ struct spa_audio_info_dsp {
enum spa_audio_format format; /*< format, one of the DSP formats in enum spa_audio_format_dsp */
};
#define SPA_AUDIO_INFO_DSP_INIT(...) (struct spa_audio_info_dsp) { __VA_ARGS__ }
#define SPA_AUDIO_INFO_DSP_INIT(...) ((struct spa_audio_info_dsp) { __VA_ARGS__ })
/**
* \}

View file

@ -50,7 +50,7 @@ struct spa_latency_info {
uint64_t max_ns;
};
#define SPA_LATENCY_INFO(dir,...) (struct spa_latency_info) { .direction = (dir), ## __VA_ARGS__ }
#define SPA_LATENCY_INFO(dir,...) ((struct spa_latency_info) { .direction = (dir), ## __VA_ARGS__ })
static inline int
spa_latency_info_compare(const struct spa_latency_info *a, struct spa_latency_info *b)
@ -146,7 +146,7 @@ struct spa_process_latency_info {
uint64_t ns;
};
#define SPA_PROCESS_LATENCY_INFO_INIT(...) (struct spa_process_latency_info) { __VA_ARGS__ }
#define SPA_PROCESS_LATENCY_INFO_INIT(...) ((struct spa_process_latency_info) { __VA_ARGS__ })
static inline int
spa_process_latency_parse(const struct spa_pod *latency, struct spa_process_latency_info *info)

View file

@ -75,7 +75,7 @@ struct spa_param_info {
uint32_t padding[5];
};
#define SPA_PARAM_INFO(id,flags) (struct spa_param_info){ (id), (flags) }
#define SPA_PARAM_INFO(id,flags) ((struct spa_param_info){ (id), (flags) })
/** properties for SPA_TYPE_OBJECT_ParamBuffers */
enum spa_param_buffers {

View file

@ -206,14 +206,14 @@ struct spa_video_info_raw {
enum spa_video_color_primaries color_primaries; /**< color primaries. used to convert between R'G'B' and CIE XYZ */
};
#define SPA_VIDEO_INFO_RAW_INIT(...) (struct spa_video_info_raw) { __VA_ARGS__ }
#define SPA_VIDEO_INFO_RAW_INIT(...) ((struct spa_video_info_raw) { __VA_ARGS__ })
struct spa_video_info_dsp {
enum spa_video_format format;
int64_t modifier;
};
#define SPA_VIDEO_INFO_DSP_INIT(...) (struct spa_video_info_dsp) { __VA_ARGS__ }
#define SPA_VIDEO_INFO_DSP_INIT(...) ((struct spa_video_info_dsp) { __VA_ARGS__ })
/**
* \}

View file

@ -69,7 +69,7 @@ struct spa_pod_builder {
struct spa_callbacks callbacks;
};
#define SPA_POD_BUILDER_INIT(buffer,size) (struct spa_pod_builder){ buffer, size, 0, {}, {} }
#define SPA_POD_BUILDER_INIT(buffer,size) ((struct spa_pod_builder){ (buffer), (size), 0, {}, {} })
static inline void
spa_pod_builder_get_state(struct spa_pod_builder *builder, struct spa_pod_builder_state *state)
@ -214,7 +214,7 @@ spa_pod_builder_primitive(struct spa_pod_builder *builder, const struct spa_pod
return res;
}
#define SPA_POD_INIT(size,type) (struct spa_pod) { size, type }
#define SPA_POD_INIT(size,type) ((struct spa_pod) { (size), (type) })
#define SPA_POD_INIT_None() SPA_POD_INIT(0, SPA_TYPE_None)
@ -231,7 +231,7 @@ static inline int spa_pod_builder_child(struct spa_pod_builder *builder, uint32_
return spa_pod_builder_raw(builder, &p, sizeof(p));
}
#define SPA_POD_INIT_Bool(val) (struct spa_pod_bool){ { sizeof(uint32_t), SPA_TYPE_Bool }, val ? 1 : 0, 0 }
#define SPA_POD_INIT_Bool(val) ((struct spa_pod_bool){ { sizeof(uint32_t), SPA_TYPE_Bool }, (val) ? 1 : 0, 0 })
static inline int spa_pod_builder_bool(struct spa_pod_builder *builder, bool val)
{
@ -239,7 +239,7 @@ static inline int spa_pod_builder_bool(struct spa_pod_builder *builder, bool val
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_INIT_Id(val) (struct spa_pod_id){ { sizeof(uint32_t), SPA_TYPE_Id }, (uint32_t)val, 0 }
#define SPA_POD_INIT_Id(val) ((struct spa_pod_id){ { sizeof(uint32_t), SPA_TYPE_Id }, (val), 0 })
static inline int spa_pod_builder_id(struct spa_pod_builder *builder, uint32_t val)
{
@ -247,7 +247,7 @@ static inline int spa_pod_builder_id(struct spa_pod_builder *builder, uint32_t v
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_INIT_Int(val) (struct spa_pod_int){ { sizeof(int32_t), SPA_TYPE_Int }, (int32_t)val, 0 }
#define SPA_POD_INIT_Int(val) ((struct spa_pod_int){ { sizeof(int32_t), SPA_TYPE_Int }, (val), 0 })
static inline int spa_pod_builder_int(struct spa_pod_builder *builder, int32_t val)
{
@ -255,7 +255,7 @@ static inline int spa_pod_builder_int(struct spa_pod_builder *builder, int32_t v
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_INIT_Long(val) (struct spa_pod_long){ { sizeof(int64_t), SPA_TYPE_Long }, (int64_t)val }
#define SPA_POD_INIT_Long(val) ((struct spa_pod_long){ { sizeof(int64_t), SPA_TYPE_Long }, (val) })
static inline int spa_pod_builder_long(struct spa_pod_builder *builder, int64_t val)
{
@ -263,7 +263,7 @@ static inline int spa_pod_builder_long(struct spa_pod_builder *builder, int64_t
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_INIT_Float(val) (struct spa_pod_float){ { sizeof(float), SPA_TYPE_Float }, val, 0 }
#define SPA_POD_INIT_Float(val) ((struct spa_pod_float){ { sizeof(float), SPA_TYPE_Float }, (val), 0 })
static inline int spa_pod_builder_float(struct spa_pod_builder *builder, float val)
{
@ -271,7 +271,7 @@ static inline int spa_pod_builder_float(struct spa_pod_builder *builder, float v
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_INIT_Double(val) (struct spa_pod_double){ { sizeof(double), SPA_TYPE_Double }, val }
#define SPA_POD_INIT_Double(val) ((struct spa_pod_double){ { sizeof(double), SPA_TYPE_Double }, (val) })
static inline int spa_pod_builder_double(struct spa_pod_builder *builder, double val)
{
@ -279,7 +279,7 @@ static inline int spa_pod_builder_double(struct spa_pod_builder *builder, double
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_INIT_String(len) (struct spa_pod_string){ { len, SPA_TYPE_String } }
#define SPA_POD_INIT_String(len) ((struct spa_pod_string){ { (len), SPA_TYPE_String } })
static inline int
spa_pod_builder_write_string(struct spa_pod_builder *builder, const char *str, uint32_t len)
@ -309,7 +309,7 @@ static inline int spa_pod_builder_string(struct spa_pod_builder *builder, const
return spa_pod_builder_string_len(builder, str ? str : "", len);
}
#define SPA_POD_INIT_Bytes(len) (struct spa_pod_bytes){ { len, SPA_TYPE_Bytes } }
#define SPA_POD_INIT_Bytes(len) ((struct spa_pod_bytes){ { (len), SPA_TYPE_Bytes } })
static inline int
spa_pod_builder_bytes(struct spa_pod_builder *builder, const void *bytes, uint32_t len)
@ -329,7 +329,7 @@ spa_pod_builder_reserve_bytes(struct spa_pod_builder *builder, uint32_t len)
return SPA_POD_BODY(spa_pod_builder_deref(builder, offset));
}
#define SPA_POD_INIT_Pointer(type,value) (struct spa_pod_pointer){ { sizeof(struct spa_pod_pointer_body), SPA_TYPE_Pointer }, { type, 0, value } }
#define SPA_POD_INIT_Pointer(type,value) ((struct spa_pod_pointer){ { sizeof(struct spa_pod_pointer_body), SPA_TYPE_Pointer }, { (type), 0, (value) } })
static inline int
spa_pod_builder_pointer(struct spa_pod_builder *builder, uint32_t type, const void *val)
@ -338,7 +338,7 @@ spa_pod_builder_pointer(struct spa_pod_builder *builder, uint32_t type, const vo
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_INIT_Fd(fd) (struct spa_pod_fd){ { sizeof(int64_t), SPA_TYPE_Fd }, fd }
#define SPA_POD_INIT_Fd(fd) ((struct spa_pod_fd){ { sizeof(int64_t), SPA_TYPE_Fd }, (fd) })
static inline int spa_pod_builder_fd(struct spa_pod_builder *builder, int64_t fd)
{
@ -346,7 +346,7 @@ static inline int spa_pod_builder_fd(struct spa_pod_builder *builder, int64_t fd
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_INIT_Rectangle(val) (struct spa_pod_rectangle){ { sizeof(struct spa_rectangle), SPA_TYPE_Rectangle }, val }
#define SPA_POD_INIT_Rectangle(val) ((struct spa_pod_rectangle){ { sizeof(struct spa_rectangle), SPA_TYPE_Rectangle }, (val) })
static inline int
spa_pod_builder_rectangle(struct spa_pod_builder *builder, uint32_t width, uint32_t height)
@ -355,7 +355,7 @@ spa_pod_builder_rectangle(struct spa_pod_builder *builder, uint32_t width, uint3
return spa_pod_builder_primitive(builder, &p.pod);
}
#define SPA_POD_INIT_Fraction(val) (struct spa_pod_fraction){ { sizeof(struct spa_fraction), SPA_TYPE_Fraction }, val }
#define SPA_POD_INIT_Fraction(val) ((struct spa_pod_fraction){ { sizeof(struct spa_fraction), SPA_TYPE_Fraction }, (val) })
static inline int
spa_pod_builder_fraction(struct spa_pod_builder *builder, uint32_t num, uint32_t denom)
@ -391,12 +391,12 @@ spa_pod_builder_array(struct spa_pod_builder *builder,
}
#define SPA_POD_INIT_CHOICE_BODY(type, flags, child_size, child_type) \
(struct spa_pod_choice_body) { type, flags, { child_size, child_type }}
((struct spa_pod_choice_body) { (type), (flags), { (child_size), (child_type) }})
#define SPA_POD_INIT_Choice(type, ctype, child_type, n_vals, ...) \
(struct { struct spa_pod_choice choice; ctype vals[n_vals];}) \
{ { { n_vals * sizeof(ctype) + sizeof(struct spa_pod_choice_body), SPA_TYPE_Choice }, \
{ type, 0, { sizeof(ctype), child_type } } }, { __VA_ARGS__ } }
((struct { struct spa_pod_choice choice; ctype vals[(n_vals)];}) \
{ { { (n_vals) * sizeof(ctype) + sizeof(struct spa_pod_choice_body), SPA_TYPE_Choice }, \
{ (type), 0, { sizeof(ctype), (child_type) } } }, { __VA_ARGS__ } })
static inline int
spa_pod_builder_push_choice(struct spa_pod_builder *builder, struct spa_pod_frame *frame,
@ -411,7 +411,7 @@ spa_pod_builder_push_choice(struct spa_pod_builder *builder, struct spa_pod_fram
return res;
}
#define SPA_POD_INIT_Struct(size) (struct spa_pod_struct){ { size, SPA_TYPE_Struct } }
#define SPA_POD_INIT_Struct(size) ((struct spa_pod_struct){ { (size), SPA_TYPE_Struct } })
static inline int
spa_pod_builder_push_struct(struct spa_pod_builder *builder, struct spa_pod_frame *frame)
@ -423,7 +423,7 @@ spa_pod_builder_push_struct(struct spa_pod_builder *builder, struct spa_pod_fram
return res;
}
#define SPA_POD_INIT_Object(size,type,id,...) (struct spa_pod_object){ { size, SPA_TYPE_Object }, { type, id }, ##__VA_ARGS__ }
#define SPA_POD_INIT_Object(size,type,id,...) ((struct spa_pod_object){ { (size), SPA_TYPE_Object }, { (type), (id) }, ##__VA_ARGS__ })
static inline int
spa_pod_builder_push_object(struct spa_pod_builder *builder, struct spa_pod_frame *frame,
@ -438,7 +438,7 @@ spa_pod_builder_push_object(struct spa_pod_builder *builder, struct spa_pod_fram
}
#define SPA_POD_INIT_Prop(key,flags,size,type) \
(struct spa_pod_prop){ key, flags, { size, type } }
((struct spa_pod_prop){ (key), (flags), { (size), (type) } })
static inline int
spa_pod_builder_prop(struct spa_pod_builder *builder, uint32_t key, uint32_t flags)
@ -448,7 +448,7 @@ spa_pod_builder_prop(struct spa_pod_builder *builder, uint32_t key, uint32_t fla
}
#define SPA_POD_INIT_Sequence(size,unit) \
(struct spa_pod_sequence){ { size, SPA_TYPE_Sequence}, {unit, 0 } }
((struct spa_pod_sequence){ { (size), SPA_TYPE_Sequence}, {(unit), 0 } })
static inline int
spa_pod_builder_push_sequence(struct spa_pod_builder *builder, struct spa_pod_frame *frame, uint32_t unit)
@ -652,26 +652,29 @@ static inline int spa_pod_builder_add(struct spa_pod_builder *builder, ...)
#define spa_pod_builder_add_object(b,type,id,...) \
({ \
struct spa_pod_builder *_b = (b); \
struct spa_pod_frame _f; \
spa_pod_builder_push_object(b, &_f, type, id); \
spa_pod_builder_add(b, ##__VA_ARGS__, 0); \
spa_pod_builder_pop(b, &_f); \
spa_pod_builder_push_object(_b, &_f, type, id); \
spa_pod_builder_add(_b, ##__VA_ARGS__, 0); \
spa_pod_builder_pop(_b, &_f); \
})
#define spa_pod_builder_add_struct(b,...) \
({ \
struct spa_pod_builder *_b = (b); \
struct spa_pod_frame _f; \
spa_pod_builder_push_struct(b, &_f); \
spa_pod_builder_add(b, ##__VA_ARGS__, NULL); \
spa_pod_builder_pop(b, &_f); \
spa_pod_builder_push_struct(_b, &_f); \
spa_pod_builder_add(_b, ##__VA_ARGS__, NULL); \
spa_pod_builder_pop(_b, &_f); \
})
#define spa_pod_builder_add_sequence(b,unit,...) \
({ \
struct spa_pod_builder *_b = (b); \
struct spa_pod_frame _f; \
spa_pod_builder_push_sequence(b, &_f, unit); \
spa_pod_builder_add(b, ##__VA_ARGS__, 0, 0); \
spa_pod_builder_pop(b, &_f); \
spa_pod_builder_push_sequence(_b, &_f, unit); \
spa_pod_builder_add(_b, ##__VA_ARGS__, 0, 0); \
spa_pod_builder_pop(_b, &_f); \
})
/** Copy a pod structure */

View file

@ -47,12 +47,12 @@ struct spa_command {
};
#define SPA_COMMAND_TYPE(cmd) ((cmd)->body.body.type)
#define SPA_COMMAND_ID(cmd,type) (SPA_COMMAND_TYPE(cmd) == type ? \
#define SPA_COMMAND_ID(cmd,type) (SPA_COMMAND_TYPE(cmd) == (type) ? \
(cmd)->body.body.id : SPA_ID_INVALID)
#define SPA_COMMAND_INIT_FULL(t,size,type,id,...) (t) \
{ { size, SPA_TYPE_Object }, \
{ { type, id }, ##__VA_ARGS__ } } \
#define SPA_COMMAND_INIT_FULL(t,size,type,id,...) ((t) \
{ { (size), SPA_TYPE_Object }, \
{ { (type), (id) }, ##__VA_ARGS__ } })
#define SPA_COMMAND_INIT(type,id) \
SPA_COMMAND_INIT_FULL(struct spa_command, \

View file

@ -46,7 +46,7 @@ struct spa_event {
};
#define SPA_EVENT_TYPE(ev) ((ev)->body.body.type)
#define SPA_EVENT_ID(ev,type) (SPA_EVENT_TYPE(ev) == type ? \
#define SPA_EVENT_ID(ev,type) (SPA_EVENT_TYPE(ev) == (type) ? \
(ev)->body.body.id : SPA_ID_INVALID)
#define SPA_EVENT_INIT_FULL(t,size,type,id,...) (t) \

View file

@ -53,7 +53,7 @@ struct spa_pod_parser {
struct spa_pod_parser_state state;
};
#define SPA_POD_PARSER_INIT(buffer,size) (struct spa_pod_parser){ buffer, size, 0, {} }
#define SPA_POD_PARSER_INIT(buffer,size) ((struct spa_pod_parser){ (buffer), (size), 0, {} })
static inline void spa_pod_parser_init(struct spa_pod_parser *parser,
const void *data, uint32_t size)
@ -355,7 +355,7 @@ do { \
break; \
case 's': \
*va_arg(args, char**) = \
(pod == NULL || (SPA_POD_TYPE(pod) == SPA_TYPE_None) \
((pod) == NULL || (SPA_POD_TYPE(pod) == SPA_TYPE_None) \
? NULL \
: (char *)SPA_POD_CONTENTS(struct spa_pod_string, pod)); \
break; \
@ -407,8 +407,8 @@ do { \
{ \
const struct spa_pod **d = va_arg(args, const struct spa_pod**); \
if (d) \
*d = (pod == NULL || (SPA_POD_TYPE(pod) == SPA_TYPE_None) \
? NULL : pod); \
*d = ((pod) == NULL || (SPA_POD_TYPE(pod) == SPA_TYPE_None) \
? NULL : (pod)); \
break; \
} \
default: \

View file

@ -52,7 +52,7 @@ struct spa_pod {
uint32_t type; /* a basic id of enum spa_type */
};
#define SPA_POD_VALUE(type,pod) (((type*)pod)->value)
#define SPA_POD_VALUE(type,pod) (((type*)(pod))->value)
struct spa_pod_bool {
struct spa_pod pod;

View file

@ -121,7 +121,7 @@ struct { \
#define SPA_LOG_IMPL_INIT(name) \
{ { { SPA_TYPE_INTERFACE_Log, SPA_VERSION_LOG, \
SPA_CALLBACKS_INIT(&name.methods, &name) }, \
SPA_CALLBACKS_INIT(&(name).methods, &(name)) }, \
SPA_LOG_LEVEL_INFO, }, \
{ SPA_VERSION_LOG_METHODS, \
spa_log_impl_log, \

View file

@ -212,7 +212,7 @@ struct spa_log_methods {
#define SPA_LOG_TOPIC(v, t) \
(struct spa_log_topic){ .version = v, .topic = (t)}
(struct spa_log_topic){ .version = (v), .topic = (t)}
#define spa_log_topic_init(l, topic) \
do { \
@ -231,10 +231,10 @@ do { \
({ \
struct spa_log *_log = l; \
enum spa_log_level _lev = _log ? _log->level : SPA_LOG_LEVEL_NONE; \
struct spa_log_topic *_t = (struct spa_log_topic *)topic; \
struct spa_log_topic *_t = (struct spa_log_topic *)(topic); \
if (_t && _t->has_custom_level) \
_lev = _t->level; \
_lev >= lev; \
_lev >= (lev); \
})
/* Transparently calls to version 0 log if v1 is not supported */
@ -302,15 +302,15 @@ do { \
#define spa_log_hexdump(l,lev,indent,data,len) \
({ \
char str[512]; \
uint8_t *buf = (uint8_t *)data; \
size_t i; \
uint8_t *buf = (uint8_t *)(data); \
size_t i, j = (len); \
int pos = 0; \
\
for (i = 0; i < len; i++) { \
for (i = 0; i < j; i++) { \
if (i % 16 == 0) \
pos = 0; \
pos += sprintf(str + pos, "%02x ", buf[i]); \
if (i % 16 == 15 || i == len - 1) \
if (i % 16 == 15 || i == j - 1) \
spa_log_lev(l,lev, "%*s" "%s",indent,"", str); \
} \
})

View file

@ -105,7 +105,7 @@ static inline void *spa_support_find(const struct spa_support *support,
return NULL;
}
#define SPA_SUPPORT_INIT(type,data) (struct spa_support) { (type), (data) }
#define SPA_SUPPORT_INIT(type,data) ((struct spa_support) { (type), (data) })
struct spa_handle_factory {
/** The version of this structure */

View file

@ -84,25 +84,25 @@ enum spa_direction {
#define SPA_DIRECTION_REVERSE(d) ((d) ^ 1)
#define SPA_RECTANGLE(width,height) (struct spa_rectangle){ width, height }
#define SPA_RECTANGLE(width,height) ((struct spa_rectangle){ (width), (height) })
struct spa_rectangle {
uint32_t width;
uint32_t height;
};
#define SPA_POINT(x,y) (struct spa_point){ x, y }
#define SPA_POINT(x,y) ((struct spa_point){ (x), (y) })
struct spa_point {
int32_t x;
int32_t y;
};
#define SPA_REGION(x,y,width,height) (struct spa_region){ SPA_POINT(x,y), SPA_RECTANGLE(width,height) }
#define SPA_REGION(x,y,width,height) ((struct spa_region){ SPA_POINT(x,y), SPA_RECTANGLE(width,height) })
struct spa_region {
struct spa_point position;
struct spa_rectangle size;
};
#define SPA_FRACTION(num,denom) (struct spa_fraction){ num, denom }
#define SPA_FRACTION(num,denom) ((struct spa_fraction){ (num), (denom) })
struct spa_fraction {
uint32_t num;
uint32_t denom;
@ -120,7 +120,7 @@ struct spa_fraction {
* ```
*/
#define SPA_FOR_EACH_ELEMENT(arr, ptr) \
for (ptr = arr; (void*)ptr < SPA_PTROFF(arr, sizeof(arr), void); ptr++)
for ((ptr) = arr; (void*)(ptr) < SPA_PTROFF(arr, sizeof(arr), void); (ptr)++)
#define SPA_ABS(a) \
({ \
@ -156,7 +156,7 @@ struct spa_fraction {
#define SPA_SWAP(a,b) \
({ \
__typeof__(a) _t = (a); \
a = b; b = _t; \
(a) = b; (b) = _t; \
})
#define SPA_TYPECHECK(type,x) \
@ -180,7 +180,7 @@ struct spa_fraction {
#define SPA_MEMBER(b,o,t) SPA_PTROFF(b,o,t)
#define SPA_MEMBER_ALIGN(b,o,a,t) SPA_PTROFF_ALIGN(b,o,a,t)
#define SPA_CONTAINER_OF(p,t,m) ((t*)((uintptr_t)p - offsetof(t,m)))
#define SPA_CONTAINER_OF(p,t,m) ((t*)((uintptr_t)(p) - offsetof(t,m)))
#define SPA_PTRDIFF(p1,p2) ((intptr_t)(p1) - (intptr_t)(p2))
@ -194,7 +194,7 @@ struct spa_fraction {
#define SPA_IDX_INVALID ((unsigned int)-1)
#define SPA_ID_INVALID ((uint32_t)0xffffffff)
#define SPA_NSEC_PER_SEC (1000000000ll)
#define SPA_NSEC_PER_SEC (1000000000LL)
#define SPA_NSEC_PER_MSEC (1000000ll)
#define SPA_NSEC_PER_USEC (1000ll)
#define SPA_USEC_PER_SEC (1000000ll)

View file

@ -48,7 +48,7 @@ struct spa_dict_item {
const char *value;
};
#define SPA_DICT_ITEM_INIT(key,value) (struct spa_dict_item) { key, value }
#define SPA_DICT_ITEM_INIT(key,value) ((struct spa_dict_item) { (key), (value) })
struct spa_dict {
#define SPA_DICT_FLAG_SORTED (1<<0) /**< items are sorted */
@ -57,8 +57,8 @@ struct spa_dict {
const struct spa_dict_item *items;
};
#define SPA_DICT_INIT(items,n_items) (struct spa_dict) { 0, n_items, items }
#define SPA_DICT_INIT_ARRAY(items) (struct spa_dict) { 0, SPA_N_ELEMENTS(items), items }
#define SPA_DICT_INIT(items,n_items) ((struct spa_dict) { 0, (n_items), (items) })
#define SPA_DICT_INIT_ARRAY(items) ((struct spa_dict) { 0, SPA_N_ELEMENTS(items), (items) })
#define spa_dict_for_each(item, dict) \
for ((item) = (dict)->items; \

View file

@ -142,7 +142,7 @@ struct spa_callbacks {
* Initialize the set of functions \a funcs as a \ref spa_callbacks, together
* with \a _data.
*/
#define SPA_CALLBACKS_INIT(_funcs,_data) (struct spa_callbacks){ _funcs, _data, }
#define SPA_CALLBACKS_INIT(_funcs,_data) ((struct spa_callbacks){ (_funcs), (_data), })
/** \struct spa_interface
*/

View file

@ -58,20 +58,20 @@ struct spa_json {
uint32_t depth;
};
#define SPA_JSON_INIT(data,size) (struct spa_json) { (data), (data)+(size), }
#define SPA_JSON_INIT(data,size) ((struct spa_json) { (data), (data)+(size), })
static inline void spa_json_init(struct spa_json * iter, const char *data, size_t size)
{
*iter = SPA_JSON_INIT(data, size);
}
#define SPA_JSON_ENTER(iter) (struct spa_json) { (iter)->cur, (iter)->end, (iter), }
#define SPA_JSON_ENTER(iter) ((struct spa_json) { (iter)->cur, (iter)->end, (iter), })
static inline void spa_json_enter(struct spa_json * iter, struct spa_json * sub)
{
*sub = SPA_JSON_ENTER(iter);
}
#define SPA_JSON_SAVE(iter) (struct spa_json) { (iter)->cur, (iter)->end, }
#define SPA_JSON_SAVE(iter) ((struct spa_json) { (iter)->cur, (iter)->end, })
/** Get the next token. \a value points to the token and the return value
* is the length. */

View file

@ -44,7 +44,7 @@ struct spa_list {
struct spa_list *prev;
};
#define SPA_LIST_INIT(list) (struct spa_list){ list, list }
#define SPA_LIST_INIT(list) ((struct spa_list){ (list), (list) })
static inline void spa_list_init(struct spa_list *list)
{
@ -98,25 +98,25 @@ static inline void spa_list_remove(struct spa_list *elem)
(&(pos)->member == (head))
#define spa_list_next(pos, member) \
SPA_CONTAINER_OF((pos)->member.next, __typeof__(*pos), member)
SPA_CONTAINER_OF((pos)->member.next, __typeof__(*(pos)), member)
#define spa_list_prev(pos, member) \
SPA_CONTAINER_OF((pos)->member.prev, __typeof__(*pos), member)
SPA_CONTAINER_OF((pos)->member.prev, __typeof__(*(pos)), member)
#define spa_list_consume(pos, head, member) \
for (pos = spa_list_first(head, __typeof__(*pos), member); \
for ((pos) = spa_list_first(head, __typeof__(*(pos)), member); \
!spa_list_is_empty(head); \
pos = spa_list_first(head, __typeof__(*pos), member))
(pos) = spa_list_first(head, __typeof__(*(pos)), member))
#define spa_list_for_each_next(pos, head, curr, member) \
for (pos = spa_list_first(curr, __typeof__(*pos), member); \
for ((pos) = spa_list_first(curr, __typeof__(*(pos)), member); \
!spa_list_is_end(pos, head, member); \
pos = spa_list_next(pos, member))
(pos) = spa_list_next(pos, member))
#define spa_list_for_each_prev(pos, head, curr, member) \
for (pos = spa_list_last(curr, __typeof__(*pos), member); \
for ((pos) = spa_list_last(curr, __typeof__(*(pos)), member); \
!spa_list_is_end(pos, head, member); \
pos = spa_list_prev(pos, member))
(pos) = spa_list_prev(pos, member))
#define spa_list_for_each(pos, head, member) \
spa_list_for_each_next(pos, head, head, member)
@ -125,16 +125,16 @@ static inline void spa_list_remove(struct spa_list *elem)
spa_list_for_each_prev(pos, head, head, member)
#define spa_list_for_each_safe_next(pos, tmp, head, curr, member) \
for (pos = spa_list_first(curr, __typeof__(*pos), member); \
tmp = spa_list_next(pos, member), \
for ((pos) = spa_list_first(curr, __typeof__(*(pos)), member); \
(tmp) = spa_list_next(pos, member), \
!spa_list_is_end(pos, head, member); \
pos = tmp)
(pos) = (tmp))
#define spa_list_for_each_safe_prev(pos, tmp, head, curr, member) \
for (pos = spa_list_last(curr, __typeof__(*pos), member); \
tmp = spa_list_prev(pos, member), \
for ((pos) = spa_list_last(curr, __typeof__(*(pos)), member); \
(tmp) = spa_list_prev(pos, member), \
!spa_list_is_end(pos, head, member); \
pos = tmp)
(pos) = (tmp))
#define spa_list_for_each_safe(pos, tmp, head, member) \
spa_list_for_each_safe_next(pos, tmp, head, head, member)
@ -146,11 +146,11 @@ static inline void spa_list_remove(struct spa_list *elem)
spa_list_prepend(head, &(cursor).member)
#define spa_list_for_each_cursor(pos, cursor, head, member) \
for(pos = spa_list_first(&(cursor).member, __typeof__(*(pos)), member); \
for((pos) = spa_list_first(&(cursor).member, __typeof__(*(pos)), member); \
spa_list_remove(&(pos)->member), \
spa_list_append(&(cursor).member, &(pos)->member), \
!spa_list_is_end(pos, head, member); \
pos = spa_list_next(&cursor, member))
(pos) = spa_list_next(&(cursor), member))
#define spa_list_cursor_end(cursor, member) \
spa_list_remove(&(cursor).member)

View file

@ -55,7 +55,7 @@ extern "C" {
#define spa_strerror(err) \
({ \
int _err = -err; \
int _err = -(err); \
if (SPA_RESULT_IS_ASYNC(err)) \
_err = EINPROGRESS; \
strerror(_err); \

View file

@ -53,7 +53,7 @@ struct spa_ringbuffer {
uint32_t writeindex; /*< the current write index */
};
#define SPA_RINGBUFFER_INIT() (struct spa_ringbuffer) { 0, 0 }
#define SPA_RINGBUFFER_INIT() ((struct spa_ringbuffer) { 0, 0 })
/**
* Initialize a spa_ringbuffer with \a size.

View file

@ -49,7 +49,7 @@ struct acp_dict_item {
const char *key;
const char *value;
};
#define ACP_DICT_ITEM_INIT(key,value) (struct acp_dict_item) { key, value }
#define ACP_DICT_ITEM_INIT(key,value) ((struct acp_dict_item) { (key), (value) })
struct acp_dict {
uint32_t flags;
@ -115,8 +115,8 @@ struct acp_format {
uint32_t map[ACP_MAX_CHANNELS];
};
#define ACP_DICT_INIT(items,n_items) (struct acp_dict) { 0, n_items, items }
#define ACP_DICT_INIT_ARRAY(items) (struct acp_dict) { 0, sizeof(items)/sizeof((items)[0]), items }
#define ACP_DICT_INIT(items,n_items) ((struct acp_dict) { 0, (n_items), (items) })
#define ACP_DICT_INIT_ARRAY(items) ((struct acp_dict) { 0, sizeof(items)/sizeof((items)[0]), (items) })
#define acp_dict_for_each(item, dict) \
for ((item) = (dict)->items; \

View file

@ -39,7 +39,7 @@ typedef struct pa_array {
size_t extend; /**< number of bytes to extend with */
} pa_array;
#define PW_ARRAY_INIT(extend) (struct pa_array) { NULL, 0, 0, extend }
#define PW_ARRAY_INIT(extend) ((struct pa_array) { NULL, 0, 0, (extend) })
#define pa_array_get_len_s(a,s) ((a)->size / (s))
#define pa_array_get_unchecked_s(a,idx,s,t) (t*)((uint8_t*)(a)->data + (int)((idx)*(s)))

View file

@ -140,9 +140,9 @@ struct pw_client_node0_message_port_reuse_buffer {
#define PW_CLIENT_NODE0_MESSAGE_TYPE(message) (((struct pw_client_node0_message*)(message))->body.type.value)
#define PW_CLIENT_NODE0_MESSAGE_INIT(message) (struct pw_client_node0_message) \
#define PW_CLIENT_NODE0_MESSAGE_INIT(message) ((struct pw_client_node0_message) \
{ { { sizeof(struct pw_client_node0_message_body), SPA_TYPE_Struct } }, \
{ SPA_POD_INIT_Int(message) } }
{ SPA_POD_INIT_Int(message) } })
#define PW_CLIENT_NODE0_MESSAGE_INIT_FULL(type,size,message,...) (type) \
{ { { size, SPA_TYPE_Struct } }, \

View file

@ -45,7 +45,7 @@ struct footer_builder {
unsigned int started:1;
};
#define FOOTER_BUILDER_INIT(builder) (struct footer_builder) { builder }
#define FOOTER_BUILDER_INIT(builder) ((struct footer_builder) { (builder) })
static void start_footer_entry(struct footer_builder *fb, uint32_t opcode)
{

View file

@ -219,13 +219,13 @@ do { \
spa_pod_parser_get(prs, \
SPA_POD_Int(&(n_params)), NULL) < 0) \
return -EINVAL; \
params = NULL; \
if (n_params > 0) { \
(params) = NULL; \
if ((n_params) > 0) { \
uint32_t i; \
if (n_params > MAX_PARAM_INFO) \
if ((n_params) > MAX_PARAM_INFO) \
return -ENOSPC; \
params = alloca(n_params * sizeof(struct spa_param_info)); \
for (i = 0; i < n_params; i++) { \
(params) = alloca((n_params) * sizeof(struct spa_param_info)); \
for (i = 0; i < (n_params); i++) { \
if (spa_pod_parser_get(prs, \
SPA_POD_Id(&(params)[i].id), \
SPA_POD_Int(&(params)[i].flags), NULL) < 0) \
@ -240,18 +240,18 @@ do { \
do { \
if (spa_pod_parser_push_struct(prs, f) < 0 || \
spa_pod_parser_get(prs, \
SPA_POD_Int(&n_permissions), NULL) < 0) \
SPA_POD_Int(&(n_permissions)), NULL) < 0) \
return -EINVAL; \
permissions = NULL; \
if (n_permissions > 0) { \
(permissions) = NULL; \
if ((n_permissions) > 0) { \
uint32_t i; \
if (n_permissions > MAX_PERMISSIONS) \
if ((n_permissions) > MAX_PERMISSIONS) \
return -ENOSPC; \
permissions = alloca(n_permissions * sizeof(struct pw_permission)); \
for (i = 0; i < n_permissions; i++) { \
(permissions) = alloca((n_permissions) * sizeof(struct pw_permission)); \
for (i = 0; i < (n_permissions); i++) { \
if (spa_pod_parser_get(prs, \
SPA_POD_Int(&permissions[i].id), \
SPA_POD_Int(&permissions[i].permissions), NULL) < 0) \
SPA_POD_Int(&(permissions)[i].id), \
SPA_POD_Int(&(permissions)[i].permissions), NULL) < 0) \
return -EINVAL; \
} \
} \

View file

@ -415,7 +415,7 @@ struct spa_pod_prop_body0 {
(iter) <= SPA_PTROFF((body), (_size)-(body)->value.size, __typeof__(*iter)); \
(iter) = SPA_PTROFF((iter), (body)->value.size, __typeof__(*iter)))
#define SPA0_POD_PROP_N_VALUES(b,size) ((size - sizeof(struct spa_pod_prop_body0)) / (b)->value.size)
#define SPA0_POD_PROP_N_VALUES(b,size) (((size) - sizeof(struct spa_pod_prop_body0)) / (b)->value.size)
static int remap_from_v2(uint32_t type, void *body, uint32_t size, struct pw_impl_client *client,
struct spa_pod_builder *builder)

View file

@ -35,13 +35,13 @@
#define MAX_PARAMS 32
#define manager_emit_sync(m) spa_hook_list_call(&m->hooks, struct pw_manager_events, sync, 0)
#define manager_emit_added(m,o) spa_hook_list_call(&m->hooks, struct pw_manager_events, added, 0, o)
#define manager_emit_updated(m,o) spa_hook_list_call(&m->hooks, struct pw_manager_events, updated, 0, o)
#define manager_emit_removed(m,o) spa_hook_list_call(&m->hooks, struct pw_manager_events, removed, 0, o)
#define manager_emit_metadata(m,o,s,k,t,v) spa_hook_list_call(&m->hooks, struct pw_manager_events, metadata,0,o,s,k,t,v)
#define manager_emit_disconnect(m) spa_hook_list_call(&m->hooks, struct pw_manager_events, disconnect, 0)
#define manager_emit_object_data_timeout(m,o,k) spa_hook_list_call(&m->hooks, struct pw_manager_events, object_data_timeout,0,o,k)
#define manager_emit_sync(m) spa_hook_list_call(&(m)->hooks, struct pw_manager_events, sync, 0)
#define manager_emit_added(m,o) spa_hook_list_call(&(m)->hooks, struct pw_manager_events, added, 0, o)
#define manager_emit_updated(m,o) spa_hook_list_call(&(m)->hooks, struct pw_manager_events, updated, 0, o)
#define manager_emit_removed(m,o) spa_hook_list_call(&(m)->hooks, struct pw_manager_events, removed, 0, o)
#define manager_emit_metadata(m,o,s,k,t,v) spa_hook_list_call(&(m)->hooks, struct pw_manager_events, metadata,0,o,s,k,t,v)
#define manager_emit_disconnect(m) spa_hook_list_call(&(m)->hooks, struct pw_manager_events, disconnect, 0)
#define manager_emit_object_data_timeout(m,o,k) spa_hook_list_call(&(m)->hooks, struct pw_manager_events, object_data_timeout,0,o,k)
struct object;

View file

@ -113,7 +113,7 @@ struct tunnel_info {
const char *domain;
};
#define TUNNEL_INFO(...) (struct tunnel_info){ __VA_ARGS__ }
#define TUNNEL_INFO(...) ((struct tunnel_info){ __VA_ARGS__ })
struct tunnel {
struct spa_list link;

View file

@ -109,7 +109,7 @@ struct tunnel_info {
const char *domain;
};
#define TUNNEL_INFO(...) (struct tunnel_info){ __VA_ARGS__ }
#define TUNNEL_INFO(...) ((struct tunnel_info){ __VA_ARGS__ })
struct tunnel {
struct spa_list link;

View file

@ -52,7 +52,7 @@ struct pw_array {
size_t extend; /**< number of bytes to extend with */
};
#define PW_ARRAY_INIT(extend) (struct pw_array) { NULL, 0, 0, extend }
#define PW_ARRAY_INIT(extend) ((struct pw_array) { NULL, 0, 0, (extend) })
#define pw_array_get_len_s(a,s) ((a)->size / (s))
#define pw_array_get_unchecked_s(a,idx,s,t) SPA_PTROFF((a)->data,(idx)*(s),t)
@ -67,17 +67,17 @@ struct pw_array {
#define pw_array_first(a) ((a)->data)
#define pw_array_end(a) SPA_PTROFF((a)->data, (a)->size, void)
#define pw_array_check(a,p) (SPA_PTROFF(p,sizeof(*p),void) <= pw_array_end(a))
#define pw_array_check(a,p) (SPA_PTROFF(p,sizeof(*(p)),void) <= pw_array_end(a))
#define pw_array_for_each(pos, array) \
for (pos = (__typeof__(pos)) pw_array_first(array); \
for ((pos) = (__typeof__(pos)) pw_array_first(array); \
pw_array_check(array, pos); \
(pos)++)
#define pw_array_consume(pos, array) \
for (pos = (__typeof__(pos)) pw_array_first(array); \
for ((pos) = (__typeof__(pos)) pw_array_first(array); \
pw_array_check(array, pos); \
pos = (__typeof__(pos)) pw_array_first(array))
(pos) = (__typeof__(pos)) pw_array_first(array))
#define pw_array_remove(a,p) \
({ \

View file

@ -1179,7 +1179,7 @@ struct match {
struct pw_filter *filter;
int count;
};
#define MATCH_INIT(f) (struct match){ .filter = f }
#define MATCH_INIT(f) ((struct match){ .filter = (f) })
static int execute_match(void *data, const char *location, const char *action,
const char *val, size_t len)

View file

@ -116,7 +116,7 @@ _pw_log_topic_new(struct spa_log_topic *topic);
*/
#define PW_LOG_TOPIC_STATIC(var, topic) \
static struct spa_log_topic var##__LINE__ = SPA_LOG_TOPIC(0, topic); \
static struct spa_log_topic *var = &(var##__LINE__)
static struct spa_log_topic *(var) = &(var##__LINE__)
/**
* Declare a static log topic named \a var.
@ -131,7 +131,7 @@ _pw_log_topic_new(struct spa_log_topic *topic);
*/
#define PW_LOG_TOPIC(var, topic) \
struct spa_log_topic var##__LINE__ = SPA_LOG_TOPIC(0, topic); \
struct spa_log_topic *var = &(var##__LINE__)
struct spa_log_topic *(var) = &(var##__LINE__)
#define PW_LOG_TOPIC_INIT(var) \
spa_log_topic_init(pw_log_get(), var);

View file

@ -85,7 +85,7 @@ struct pw_map {
};
/** \param extend the amount of bytes to grow the map with when needed */
#define PW_MAP_INIT(extend) (struct pw_map) { PW_ARRAY_INIT(extend), SPA_ID_INVALID }
#define PW_MAP_INIT(extend) ((struct pw_map) { PW_ARRAY_INIT(extend), SPA_ID_INVALID })
/**
* Get the number of currently allocated elements in the map.

View file

@ -66,7 +66,7 @@ struct pw_permission {
uint32_t permissions; /**< bitmask of above permissions */
};
#define PW_PERMISSION_INIT(id,p) (struct pw_permission){ (id), (p) }
#define PW_PERMISSION_INIT(id,p) ((struct pw_permission){ (id), (p) })
#define PW_PERMISSION_FORMAT "%c%c%c%c"
#define PW_PERMISSION_ARGS(permission) \

View file

@ -177,7 +177,7 @@ static inline struct spa_param_info *pw_param_info_find(struct spa_param_info in
return NULL;
}
#define pw_protocol_emit_destroy(p) spa_hook_list_call(&p->listener_list, struct pw_protocol_events, destroy, 0)
#define pw_protocol_emit_destroy(p) spa_hook_list_call(&(p)->listener_list, struct pw_protocol_events, destroy, 0)
struct pw_protocol {
struct spa_list link; /**< link in context protocol_list */
@ -805,7 +805,7 @@ struct pw_impl_port_implementation {
#define pw_impl_port_emit_param_changed(p,i) pw_impl_port_emit(p, param_changed, 1, i)
#define pw_impl_port_emit_latency_changed(p) pw_impl_port_emit(p, latency_changed, 2)
#define PW_IMPL_PORT_IS_CONTROL(port) SPA_FLAG_MASK(port->flags, \
#define PW_IMPL_PORT_IS_CONTROL(port) SPA_FLAG_MASK((port)->flags, \
PW_IMPL_PORT_FLAG_BUFFERS|PW_IMPL_PORT_FLAG_CONTROL,\
PW_IMPL_PORT_FLAG_CONTROL)
struct pw_impl_port {

View file

@ -1402,7 +1402,7 @@ struct match {
struct pw_stream *stream;
int count;
};
#define MATCH_INIT(s) (struct match){ .stream = s }
#define MATCH_INIT(s) ((struct match){ .stream = (s) })
static int execute_match(void *data, const char *location, const char *action,
const char *val, size_t len)

View file

@ -91,7 +91,7 @@ static void do_stop(void *data, uint64_t count)
#define CHECK(expression,label) \
do { \
if ((errno = expression) != 0) { \
if ((errno = (expression)) != 0) { \
res = -errno; \
pw_log_error(#expression ": %s", strerror(errno)); \
goto label; \

View file

@ -37,7 +37,7 @@
#define CHECK(expression,label) \
do { \
if ((errno = expression) != 0) { \
if ((errno = (expression)) != 0) { \
res = -errno; \
pw_log_error(#expression ": %s", strerror(errno)); \
goto label; \