fix signed and unsigned comparisons

This commit is contained in:
Wim Taymans 2019-01-07 15:04:34 +01:00
parent 9062145e13
commit 89fb73a949
5 changed files with 25 additions and 21 deletions

View file

@ -294,7 +294,7 @@ struct global *pa_context_find_global(pa_context *c, uint32_t id);
struct global *pa_context_find_global_by_name(pa_context *c, uint32_t mask, const char *name); struct global *pa_context_find_global_by_name(pa_context *c, uint32_t mask, const char *name);
struct global *pa_context_find_linked(pa_context *c, uint32_t id); struct global *pa_context_find_linked(pa_context *c, uint32_t id);
#define MAX_BUFFERS 64 #define MAX_BUFFERS 64u
#define MASK_BUFFERS (MAX_BUFFERS-1) #define MASK_BUFFERS (MAX_BUFFERS-1)
struct pa_stream { struct pa_stream {

View file

@ -1404,8 +1404,9 @@ static void card_profile(pa_operation *o, void *userdata)
struct card_data *d = userdata; struct card_data *d = userdata;
struct global *g = d->global; struct global *g = d->global;
pa_context *c = d->context; pa_context *c = d->context;
int res = 0, n_profiles; size_t i, n_profiles;
uint32_t i, id = SPA_ID_INVALID; int res = 0;
uint32_t id = SPA_ID_INVALID;
char buf[1024]; char buf[1024];
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buf, sizeof(buf)); struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buf, sizeof(buf));
struct spa_pod **profiles; struct spa_pod **profiles;
@ -1421,7 +1422,7 @@ static void card_profile(pa_operation *o, void *userdata)
":", SPA_PARAM_PROFILE_id, "i", &test_id, ":", SPA_PARAM_PROFILE_id, "i", &test_id,
":", SPA_PARAM_PROFILE_name, "s", &name, ":", SPA_PARAM_PROFILE_name, "s", &name,
NULL) < 0) { NULL) < 0) {
pw_log_warn("device %d: can't parse profile %d", g->id, i); pw_log_warn("device %d: can't parse profile %zd", g->id, i);
continue; continue;
} }
if (strcmp(name, d->profile) == 0) { if (strcmp(name, d->profile) == 0) {

View file

@ -65,7 +65,9 @@ static GSourceFuncs source_funcs =
source_prepare, source_prepare,
NULL, NULL,
source_dispatch, source_dispatch,
NULL NULL,
NULL,
NULL,
}; };
pa_glib_mainloop *pa_glib_mainloop_new(GMainContext *c) pa_glib_mainloop *pa_glib_mainloop_new(GMainContext *c)

View file

