From 8259ae60e83613f9a84da070bfed12ccc43da844 Mon Sep 17 00:00:00 2001 From: James Laird Date: Tue, 4 Jun 2013 00:18:46 +1000 Subject: [PATCH] die/warn functions now have implicit newline at the end --- audio_ao.c | 8 ++++---- common.c | 2 ++ mdns.c | 2 +- player.c | 14 +++++++------- rtp.c | 10 +++++----- rtsp.c | 22 +++++++++++----------- shairport.c | 2 +- 7 files changed, 31 insertions(+), 29 deletions(-) diff --git a/audio_ao.c b/audio_ao.c index c1d7a3d03..269aac56a 100644 --- a/audio_ao.c +++ b/audio_ao.c @@ -56,7 +56,7 @@ static int init(int argc, char **argv) { case 'd': driver = ao_driver_id(optarg); if (!driver) - die("could not find ao driver %s\n", optarg); + die("could not find ao driver %s", optarg); break; case 'i': ao_append_option(&ao_opts, "id", optarg); @@ -70,13 +70,13 @@ static int init(int argc, char **argv) { case 'o': mid = strchr(optarg, '='); if (!mid) - die("Expected an = in audio option %s\n", optarg); + die("Expected an = in audio option %s", optarg); *mid = 0; ao_append_option(&ao_opts, optarg, mid+1); break; default: help(); - die("Invalid audio option -%c specified\n", opt); + die("Invalid audio option -%c specified", opt); } } @@ -102,7 +102,7 @@ static void deinit(void) { static void start(int sample_rate) { if (sample_rate != 44100) - die("unexpected sample rate!\n"); + die("unexpected sample rate!"); } static void play(short buf[], int samples) { diff --git a/common.c b/common.c index 89ab4803f..5b8050eb3 100644 --- a/common.c +++ b/common.c @@ -45,6 +45,7 @@ void die(char *format, ...) { va_start(args, format); vfprintf(stderr, format, args); va_end(args); + fprintf(stderr, "\n"); shairport_shutdown(); } @@ -54,6 +55,7 @@ void warn(char *format, ...) { va_start(args, format); vfprintf(stderr, format, args); va_end(args); + fprintf(stderr, "\n"); } void debug(int level, char *format, ...) { diff --git a/mdns.c b/mdns.c index 936e33385..a593316ce 100644 --- a/mdns.c +++ b/mdns.c @@ -79,5 +79,5 @@ void mdns_register(void) { mdns_port, RECORD, NULL}; execvp(mac_argv[0], mac_argv); - die("Could not establish mDNS advertisement!\n"); + die("Could not establish mDNS advertisement!"); } diff --git a/player.c b/player.c index 18df1a7e2..639354ce2 100644 --- a/player.c +++ b/player.c @@ -209,7 +209,7 @@ void player_put_packet(seq_t seqno, uint8_t *data, int len) { } else if (seq_order(ab_read, seqno)) { // late but not yet played abuf = audio_buffer + BUFIDX(seqno); } else { // too late. - warn("late packet %04X (%04X:%04X)\n", seqno, ab_read, ab_write); + warn("late packet %04X (%04X:%04X)", seqno, ab_read, ab_write); } buf_fill = seq_diff(ab_read, ab_write); pthread_mutex_unlock(&ab_mutex); @@ -353,13 +353,13 @@ static short *buffer_get_frame(void) { buf_fill = seq_diff(ab_read, ab_write); if (buf_fill < 1 || !ab_synced) { if (buf_fill < 1) - warn("underrun.\n"); + warn("underrun."); ab_buffering = 1; pthread_mutex_unlock(&ab_mutex); return 0; } if (buf_fill >= BUFFER_FRAMES) { // overrunning! uh-oh. restart at a sane distance - warn("overrun.\n"); + warn("overrun."); ab_read = ab_write - config.buffer_start_fill; } read = ab_read; @@ -381,7 +381,7 @@ static short *buffer_get_frame(void) { abuf_t *curframe = audio_buffer + BUFIDX(read); if (!curframe->ready) { - warn("missing frame %04X.\n", read); + warn("missing frame %04X.", read); memset(curframe->data, 0, FRAME_BYTES(frame_size)); } curframe->ready = 0; @@ -503,7 +503,7 @@ void player_flush(void) { int player_play(stream_cfg *stream) { if (config.buffer_start_fill > BUFFER_FRAMES) - die("specified buffer starting fill %d > buffer size %d\n", + die("specified buffer starting fill %d > buffer size %d", config.buffer_start_fill, BUFFER_FRAMES); AES_set_decrypt_key(stream->aeskey, 128, &aes); @@ -518,7 +518,7 @@ int player_play(stream_cfg *stream) { please_stop = 0; if (config.cmd_start && !fork()) { if (system(config.cmd_start)) - warn("exec of external start command failed\n"); + warn("exec of external start command failed"); exit(0); } config.output->start(sampling_rate); @@ -533,7 +533,7 @@ void player_stop(void) { config.output->stop(); if (config.cmd_stop && !fork()) { if (system(config.cmd_stop)) - warn("exec of external stop command failed\n"); + warn("exec of external stop command failed"); exit(0); } free_buffer(); diff --git a/rtp.c b/rtp.c index e9ebc6f97..b7f42a199 100644 --- a/rtp.c +++ b/rtp.c @@ -79,7 +79,7 @@ static void *rtp_receiver(void *arg) { } debug(1, "Unknown RTP packet of type 0x%02X length %d seqno %d\n", type, nread, seqno); } - warn("Unknown RTP packet of type 0x%02X length %d\n", type, nread); + warn("Unknown RTP packet of type 0x%02X length %d", type, nread); } debug(1, "RTP thread interrupted. terminating.\n"); @@ -130,7 +130,7 @@ static int bind_port(SOCKADDR *remote) { int rtp_setup(SOCKADDR *remote, int cport, int tport) { if (running) - die("rtp_setup called with active stream!\n"); + die("rtp_setup called with active stream!"); debug(1, "rtp_setup: cport=%d tport=%d\n", cport, tport); @@ -162,7 +162,7 @@ int rtp_setup(SOCKADDR *remote, int cport, int tport) { void rtp_shutdown(void) { if (!running) - die("rtp_shutdown called without active stream!\n"); + die("rtp_shutdown called without active stream!"); please_shutdown = 1; pthread_kill(rtp_thread, SIGUSR1); @@ -173,9 +173,9 @@ void rtp_shutdown(void) { void rtp_request_resend(seq_t first, seq_t last) { if (!running) - die("rtp_request_resend called without active stream!\n"); + die("rtp_request_resend called without active stream!"); - warn("requesting resend on %d packets (%04X:%04X)\n", + warn("requesting resend on %d packets (%04X:%04X)", seq_diff(first,last) + 1, first, last); char req[8]; // *not* a standard RTCP NACK diff --git a/rtsp.c b/rtsp.c index 9e048fc56..951020cef 100644 --- a/rtsp.c +++ b/rtsp.c @@ -130,7 +130,7 @@ static rtsp_message * msg_init(void) { static int msg_add_header(rtsp_message *msg, char *name, char *value) { if (msg->nheaders >= sizeof(msg->name)/sizeof(char*)) { - warn("too many headers?!\n"); + warn("too many headers?!"); return 1; } @@ -193,7 +193,7 @@ static int msg_handle_line(rtsp_message **pmsg, char *line) { char *p; p = strstr(line, ": "); if (!p) { - warn("bad header: >>%s<<\n", line); + warn("bad header: >>%s<<", line); goto fail; } *p = 0; @@ -248,7 +248,7 @@ static rtsp_message * rtsp_read_request(int fd) { msg_size = msg_handle_line(&msg, buf); if (!msg) { - warn("no RTSP header received\n"); + warn("no RTSP header received"); goto shutdown; } @@ -431,14 +431,14 @@ static void handle_announce(rtsp_conn_info *conn, } if (!paesiv || !prsaaeskey || !pfmtp) { - warn("required params missing from announce\n"); + warn("required params missing from announce"); return; } int len, keylen; uint8_t *aesiv = base64_dec(paesiv, &len); if (len != 16) { - warn("client announced aeskey of %d bytes, wanted 16\n", len); + warn("client announced aeskey of %d bytes, wanted 16", len); free(aesiv); return; } @@ -449,7 +449,7 @@ static void handle_announce(rtsp_conn_info *conn, uint8_t *aeskey = rsa_apply(rsaaeskey, len, &keylen, RSA_MODE_KEY); free(rsaaeskey); if (keylen != 16) { - warn("client announced rsaaeskey of %d bytes, wanted 16\n", keylen); + warn("client announced rsaaeskey of %d bytes, wanted 16", keylen); free(aeskey); return; } @@ -496,7 +496,7 @@ static void apple_challenge(int fd, rtsp_message *req, rtsp_message *resp) { memset(buf, 0, sizeof(buf)); if (chall_len > 16) { - warn("oversized Apple-Challenge!\n"); + warn("oversized Apple-Challenge!"); free(chall); return; } @@ -622,7 +622,7 @@ static int rtsp_auth(char **nonce, rtsp_message *req, rtsp_message *resp) { if (!strcmp(response, buf)) return 0; - warn("auth failed\n"); + warn("auth failed"); authenticate: resp->respcode = 401; @@ -729,7 +729,7 @@ void rtsp_listen_loop(void) { ret = getaddrinfo(NULL, portstr, &hints, &info); if (ret) { - die("getaddrinfo failed: %s\n", gai_strerror(ret)); + die("getaddrinfo failed: %s", gai_strerror(ret)); } for (p=info; p; p=p->ai_next) { @@ -766,7 +766,7 @@ void rtsp_listen_loop(void) { freeaddrinfo(info); if (!nsock) - die("could not bind any listen sockets!\n"); + die("could not bind any listen sockets!"); int maxfd = -1; @@ -816,5 +816,5 @@ void rtsp_listen_loop(void) { FD_SET(sockfd[i], &fds); } perror("select"); - die("fell out of the RTSP select loop\n"); + die("fell out of the RTSP select loop"); } diff --git a/shairport.c b/shairport.c index 8c475bbf3..6531b0ca6 100644 --- a/shairport.c +++ b/shairport.c @@ -170,7 +170,7 @@ int main(int argc, char **argv) { config.output = audio_get_output(config.output_name); if (!config.output) { audio_ls_outputs(); - die("Invalid audio output specified!\n"); + die("Invalid audio output specified!"); } config.output->init(argc-audio_arg, argv+audio_arg);