]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Remove more causes of warnings at -Wextra levels
authorMike Brady <mikebrady@eircom.net>
Wed, 7 Mar 2018 22:05:11 +0000 (22:05 +0000)
committerMike Brady <mikebrady@eircom.net>
Wed, 7 Mar 2018 22:05:11 +0000 (22:05 +0000)
audio_ao.c
audio_dummy.c
audio_pa.c
audio_pipe.c
audio_sndio.c
audio_soundio.c
audio_stdout.c
player.c
tinysvcmdns.c

index f6779e7c78bd2cfcf5c6260a3226724ea7e054da..3b58ca7c9f795c34d2936954cdb189312b0f7e74 100644 (file)
@@ -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); }
 
index 98d14efbcad68bec83cce5e93c402faea2a1a460..b0163de7ac78dc11320c747ee820629f76d62628 100644 (file)
 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"); }
 
index f1cc08e0283a94d4d695b3de0493875fa39ae011..3712f3c1087c006d1b1a6c00c873c62f030adb26 100644 (file)
@@ -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;
+}
index 7b74bbbdc09b47b58bdc0ed67caf6a204f3bc8b0..b81401c52fcae59a2e13c41c019fc8b87b9d9036 100644 (file)
@@ -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)) {
index 0ba54aca83f0eed16ca6d4d150f56c82c84c4cf8..119e84e1a35305655824cd6cfeb55bad99f1532a 100644 (file)
@@ -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;
index 03ec5e6e5a3279bacfd69b8a792e27bfa33f6946..1012ec6e6d1ad5154d1defcab961bb7c8fbbb841 100644 (file)
@@ -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;
index a97df679f5b96f27c3bab7cbe9694c0b5655a692..3539994513c991609266cb60186c4ecfb22ae83c 100644 (file)
 
 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;
index 830a01380eb46001bc1f65524882c66ac933c883..dc34ee48d9638fc1e8857b0eb1b4876517992a04 100644 (file)
--- 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;
 
index 5d2f4d81035f8ef833369463a308fbddf50f86f3..ebf6fea709d5a6aab8864daddf99513b24891393 100644 (file)
@@ -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);