@ -158,7 +158,7 @@ int pa_proplist_get(pa_proplist *p, const char *key, const void **data, size_t *
void pa_proplist_update(pa_proplist *p, pa_update_mode_t mode, const pa_proplist *other) void pa_proplist_update(pa_proplist *p, pa_update_mode_t mode, const pa_proplist *other)
{ {
int i; uint32_t i;
spa_assert(p); spa_assert(p);
spa_assert(mode == PA_UPDATE_SET || mode == PA_UPDATE_MERGE || mode == PA_UPDATE_REPLACE); spa_assert(mode == PA_UPDATE_SET || mode == PA_UPDATE_MERGE || mode == PA_UPDATE_REPLACE);
@ -324,7 +324,7 @@ int pa_proplist_isempty(pa_proplist *p)
int pa_proplist_equal(pa_proplist *a, pa_proplist *b) int pa_proplist_equal(pa_proplist *a, pa_proplist *b)
{ {
int i; uint32_t i;
spa_assert(a); spa_assert(a);
spa_assert(b); spa_assert(b);

View file

@ -53,14 +53,14 @@ static const uint32_t audio_formats[] = {
static inline uint32_t format_pa2id(pa_stream *s, pa_sample_format_t format) static inline uint32_t format_pa2id(pa_stream *s, pa_sample_format_t format)
{ {
if (format < 0 || format >= SPA_N_ELEMENTS(audio_formats)) if (format < 0 || (size_t)format >= SPA_N_ELEMENTS(audio_formats))
return SPA_AUDIO_FORMAT_UNKNOWN; return SPA_AUDIO_FORMAT_UNKNOWN;
return audio_formats[format]; return audio_formats[format];
} }
static inline pa_sample_format_t format_id2pa(pa_stream *s, uint32_t id) static inline pa_sample_format_t format_id2pa(pa_stream *s, uint32_t id)
{ {
int i; size_t i;
for (i = 0; i < SPA_N_ELEMENTS(audio_formats); i++) { for (i = 0; i < SPA_N_ELEMENTS(audio_formats); i++) {
if (id == audio_formats[i]) if (id == audio_formats[i])
return i; return i;
@ -132,14 +132,14 @@ static const uint32_t audio_channels[] = {
static inline uint32_t channel_pa2id(pa_stream *s, pa_channel_position_t channel) static inline uint32_t channel_pa2id(pa_stream *s, pa_channel_position_t channel)
{ {
if (channel < 0 || channel >= SPA_N_ELEMENTS(audio_channels)) if (channel < 0 || (size_t)channel >= SPA_N_ELEMENTS(audio_channels))
return SPA_AUDIO_CHANNEL_UNKNOWN; return SPA_AUDIO_CHANNEL_UNKNOWN;
return audio_channels[channel]; return audio_channels[channel];
} }
static inline pa_channel_position_t channel_id2pa(pa_stream *s, uint32_t id) static inline pa_channel_position_t channel_id2pa(pa_stream *s, uint32_t id)
{ {
int i; size_t i;
for (i = 0; i < SPA_N_ELEMENTS(audio_channels); i++) { for (i = 0; i < SPA_N_ELEMENTS(audio_channels); i++) {
if (id == audio_channels[i]) if (id == audio_channels[i])
return i; return i;
@ -179,7 +179,7 @@ static void dump_buffer_attr(pa_stream *s, pa_buffer_attr *attr)
static void configure_buffers(pa_stream *s) static void configure_buffers(pa_stream *s)
{ {
s->buffer_attr.maxlength = s->maxsize; s->buffer_attr.maxlength = s->maxsize;
if (s->buffer_attr.prebuf == -1) if (s->buffer_attr.prebuf == (uint32_t)-1)
s->buffer_attr.prebuf = s->buffer_attr.minreq; s->buffer_attr.prebuf = s->buffer_attr.minreq;
s->buffer_attr.fragsize = s->buffer_attr.minreq; s->buffer_attr.fragsize = s->buffer_attr.minreq;
dump_buffer_attr(s, &s->buffer_attr); dump_buffer_attr(s, &s->buffer_attr);
@ -256,25 +256,25 @@ static void stream_state_changed(void *data, enum pw_stream_state old,
static const struct spa_pod *get_buffers_param(pa_stream *s, pa_buffer_attr *attr, struct spa_pod_builder *b) static const struct spa_pod *get_buffers_param(pa_stream *s, pa_buffer_attr *attr, struct spa_pod_builder *b)
{ {
const struct spa_pod *param; const struct spa_pod *param;
int32_t blocks, buffers, size, maxsize, stride; uint32_t blocks, buffers, size, maxsize, stride;
blocks = 1; blocks = 1;
stride = pa_frame_size(&s->sample_spec); stride = pa_frame_size(&s->sample_spec);
if (attr->tlength == -1 || attr->tlength == 0) if (attr->tlength == (uint32_t)-1 || attr->tlength == 0)
maxsize = 1024; maxsize = 1024;
else else
maxsize = (attr->tlength / stride); maxsize = (attr->tlength / stride);
if (attr->minreq == -1 || attr->minreq == 0) if (attr->minreq == (uint32_t)-1 || attr->minreq == 0)
size = maxsize; size = maxsize;
else else
size = SPA_MIN(attr->minreq / stride, maxsize); size = SPA_MIN(attr->minreq / stride, maxsize);
if (attr->maxlength == -1) if (attr->maxlength == (uint32_t)-1)
buffers = 3; buffers = 3;
else else
buffers = SPA_CLAMP(attr->maxlength / (size * stride), 3, MAX_BUFFERS); buffers = SPA_CLAMP(attr->maxlength / (size * stride), 3u, MAX_BUFFERS);
pw_log_info("stream %p: stride %d maxsize %d size %u buffers %d", s, stride, maxsize, pw_log_info("stream %p: stride %d maxsize %d size %u buffers %d", s, stride, maxsize,
size, buffers); size, buffers);
@ -310,7 +310,7 @@ static void patch_buffer_attr(pa_stream *s, pa_buffer_attr *attr, pa_stream_flag
else if (s->n_formats == 1) else if (s->n_formats == 1)
pa_format_info_to_sample_spec(s->req_formats[0], &ss, NULL); pa_format_info_to_sample_spec(s->req_formats[0], &ss, NULL);
if ((ms = atoi(e)) < 0 || ms <= 0) { if ((ms = atoi(e)) == 0) {
pa_log_debug("Failed to parse $PULSE_LATENCY_MSEC: %s", e); pa_log_debug("Failed to parse $PULSE_LATENCY_MSEC: %s", e);
} }
else if (!pa_sample_spec_valid(&s->sample_spec)) { else if (!pa_sample_spec_valid(&s->sample_spec)) {
@ -354,7 +354,8 @@ static void stream_format_changed(void *data, const struct spa_pod *format)
uint8_t buffer[4096]; uint8_t buffer[4096];
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer)); struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
struct spa_audio_info info = { 0 }; struct spa_audio_info info = { 0 };
int i, res; int res;
unsigned int i;
if (format == NULL) { if (format == NULL) {
res = 0; res = 0;
@ -502,7 +503,7 @@ pa_stream* stream_new(pa_context *c, const char *name,
{ {
pa_stream *s; pa_stream *s;
char str[1024]; char str[1024];
int i; unsigned int i;
struct pw_properties *props; struct pw_properties *props;
spa_assert(c); spa_assert(c);
@ -1059,7 +1060,7 @@ int pa_stream_begin_write(
else { else {
size_t max = s->buffer_size - s->buffer_offset; size_t max = s->buffer_size - s->buffer_offset;
*data = SPA_MEMBER(s->buffer_data, s->buffer_offset, void); *data = SPA_MEMBER(s->buffer_data, s->buffer_offset, void);
*nbytes = *nbytes != -1 ? SPA_MIN(*nbytes, max) : max; *nbytes = *nbytes != (size_t)-1 ? SPA_MIN(*nbytes, max) : max;
} }
pw_log_trace("peek buffer %p %zd", *data, *nbytes); pw_log_trace("peek buffer %p %zd", *data, *nbytes);