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

@ -53,6 +53,12 @@ if cc.get_id() == 'gcc'
'-Wpointer-arith',
'-Wformat-security',
'-Werror=suggest-attribute=format',
'-Wmissing-braces',
'-Wno-missing-field-initializers',
'-Wno-unused-parameter',
'-Wtype-limits',
'-Wold-style-declaration',
'-Wvariadic-macros',
# '-DSPA_DEBUG_MEMCPY',
# '-DFASTPATH',
language : 'c')

View file

@ -1572,7 +1572,8 @@ static int client_node_port_use_buffers(void *object,
struct client *c = (struct client *) object;
struct port *p = GET_PORT(c, direction, port_id);
struct buffer *b;
uint32_t i, j, fl, res;
uint32_t i, j, fl;
int res;
struct mix *mix;
if (!p->valid) {
@ -4593,7 +4594,7 @@ jack_midi_data_t* jack_midi_event_reserve(void *port_buffer,
buffer_size = mb->buffer_size;
if (SPA_UNLIKELY(time < 0 || time >= mb->nframes)) {
if (SPA_UNLIKELY(time >= mb->nframes)) {
pw_log_warn("midi %p: time:%d frames:%d", port_buffer, time, mb->nframes);
goto failed;
}

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) \

View file

@ -199,7 +199,7 @@ static void sanitize_map(snd_pcm_chmap_t* map)
uint32_t i, j, pos;
for (i = 0; i < map->channels; i++) {
if (map->pos[i] < 0 || map->pos[i] > SND_CHMAP_LAST)
if (map->pos[i] > SND_CHMAP_LAST)
map->pos[i] = SND_CHMAP_UNKNOWN;
p = 1LL << map->pos[i];

View file

@ -1045,12 +1045,15 @@ impl_node_port_enum_params(void *object, int seq,
{
a2dp_sbc_t *config = this->transport->configuration;
struct spa_audio_info_raw info = { 0, };
int res;
info.format = SPA_AUDIO_FORMAT_S16;
if ((info.rate = a2dp_sbc_get_frequency(config)) < 0)
if ((res = a2dp_sbc_get_frequency(config)) < 0)
return -EIO;
if ((info.channels = a2dp_sbc_get_channels(config)) < 0)
info.rate = res;
if ((res = a2dp_sbc_get_channels(config)) < 0)
return -EIO;
info.channels = res;
switch (info.channels) {
case 1:

View file

@ -702,12 +702,15 @@ impl_node_port_enum_params(void *object, int seq,
{
a2dp_sbc_t *config = this->transport->configuration;
struct spa_audio_info_raw info = { 0, };
int res;
info.format = SPA_AUDIO_FORMAT_S16;
if ((info.rate = a2dp_sbc_get_frequency(config)) < 0)
if ((res = a2dp_sbc_get_frequency(config)) < 0)
return -EIO;
if ((info.channels = a2dp_sbc_get_channels(config)) < 0)
info.rate = res;
if ((res = a2dp_sbc_get_channels(config)) < 0)
return -EIO;
info.channels = res;
switch (info.channels) {
case 1:

View file

@ -1046,7 +1046,7 @@ error:
return NULL;
}
const static struct pw_protocol_implementaton protocol_impl = {
static const struct pw_protocol_implementaton protocol_impl = {
PW_VERSION_PROTOCOL_IMPLEMENTATION,
.new_client = impl_new_client,
.add_server = impl_add_server,
@ -1105,7 +1105,7 @@ static int impl_ext_end_resource(struct pw_resource *resource,
struct pw_impl_client *client = resource->client;
return client->send_seq = pw_protocol_native_connection_end(data->connection, builder);
}
const static struct pw_protocol_native_ext protocol_ext_impl = {
static const struct pw_protocol_native_ext protocol_ext_impl = {
PW_VERSION_PROTOCOL_NATIVE_EXT,
.begin_proxy = impl_ext_begin_proxy,
.add_proxy_fd = impl_ext_add_proxy_fd,

View file

@ -283,7 +283,7 @@ int pw_rtkit_get_min_nice_level(struct pw_rtkit_bus *connection, int *min_nice_l
return err;
}
long unsigned int pw_rtkit_get_rttime_usec_max(struct pw_rtkit_bus *connection)
long long pw_rtkit_get_rttime_usec_max(struct pw_rtkit_bus *connection)
{
long long retval;
int err;
@ -453,7 +453,7 @@ static void idle_func(struct spa_source *source)
struct pw_rtkit_bus *system_bus;
struct rlimit rl;
int r, rtprio;
long unsigned int rttime;
long long rttime;
uint64_t count;
spa_system_eventfd_read(impl->system, impl->source.fd, &count);
@ -485,8 +485,8 @@ static void idle_func(struct spa_source *source)
rttime = pw_rtkit_get_rttime_usec_max(system_bus);
if (rttime >= 0) {
rl.rlim_cur = SPA_MIN(rl.rlim_cur, rttime);
rl.rlim_max = SPA_MIN(rl.rlim_max, rttime);
rl.rlim_cur = SPA_MIN(rl.rlim_cur, (long unsigned int)rttime);
rl.rlim_max = SPA_MIN(rl.rlim_max, (long unsigned int)rttime);
}
pw_log_debug("rt.prio:%d rt.time.soft:%lu rt.time.hard:%lu",