From b7026bf248948a6a30386ddbcc137f48f369a51e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 19 Aug 2008 22:39:54 +0200 Subject: add a few more gcc warning flags and fix quite a few problems found by doing so --- src/utils/pacat.c | 22 +++++++++++----------- src/utils/pactl.c | 18 +++++++++--------- src/utils/padsp.c | 32 ++++++++++++++++---------------- src/utils/paplay.c | 14 +++++++------- 4 files changed, 43 insertions(+), 43 deletions(-) (limited to 'src/utils') diff --git a/src/utils/pacat.c b/src/utils/pacat.c index 32fa6bcf..c1826d7b 100644 --- a/src/utils/pacat.c +++ b/src/utils/pacat.c @@ -274,8 +274,8 @@ static void context_state_callback(pa_context *c, void *userdata) { if (latency > 0) { memset(&buffer_attr, 0, sizeof(buffer_attr)); - buffer_attr.tlength = latency; - buffer_attr.minreq = process_time; + buffer_attr.tlength = (uint32_t) latency; + buffer_attr.minreq = (uint32_t) process_time; buffer_attr.maxlength = (uint32_t) -1; buffer_attr.prebuf = (uint32_t) -1; flags |= PA_STREAM_ADJUST_LATENCY; @@ -391,7 +391,7 @@ static void stdin_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_even return; } - buffer_length = r; + buffer_length = (uint32_t) r; buffer_index = 0; if (w) @@ -422,8 +422,8 @@ static void stdout_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_eve return; } - buffer_length -= r; - buffer_index += r; + buffer_length -= (uint32_t) r; + buffer_index += (uint32_t) r; if (!buffer_length) { pa_xfree(buffer); @@ -456,7 +456,7 @@ static void stream_update_timing_callback(pa_stream *s, int success, void *userd fprintf(stderr, _("Time: %0.3f sec; Latency: %0.0f usec. \r"), (float) usec / 1000000, - (float) l * (negative?-1:1)); + (float) l * (negative?-1.0f:1.0f)); } /* Someone requested that the latency is shown */ @@ -626,12 +626,12 @@ int main(int argc, char *argv[]) { case ARG_VOLUME: { int v = atoi(optarg); - volume = v < 0 ? 0 : v; + volume = v < 0 ? 0U : (pa_volume_t) v; break; } case ARG_CHANNELS: - sample_spec.channels = atoi(optarg); + sample_spec.channels = (uint8_t) atoi(optarg); break; case ARG_SAMPLEFORMAT: @@ -639,7 +639,7 @@ int main(int argc, char *argv[]) { break; case ARG_SAMPLERATE: - sample_spec.rate = atoi(optarg); + sample_spec.rate = (uint32_t) atoi(optarg); break; case ARG_CHANNELMAP: @@ -672,14 +672,14 @@ int main(int argc, char *argv[]) { break; case ARG_LATENCY: - if (((latency = atoi(optarg))) <= 0) { + if (((latency = (size_t) atoi(optarg))) <= 0) { fprintf(stderr, _("Invalid latency specification '%s'\n"), optarg); goto quit; } break; case ARG_PROCESS_TIME: - if (((process_time = atoi(optarg))) <= 0) { + if (((process_time = (size_t) atoi(optarg))) <= 0) { fprintf(stderr, _("Invalid process time specification '%s'\n"), optarg); goto quit; } diff --git a/src/utils/pactl.c b/src/utils/pactl.c index 3f00df1b..2f430ca7 100644 --- a/src/utils/pactl.c +++ b/src/utils/pactl.c @@ -555,7 +555,7 @@ static void stream_write_callback(pa_stream *s, size_t length, void *userdata) { d = pa_xmalloc(length); assert(sample_length >= length); - l = length/pa_frame_size(&sample_spec); + l = (sf_count_t) (length/pa_frame_size(&sample_spec)); if ((sf_readf_float(sndfile, d, l)) != l) { pa_xfree(d); @@ -791,11 +791,11 @@ int main(int argc, char *argv[]) { goto quit; } - sample_spec.format = PA_SAMPLE_FLOAT32; - sample_spec.rate = sfinfo.samplerate; - sample_spec.channels = sfinfo.channels; + sample_spec.format = PA_SAMPLE_FLOAT32; + sample_spec.rate = (uint32_t) sfinfo.samplerate; + sample_spec.channels = (uint8_t) sfinfo.channels; - sample_length = sfinfo.frames*pa_frame_size(&sample_spec); + sample_length = (size_t)sfinfo.frames*pa_frame_size(&sample_spec); } else if (!strcmp(argv[optind], "play-sample")) { action = PLAY_SAMPLE; if (argc != optind+2 && argc != optind+3) { @@ -823,7 +823,7 @@ int main(int argc, char *argv[]) { goto quit; } - sink_input_idx = atoi(argv[optind+1]); + sink_input_idx = (uint32_t) atoi(argv[optind+1]); sink_name = pa_xstrdup(argv[optind+2]); } else if (!strcmp(argv[optind], "move-source-output")) { action = MOVE_SOURCE_OUTPUT; @@ -832,7 +832,7 @@ int main(int argc, char *argv[]) { goto quit; } - source_output_idx = atoi(argv[optind+1]); + source_output_idx = (uint32_t) atoi(argv[optind+1]); source_name = pa_xstrdup(argv[optind+2]); } else if (!strcmp(argv[optind], "load-module")) { int i; @@ -852,7 +852,7 @@ int main(int argc, char *argv[]) { n += strlen(argv[i])+1; if (n > 0) { - p = module_args = pa_xnew0(char, n); + p = module_args = pa_xmalloc(n); for (i = optind+2; i < argc; i++) p += sprintf(p, "%s%s", p == module_args ? "" : " ", argv[i]); @@ -866,7 +866,7 @@ int main(int argc, char *argv[]) { goto quit; } - module_index = atoi(argv[optind+1]); + module_index = (uint32_t) atoi(argv[optind+1]); } else if (!strcmp(argv[optind], "suspend-sink")) { action = SUSPEND_SINK; diff --git a/src/utils/padsp.c b/src/utils/padsp.c index c82fde64..134a7e58 100644 --- a/src/utils/padsp.c +++ b/src/utils/padsp.c @@ -748,7 +748,7 @@ static void fix_metrics(fd_info *i) { /* Number of fragments set? */ if (i->n_fragments < 2) { if (i->fragment_size > 0) { - i->n_fragments = pa_bytes_per_second(&i->sample_spec) / 2 / i->fragment_size; + i->n_fragments = (unsigned) (pa_bytes_per_second(&i->sample_spec) / 2 / i->fragment_size); if (i->n_fragments < 2) i->n_fragments = 2; } else @@ -864,7 +864,7 @@ static int fd_info_copy_data(fd_info *i, int force) { return -1; } - if (pa_stream_write(i->play_stream, i->buf, r, free, 0, PA_SEEK_RELATIVE) < 0) { + if (pa_stream_write(i->play_stream, i->buf, (size_t) r, free, 0, PA_SEEK_RELATIVE) < 0) { debug(DEBUG_LEVEL_NORMAL, __FILE__": pa_stream_write(): %s\n", pa_strerror(pa_context_errno(i->context))); return -1; } @@ -872,7 +872,7 @@ static int fd_info_copy_data(fd_info *i, int force) { i->buf = NULL; assert(n >= (size_t) r); - n -= r; + n -= (size_t) r; } if (n >= i->fragment_size) @@ -916,7 +916,7 @@ static int fd_info_copy_data(fd_info *i, int force) { } assert((size_t)r <= len - i->rec_offset); - i->rec_offset += r; + i->rec_offset += (size_t) r; if (i->rec_offset == len) { if (pa_stream_drop(i->rec_stream) < 0) { @@ -927,7 +927,7 @@ static int fd_info_copy_data(fd_info *i, int force) { } assert(n >= (size_t) r); - n -= r; + n -= (size_t) r; } if (n >= i->fragment_size) @@ -998,10 +998,10 @@ static int create_playback_stream(fd_info *i) { pa_stream_set_latency_update_callback(i->play_stream, stream_latency_update_cb, i); memset(&attr, 0, sizeof(attr)); - attr.maxlength = i->fragment_size * (i->n_fragments+1); - attr.tlength = i->fragment_size * i->n_fragments; - attr.prebuf = i->fragment_size; - attr.minreq = i->fragment_size; + attr.maxlength = (uint32_t) (i->fragment_size * (i->n_fragments+1)); + attr.tlength = (uint32_t) (i->fragment_size * i->n_fragments); + attr.prebuf = (uint32_t) i->fragment_size; + attr.minreq = (uint32_t) i->fragment_size; flags = PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE; if (i->play_precork) { @@ -1013,9 +1013,9 @@ static int create_playback_stream(fd_info *i) { goto fail; } - n = i->fragment_size; + n = (int) i->fragment_size; setsockopt(i->app_fd, SOL_SOCKET, SO_SNDBUF, &n, sizeof(n)); - n = i->fragment_size; + n = (int) i->fragment_size; setsockopt(i->thread_fd, SOL_SOCKET, SO_RCVBUF, &n, sizeof(n)); return 0; @@ -1042,8 +1042,8 @@ static int create_record_stream(fd_info *i) { pa_stream_set_latency_update_callback(i->rec_stream, stream_latency_update_cb, i); memset(&attr, 0, sizeof(attr)); - attr.maxlength = i->fragment_size * (i->n_fragments+1); - attr.fragsize = i->fragment_size; + attr.maxlength = (uint32_t) (i->fragment_size * (i->n_fragments+1)); + attr.fragsize = (uint32_t) i->fragment_size; flags = PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE; if (i->rec_precork) { @@ -1055,9 +1055,9 @@ static int create_record_stream(fd_info *i) { goto fail; } - n = i->fragment_size; + n = (int) i->fragment_size; setsockopt(i->app_fd, SOL_SOCKET, SO_RCVBUF, &n, sizeof(n)); - n = i->fragment_size; + n = (int) i->fragment_size; setsockopt(i->thread_fd, SOL_SOCKET, SO_SNDBUF, &n, sizeof(n)); return 0; @@ -1474,7 +1474,7 @@ int open(const char *filename, int flags, ...) { if (flags & O_CREAT) { va_start(args, flags); if (sizeof(mode_t) < sizeof(int)) - mode = va_arg(args, int); + mode = (mode_t) va_arg(args, int); else mode = va_arg(args, mode_t); va_end(args); diff --git a/src/utils/paplay.c b/src/utils/paplay.c index 9264a940..df2edf62 100644 --- a/src/utils/paplay.c +++ b/src/utils/paplay.c @@ -107,14 +107,14 @@ static void stream_write_callback(pa_stream *s, size_t length, void *userdata) { if (readf_function) { size_t k = pa_frame_size(&sample_spec); - if ((bytes = readf_function(sndfile, data, length/k)) > 0) - bytes *= k; + if ((bytes = readf_function(sndfile, data, (sf_count_t) (length/k))) > 0) + bytes *= (sf_count_t) k; } else - bytes = sf_read_raw(sndfile, data, length); + bytes = sf_read_raw(sndfile, data, (sf_count_t) length); if (bytes > 0) - pa_stream_write(s, data, bytes, pa_xfree, 0, PA_SEEK_RELATIVE); + pa_stream_write(s, data, (size_t) bytes, pa_xfree, 0, PA_SEEK_RELATIVE); else pa_xfree(data); @@ -283,7 +283,7 @@ int main(int argc, char *argv[]) { case ARG_VOLUME: { int v = atoi(optarg); - volume = v < 0 ? 0 : v; + volume = v < 0 ? 0U : (pa_volume_t) v; break; } @@ -315,8 +315,8 @@ int main(int argc, char *argv[]) { goto quit; } - sample_spec.rate = sfinfo.samplerate; - sample_spec.channels = sfinfo.channels; + sample_spec.rate = (uint32_t) sfinfo.samplerate; + sample_spec.channels = (uint8_t) sfinfo.channels; readf_function = NULL; -- cgit