mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-31 11:09:04 -05:00
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:
parent
bb4f274ae0
commit
671a7102ff
46 changed files with 162 additions and 156 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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, \
|
||||
|
|
|
|||
|
|
@ -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) \
|
||||
|
|
|
|||
|
|
@ -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: \
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue