From: Mike Brady Date: Wed, 7 Mar 2018 22:05:11 +0000 (+0000) Subject: Remove more causes of warnings at -Wextra levels X-Git-Tag: 3.2d29~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0cd8a2ce909da89030146cc1702a1114c3ea83f7;p=thirdparty%2Fshairport-sync.git Remove more causes of warnings at -Wextra levels --- diff --git a/audio_ao.c b/audio_ao.c index f6779e7c..3b58ca7c 100644 --- a/audio_ao.c +++ b/audio_ao.c @@ -118,7 +118,8 @@ static void deinit(void) { ao_shutdown(); } -static void start(int sample_rate, int sample_format) {} +static void start(__attribute__((unused)) int sample_rate, + __attribute__((unused)) int sample_format) {} static void play(short buf[], int samples) { ao_play(dev, (char *)buf, samples * 4); } diff --git a/audio_dummy.c b/audio_dummy.c index 98d14efb..b0163de7 100644 --- a/audio_dummy.c +++ b/audio_dummy.c @@ -37,18 +37,18 @@ int Fs; long long starttime, samples_played; -static int init(int argc, char **argv) { return 0; } +static int init(__attribute__((unused)) int argc, __attribute__((unused)) char **argv) { return 0; } static void deinit(void) {} -static void start(int sample_rate, int sample_format) { +static void start(int sample_rate, __attribute__((unused)) int sample_format) { Fs = sample_rate; starttime = 0; samples_played = 0; debug(1, "dummy audio output started at Fs=%d Hz\n", sample_rate); } -static void play(short buf[], int samples) {} +static void play(__attribute__((unused)) short buf[], __attribute__((unused)) int samples) {} static void stop(void) { debug(1, "dummy audio stopped\n"); } diff --git a/audio_pa.c b/audio_pa.c index f1cc08e0..3712f3c1 100644 --- a/audio_pa.c +++ b/audio_pa.c @@ -66,7 +66,7 @@ void stream_state_cb(pa_stream *s, void *mainloop); void stream_success_cb(pa_stream *stream, int success, void *userdata); void stream_write_cb(pa_stream *stream, size_t requested_bytes, void *userdata); -static int init(int argc, char **argv) { +static int init(__attribute__((unused)) int argc, __attribute__((unused)) char **argv) { // set up default values first config.audio_backend_buffer_desired_length = 0.35; @@ -144,7 +144,8 @@ static void deinit(void) { // debug(1, "pa deinit done"); } -static void start(int sample_rate, int sample_format) { +static void start(__attribute__((unused)) int sample_rate, + __attribute__((unused)) int sample_format) { uint32_t buffer_size_in_bytes = (uint32_t)2 * 2 * RATE * 0.1; // hard wired in here // debug(1, "pa_buffer size is %u bytes.", buffer_size_in_bytes); @@ -294,13 +295,16 @@ audio_output audio_pa = {.name = "pa", .parameters = NULL, .mute = NULL}; -void context_state_cb(pa_context *context, void *mainloop) { +void context_state_cb(__attribute__((unused)) pa_context *context, void *mainloop) { pa_threaded_mainloop_signal(mainloop, 0); } -void stream_state_cb(pa_stream *s, void *mainloop) { pa_threaded_mainloop_signal(mainloop, 0); } +void stream_state_cb(__attribute__((unused)) pa_stream *s, void *mainloop) { + pa_threaded_mainloop_signal(mainloop, 0); +} -void stream_write_cb(pa_stream *stream, size_t requested_bytes, void *userdata) { +void stream_write_cb(pa_stream *stream, size_t requested_bytes, + __attribute__((unused)) void *userdata) { /* // play with timing information @@ -348,7 +352,7 @@ void stream_write_cb(pa_stream *stream, size_t requested_bytes, void *userdata) // bytes we can transfer will never be greater than the bytes available pa_stream_begin_write(stream, (void **)&buffer, &bytes_we_can_transfer); - if (bytes_we_can_transfer <= (audio_umb - audio_toq)) { + if (bytes_we_can_transfer <= (size_t)(audio_umb - audio_toq)) { // the bytes are all in a row in the audo buffer memcpy(buffer, audio_toq, bytes_we_can_transfer); audio_toq += bytes_we_can_transfer; @@ -383,9 +387,10 @@ void stream_write_cb(pa_stream *stream, size_t requested_bytes, void *userdata) // %d.",requested_bytes/4,bytes_transferred/4,pa_stream_is_corked(stream)); } -void alt_stream_write_cb(pa_stream *stream, size_t requested_bytes, void *userdata) { +void alt_stream_write_cb(pa_stream *stream, size_t requested_bytes, + __attribute__((unused)) void *userdata) { // debug(1, "***Bytes requested bytes %d.", requested_bytes); - int bytes_remaining = requested_bytes; + size_t bytes_remaining = requested_bytes; while (bytes_remaining > 0) { uint8_t *buffer = NULL; size_t bytes_to_fill = 44100; @@ -410,4 +415,8 @@ void alt_stream_write_cb(pa_stream *stream, size_t requested_bytes, void *userda } } -void stream_success_cb(pa_stream *stream, int success, void *userdata) { return; } +void stream_success_cb(__attribute__((unused)) pa_stream *stream, + __attribute__((unused)) int success, + __attribute__((unused)) void *userdata) { + return; +} diff --git a/audio_pipe.c b/audio_pipe.c index 7b74bbbd..b81401c5 100644 --- a/audio_pipe.c +++ b/audio_pipe.c @@ -44,7 +44,8 @@ static int fd = -1; char *pipename = NULL; int warned = 0; -static void start(int sample_rate, int sample_format) { +static void start(__attribute__((unused)) int sample_rate, + __attribute__((unused)) int sample_format) { // this will leave fd as -1 if a reader hasn't been attached fd = open(pipename, O_WRONLY | O_NONBLOCK); if ((fd < -1) && (warned == 0)) { diff --git a/audio_sndio.c b/audio_sndio.c index 0ba54aca..119e84e1 100644 --- a/audio_sndio.c +++ b/audio_sndio.c @@ -82,7 +82,8 @@ static struct sndio_formats formats[] = {{"S8", SPS_FORMAT_S8, 8, 1, 1, SIO_LE_N static void help() { printf(" -d output-device set the output device [default*|...]\n"); } static int init(int argc, char **argv) { - int i, found, opt, round, rate, bufsz; + int found, opt, round, rate, bufsz; + unsigned int i; const char *devname, *tmp; // set up default values first @@ -210,7 +211,8 @@ static void deinit() { pthread_mutex_unlock(&sndio_mutex); } -static void start(int sample_rate, int sample_format) { +static void start(__attribute__((unused)) int sample_rate, + __attribute__((unused)) int sample_format) { pthread_mutex_lock(&sndio_mutex); if (!sio_start(hdl)) die("sndio: unable to start"); @@ -236,7 +238,7 @@ static void stop() { pthread_mutex_unlock(&sndio_mutex); } -static void onmove_cb(void *arg, int delta) { +static void onmove_cb(__attribute__((unused)) void *arg, int delta) { time_of_last_onmove_cb = get_absolute_time_in_fp(); at_least_one_onmove_cb_seen = 1; played += delta; diff --git a/audio_soundio.c b/audio_soundio.c index 03ec5e6e..1012ec6e 100644 --- a/audio_soundio.c +++ b/audio_soundio.c @@ -77,12 +77,12 @@ static void write_callback(struct SoundIoOutStream *outstream, int frame_count_m soundio_ring_buffer_advance_read_ptr(ring_buffer, read_count * outstream->bytes_per_frame); } -static void underflow_callback(struct SoundIoOutStream *outstream) { +static void underflow_callback(__attribute__((unused)) struct SoundIoOutStream *outstream) { static int count = 0; debug(0, "underflow %d\n", ++count); } -static int init(int argc, char **argv) { +static int init(__attribute__((unused)) int argc, __attribute__((unused)) char **argv) { int err; config.audio_backend_buffer_desired_length = 2.0; diff --git a/audio_stdout.c b/audio_stdout.c index a97df679..35399945 100644 --- a/audio_stdout.c +++ b/audio_stdout.c @@ -38,7 +38,10 @@ static int fd = -1; -static void start(int sample_rate, int sample_format) { fd = STDOUT_FILENO; } +static void start(__attribute__((unused)) int sample_rate, + __attribute__((unused)) int sample_format) { + fd = STDOUT_FILENO; +} static void play(short buf[], int samples) { char errorstring[1024]; @@ -55,7 +58,7 @@ static void stop(void) { // don't close stdout } -static int init(int argc, char **argv) { +static int init(__attribute__((unused)) int argc, __attribute__((unused)) char **argv) { // set up default values first config.audio_backend_buffer_desired_length = 1.0; config.audio_backend_latency_offset = 0; diff --git a/player.c b/player.c index 830a0138..dc34ee48 100644 --- a/player.c +++ b/player.c @@ -1888,14 +1888,13 @@ static void *player_thread_func(void *arg) { // sync_error_out_of_bounds, sync_error); sync_error_out_of_bounds = 0; - size_t filler_length = - config.resyncthreshold * config.output_rate; // number of samples + int filler_length = config.resyncthreshold * config.output_rate; // number of samples if ((sync_error > 0) && (sync_error > filler_length)) { // debug(1, "Large positive sync error: %lld.", sync_error); frames_to_drop = sync_error / conn->output_sample_ratio; } else if ((sync_error < 0) && ((-sync_error) > filler_length)) { // debug(1, "Large negative sync error: %lld. Inserting silence.", sync_error); - size_t silence_length = -sync_error; + int silence_length = -sync_error; if (silence_length > (filler_length * 5)) silence_length = filler_length * 5; diff --git a/tinysvcmdns.c b/tinysvcmdns.c index 5d2f4d81..ebf6fea7 100644 --- a/tinysvcmdns.c +++ b/tinysvcmdns.c @@ -760,7 +760,7 @@ static size_t mdns_parse_rr(uint8_t *pkt_buf, size_t pkt_len, size_t off, struct break; } rr->data.AAAA.addr = malloc(sizeof(struct in6_addr)); - int i; + unsigned int i; for (i = 0; i < sizeof(struct in6_addr); i++) rr->data.AAAA.addr->s6_addr[i] = p[i]; p += sizeof(struct in6_addr); @@ -883,8 +883,8 @@ struct mdns_pkt *mdns_parse_pkt(uint8_t *pkt_buf, size_t pkt_len) { // encodes a name (label) into a packet using the name compression scheme // encoded names will be added to the compression list for subsequent use -static size_t mdns_encode_name(uint8_t *pkt_buf, size_t pkt_len, size_t off, const uint8_t *name, - struct name_comp *comp) { +static size_t mdns_encode_name(uint8_t *pkt_buf, __attribute__((unused)) size_t pkt_len, size_t off, + const uint8_t *name, struct name_comp *comp) { struct name_comp *c, *c_tail = NULL; uint8_t *p = pkt_buf + off; size_t len = 0; @@ -934,7 +934,7 @@ static size_t mdns_encode_rr(uint8_t *pkt_buf, size_t pkt_len, size_t off, struc size_t l; struct rr_data_txt *txt_rec; uint8_t *label; - int i; + unsigned int i; assert(off < pkt_len); @@ -1025,7 +1025,7 @@ size_t mdns_encode_pkt(struct mdns_pkt *answer, uint8_t *pkt_buf, size_t pkt_len uint8_t *p = pkt_buf; // uint8_t *e = pkt_buf + pkt_len; size_t off; - int i; + unsigned int i; assert(answer != NULL); assert(pkt_len >= 12);