Skip to content

Commit

Permalink
Remove more causes of warnings at -Wextra levels
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebrady committed Mar 7, 2018
1 parent 7970a54 commit 0cd8a2c
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 29 deletions.
3 changes: 2 additions & 1 deletion audio_ao.c
Original file line number Diff line number Diff line change
Expand Up @@ -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); }

Expand Down
6 changes: 3 additions & 3 deletions audio_dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"); }

Expand Down
27 changes: 18 additions & 9 deletions audio_pa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
3 changes: 2 additions & 1 deletion audio_pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
8 changes: 5 additions & 3 deletions audio_sndio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions audio_soundio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions audio_stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions player.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 5 additions & 5 deletions tinysvcmdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0cd8a2c

Please sign in to comment.