From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Tue, 30 Dec 2025 14:59:27 +0000 (+0000) Subject: fix lots of errors calling debug() with incorrect argument patterns. X-Git-Tag: 5.0-post-dev~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3aa34cd7125a9d0c92a87feeb01249d95b8a7106;p=thirdparty%2Fshairport-sync.git fix lots of errors calling debug() with incorrect argument patterns. --- diff --git a/activity_monitor.c b/activity_monitor.c index 55841c4a..bdd81c59 100644 --- a/activity_monitor.c +++ b/activity_monitor.c @@ -146,7 +146,7 @@ void *activity_monitor_thread_code(void *arg) { rc = pthread_cond_init(&activity_monitor_cv, NULL); if (rc) - die("activity_monitor: error %d initialising activity_monitor_cv."); + die("activity_monitor: error %d initialising activity_monitor_cv.", rc); pthread_cleanup_push(activity_thread_cleanup_handler, arg); uint64_t sec; diff --git a/audio.c b/audio.c index af517510..7c08de00 100644 --- a/audio.c +++ b/audio.c @@ -327,7 +327,7 @@ uint32_t get_format_settings(const char *stanza_name, const char *setting_name) } *p = '\0'; if (strlen(buf) == 0) - debug(3, "No \"%s\" output format settings.", stanza_name, buf); + debug(3, "No \"%s\" output format settings.", stanza_name); else debug(3, "The \"%s\" output format settings are: \"%s\".", stanza_name, buf); return format_set; @@ -421,7 +421,7 @@ uint32_t get_rate_settings(const char *stanza_name, const char *setting_name) { } *p = '\0'; if (strlen(buf) == 0) - debug(3, "No \"%s\" output rate settings.", stanza_name, buf); + debug(3, "No \"%s\" output rate settings.", stanza_name); else debug(3, "The \"%s\" output rate settings are: \"%s\".", stanza_name, buf); return rate_set; @@ -510,7 +510,7 @@ uint32_t get_channel_settings(const char *stanza_name, const char *setting_name) } *p = '\0'; if (strlen(buf) == 0) - debug(3, "No \"%s\" output channel settings.", stanza_name, buf); + debug(3, "No \"%s\" output channel settings.", stanza_name); else debug(3, "The \"%s\" output channel settings are: \"%s\".", stanza_name, buf); return channel_set; diff --git a/audio_alsa.c b/audio_alsa.c index de9361da..516e3a2c 100644 --- a/audio_alsa.c +++ b/audio_alsa.c @@ -410,7 +410,7 @@ static int get_permissible_configuration_settings() { permissible_configurations[r][f][c] = 0; // i.e. no error, so remove the EINVAL } else { - debug(1, "Can't set format of %u for \"%s\": %s.", + debug(1, "Can't set format %s for \"%s\": %s.", sps_format_description_string(f), alsa_out_dev, snd_strerror(ret)); } @@ -707,7 +707,7 @@ static int actual_open_alsa_device() { ret = snd_pcm_open(&alsa_handle, "hw:0", SND_PCM_STREAM_PLAYBACK, 0); if ((ret == 0) || (ret == -EBUSY)) { // being busy should be okay - inform("the default ALSA device is inaccessible -- \"hw:0\" used instead.", alsa_out_dev); + inform("the default ALSA device is inaccessible -- \"hw:0\" used instead."); set_alsa_out_dev("hw:0"); } } @@ -951,8 +951,8 @@ static int actual_open_alsa_device() { if ((snd_pcm_hw_params_get_rate_numden(alsa_params, &uval, &uval2) == 0) && (uval2 != 0)) // watch for a divide by zero too! - debug(log_level, " precise (rational) rate = %.3f frames per second (i.e. %u/%u).", uval, - uval2, ((double)uval) / uval2); + debug(log_level, " precise (rational) rate = %.3f frames per second (i.e. %u/%u).", (1.0 * uval) / uval2, uval, + uval2); else debug(log_level, " precise (rational) rate information unavailable."); @@ -1260,7 +1260,7 @@ static int init(int argc, char **argv) { else { warn("Invalid disable_synchronization option choice \"%s\". It should " "be \"yes\" or " - "\"no\". It is set to \"no\"."); + "\"no\". It is set to \"no\".", str); config.no_sync = 0; } } @@ -1276,7 +1276,7 @@ static int init(int argc, char **argv) { else { warn("Invalid mute_using_playback_switch option choice \"%s\". It " "should be \"yes\" or " - "\"no\". It is set to \"no\"."); + "\"no\". It is set to \"no\".", str); config.alsa_use_hardware_mute = 0; } } @@ -1290,7 +1290,7 @@ static int init(int argc, char **argv) { else { warn("Invalid use_hardware_mute_if_available option choice \"%s\". It " "should be \"yes\" or " - "\"no\". It is set to \"no\"."); + "\"no\". It is set to \"no\".", str); config.alsa_use_hardware_mute = 0; } } @@ -1304,7 +1304,7 @@ static int init(int argc, char **argv) { else { warn("Invalid use_mmap_if_available option choice \"%s\". It should be " "\"yes\" or \"no\". " - "It remains set to \"yes\"."); + "It remains set to \"yes\".", str); config.no_mmap = 0; } } @@ -1394,7 +1394,7 @@ static int init(int argc, char **argv) { if (value < 0) { warn("Invalid alsa disable_standby_mode_default_rate setting %d. It " "must be greater than 0. Default is %d. No setting is made.", - dvalue, disable_standby_mode_default_rate); + value, disable_standby_mode_default_rate); } else { disable_standby_mode_default_rate = value; } @@ -1405,7 +1405,7 @@ static int init(int argc, char **argv) { if (value < 0) { warn("Invalid alsa disable_standby_mode_default_channels setting %d. It " "must be greater than 0. Default is %d. No setting is made.", - dvalue, disable_standby_mode_default_channels); + value, disable_standby_mode_default_channels); } else { disable_standby_mode_default_channels = value; } @@ -1424,7 +1424,7 @@ static int init(int argc, char **argv) { else { warn("Invalid use_precision_timing option choice \"%s\". It should be " "\"yes\", \"auto\" or \"no\". " - "It remains set to \"%s\".", + "It remains set to \"%s\".", str, config.use_precision_timing == YNA_NO ? "no" : config.use_precision_timing == YNA_AUTO ? "auto" : "yes"); @@ -1882,7 +1882,7 @@ static int precision_delay_and_status(snd_pcm_state_t *state, snd_pcm_sframes_t *delay = delay_temp; if (state != NULL) *state = state_temp; - debug(3, "precision_delay_and_status returning state: %d and delay %d.", state_temp, delay_temp); + debug(3, "precision_delay_and_status returning state: %d and delay %ld.", state_temp, delay_temp); return ret; } @@ -2380,7 +2380,7 @@ static void *alsa_buffer_monitor_thread_code(__attribute__((unused)) void *arg) dither_random_number_store, current_encoded_output_format); ret = do_play(silence, frames_of_silence); - debug(3, "Played %u frames of silence on %u channels, equal to %u bytes.", + debug(3, "Played %u frames of silence on %u channels, equal to %lu bytes.", frames_of_silence, CHANNELS_FROM_ENCODED_FORMAT(current_encoded_output_format), size_of_silence_buffer); frame_count++; diff --git a/common.c b/common.c index 9a27300a..0a289899 100644 --- a/common.c +++ b/common.c @@ -1808,7 +1808,7 @@ void sps_nanosleep(const time_t sec, const long nanosec) { rem = req; } while ((result == -1) && (errno == EINTR)); if (result == -1) - debug(1, "Error in sps_nanosleep of %d sec and %ld nanoseconds: %d.", sec, nanosec, errno); + debug(1, "Error in sps_nanosleep of %ld sec and %ld nanoseconds: %d.", sec, nanosec, errno); } // Mac OS X doesn't have pthread_mutex_timedlock @@ -1918,7 +1918,7 @@ void plist_cleanup(void *arg) { void socket_cleanup(void *arg) { intptr_t fdp = (intptr_t)arg; int soc = fdp; - debug(3, "socket_cleanup called for socket: %" PRIdPTR ".", soc); + debug(3, "socket_cleanup called for socket: %d.", soc); close(fdp); } diff --git a/mdns.c b/mdns.c index 4069ac4f..8f4fa0b8 100644 --- a/mdns.c +++ b/mdns.c @@ -90,7 +90,7 @@ void mdns_register(char **txt_records, char **secondary_txt_records) { } if (*b == NULL) - warn("%s mDNS backend not found"); + warn("mDNS backend not found"); } else { // default -- pick the first back end for (b = mdns_backends; *b; b++) { diff --git a/mdns_avahi.c b/mdns_avahi.c index fe148937..29c360f6 100644 --- a/mdns_avahi.c +++ b/mdns_avahi.c @@ -144,7 +144,7 @@ static void browse_callback(AvahiServiceBrowser *b, AvahiIfIndex interface, Avah /* Called whenever a new services becomes available on the LAN or is removed from the LAN */ switch (event) { case AVAHI_BROWSER_FAILURE: - warn("avahi: browser failure.", + warn("avahi: browser failure: %s.", avahi_strerror(avahi_client_errno(avahi_service_browser_get_client(b)))); avahi_threaded_poll_quit(tpoll); break; diff --git a/player.c b/player.c index b38183eb..5da767ba 100644 --- a/player.c +++ b/player.c @@ -2126,7 +2126,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn, int resync_requested) { if (offset_to_flush_frame > 0) { debug(2, "flush to %u request: flush buffer %u, from " - "%u to %u. ab_write is: %u.", + "%u to %lu. ab_write is: %u.", conn->flush_rtp_timestamp, conn->ab_read, current_packet->timestamp, current_packet->timestamp + current_packet->length - 1, conn->ab_write); @@ -2513,7 +2513,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn, int resync_requested) { CHANNELS_FROM_ENCODED_FORMAT(config.current_output_configuration) * fs); if (silence == NULL) - debug(1, "Failed to allocate %d byte silence buffer.", fs); + debug(1, "Failed to allocate %" PRId64 " byte silence buffer.", fs); else { // generate frames of silence with dither if necessary pthread_cleanup_push(malloc_cleanup, &silence); @@ -2561,7 +2561,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn, int resync_requested) { 1000000000; // debug(1,"%d frames needed.",frame_gap); while (frame_gap > 0) { - ssize_t fs = RATE_FROM_ENCODED_FORMAT(config.current_output_configuration) / 10; + int64_t fs = RATE_FROM_ENCODED_FORMAT(config.current_output_configuration) / 10; if (fs > frame_gap) fs = frame_gap; @@ -2571,7 +2571,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn, int resync_requested) { FORMAT_FROM_ENCODED_FORMAT(config.current_output_configuration)) * CHANNELS_FROM_ENCODED_FORMAT(config.current_output_configuration) * fs); if (silence == NULL) - debug(1, "Failed to allocate %d frame silence buffer.", fs); + debug(1, "Failed to allocate %" PRId64 " frame silence buffer.", fs); else { // debug(1, "No delay function -- outputting %d frames of silence.", fs); pthread_cleanup_push(malloc_cleanup, &silence); @@ -3011,8 +3011,7 @@ static int stuff_buffer_vernier(int32_t *inptr, int length, sps_format_t l_outpu debug(1, "Can't see how this could ever happen, but " "current_input_sample_floor_index %" PRId64 - " has just stepped outside the frame of %" PRId64 - "samples, with stuff %d and current_input_sample_index_fp at %" PRId64 ".%05" PRId64 + " has just stepped outside the frame of %d samples, with stuff %d and current_input_sample_index_fp at %" PRId64 ".%05" PRId64 ".", current_input_sample_floor_index, length, stuff, current_input_sample_index_int, current_input_sample_index_low); @@ -3035,8 +3034,7 @@ static int stuff_buffer_vernier(int32_t *inptr, int length, sps_format_t l_outpu debug(1, "Can't see how this could ever happen, but " "current_input_sample_ceil_index %" PRId64 - " has just stepped outside the frame of %" PRId64 - "samples, with stuff %d and current_input_sample_index_fp at %" PRId64 + " has just stepped outside the frame of %d samples, with stuff %d and current_input_sample_index_fp at %" PRId64 ".%05" PRId64 ".", current_input_sample_floor_index, length, stuff, current_input_sample_index_int, current_input_sample_index_low); @@ -3142,10 +3140,10 @@ int stuff_buffer_soxr_32(int32_t *inptr, int length, sps_format_t l_output_forma NULL, NULL); // Default configuration. if (error) - die("soxr error: %s\n", "error: %s\n", soxr_strerror(error)); + die("soxr error: %s\n", soxr_strerror(error)); if (odone > (size_t)(length + INTERPOLATION_LIMIT)) - die("odone = %u!\n", odone); + die("odone = %lu!\n", odone); // mean and variance calculations from "online_variance" algorithm at // https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Online_algorithm @@ -3693,7 +3691,7 @@ void *player_thread_func(void *arg) { (conn->input_effective_bit_depth > conn->output_bit_depth)) || (config.playback_mode == ST_mono)) { if (conn->enable_dither == 0) - debug(2, "enabling dither", conn->fix_volume); + debug(2, "enabling dither"); conn->enable_dither = 1; } else { if (conn->enable_dither != 0) @@ -4039,7 +4037,7 @@ void *player_thread_func(void *arg) { insertions_plus_deletions_ppm = (1000000.0 * tsum_of_insertions_and_deletions) / tsum_of_frames; } else { - debug(3, "tsum_of_frames: %u.", tsum_of_frames); + debug(3, "tsum_of_frames: %lu.", tsum_of_frames); } } if (config.statistics_requested) { @@ -4314,14 +4312,14 @@ void *player_thread_func(void *arg) { if (skipping_frames_at_start_of_play != 0) { if (sync_error <= 0) { debug(3, - "cancel skipping at start of play -- skip estimate was: %" PRId64 + "cancel skipping at start of play -- skip estimate was: %" PRId32 ", but sync_error is now: %" PRId64 ".", frames_to_skip, sync_error); frames_to_skip = 0; skipping_frames_at_start_of_play = 0; } else if (frames_to_skip != sync_error) { debug(3, - "updating skipping at start of play count from: %" PRId64 " to: %" PRId64 + "updating skipping at start of play count from: %" PRId32 " to: %" PRId64 ".", frames_to_skip, sync_error); frames_to_skip = sync_error; diff --git a/rtp.c b/rtp.c index 1ac5fa6b..5b9d268d 100644 --- a/rtp.c +++ b/rtp.c @@ -300,10 +300,10 @@ void *rtp_audio_receiver(void *arg) { debug(2, "resend-related request packet received, ignoring."); continue; } - debug(1, "Audio receiver -- Unknown RTP packet of type 0x%02X length %d seqno %d", type, + debug(1, "Audio receiver -- Unknown RTP packet of type 0x%02X length %ld seqno %d", type, nread, seqno); } - warn("Audio receiver -- Unknown RTP packet of type 0x%02X length %d.", type, nread); + warn("Audio receiver -- Unknown RTP packet of type 0x%02X length %ld.", type, nread); } else { char em[1024]; strerror_r(errno, em, sizeof(em)); @@ -573,7 +573,7 @@ void *rtp_control_receiver(void *arg) { debug(3, "Too-short retransmitted audio packet received in control port, ignored."); } } else - debug(1, "Control Receiver -- Unknown RTP packet of type 0x%02X length %d, ignored.", + debug(1, "Control Receiver -- Unknown RTP packet of type 0x%02X length %ld, ignored.", packet[1], nread); } else { debug(3, "Control Receiver -- dropping a packet to simulate a bad network."); @@ -834,7 +834,7 @@ void *rtp_timing_receiver(void *arg) { // conn->time_pings[cc].dispersion * pow(2.14, // 1.0/conn->time_ping_count); if (conn->time_pings[cc].dispersion > UINT64_MAX / dispersion_factor) - debug(1, "dispersion factor is too large at %" PRIu64 "."); + debug(1, "dispersion factor is too large at %" PRIu64 ".", dispersion_factor); else conn->time_pings[cc].dispersion = (conn->time_pings[cc].dispersion * dispersion_factor) / @@ -981,7 +981,7 @@ void *rtp_timing_receiver(void *arg) { return_time); } } else { - debug(1, "Timing port -- Unknown RTP packet of type 0x%02X length %d.", packet[1], nread); + debug(1, "Timing port -- Unknown RTP packet of type 0x%02X length %ld.", packet[1], nread); } } else { debug(3, "Timing Receiver Thread -- dropping incoming packet to simulate a bad network."); diff --git a/rtsp.c b/rtsp.c index 8c6978b7..9c7070cf 100644 --- a/rtsp.c +++ b/rtsp.c @@ -500,7 +500,8 @@ play_lock_r get_play_lock(rtsp_conn_info *conn, int allow_session_interruption) pthread_cleanup_pop(1); // release the principal_conn lock } else { - debug(1, "Connection %d: %s get_play_lock must have a non-NULL conn."); + debug(1, "Connection %d: %s get_play_lock must have a non-NULL conn.", conn->connection_number, + get_category_string(conn->airplay_stream_category)); } return response; } @@ -641,7 +642,7 @@ void msg_retain(rtsp_message *msg) { if (rc) debug(1, "Error %d unlocking reference counter lock", rc); } else { - debug(1, "invalid rtsp_message pointer 0x%x passed to retain", (uintptr_t)msg); + debug(1, "invalid rtsp_message pointer 0x%" PRIxPTR " passed to retain", (uintptr_t)msg); } } @@ -649,7 +650,7 @@ rtsp_message *msg_init(void) { // no thread cancellation points here int rc = debug_mutex_lock(&reference_counter_lock, 500000, 1); if (rc) - debug(1, "Error %d locking reference counter lock"); + debug(1, "Error %d locking reference counter lock", rc); rtsp_message *msg = malloc(sizeof(rtsp_message)); if (msg) { @@ -664,7 +665,7 @@ rtsp_message *msg_init(void) { rc = pthread_mutex_unlock(&reference_counter_lock); if (rc) - debug(1, "Error %d unlocking reference counter lock"); + debug(1, "Error %d unlocking reference counter lock", rc); return msg; } @@ -755,7 +756,7 @@ void msg_free(rtsp_message **msgh) { } else if (*msgh != NULL) { debug(1, "msg_free: error attempting to free an allocated but already-freed rtsp_message, number " - "%d.", + "%" PRIxPTR ".", (uintptr_t)*msgh); } debug_mutex_unlock(&reference_counter_lock, 0); @@ -1007,7 +1008,7 @@ ssize_t read_from_rtsp_connection(rtsp_conn_info *conn, void *buf, size_t count) if ((result <= 0) && (errno != 0)) { char errorstring[1024]; strerror_r(errno, (char *)errorstring, sizeof(errorstring)); - debug(3, "read_from_rtsp_connection error %d \"%s\" attempting to read up to %u bytes.", + debug(3, "read_from_rtsp_connection error %d \"%s\" attempting to read up to %lu bytes.", errno, errorstring, count); } } else { @@ -1041,7 +1042,7 @@ enum rtsp_read_request_response rtsp_read_request(rtsp_conn_info *conn, rtsp_mes debug(1, "Connection %d: rtsp_read_request: can't get a buffer.", conn->connection_number); reply = rtsp_read_request_response_error; } else { - debug(3, "buf is allocated at 0x%" PRIxPTR ".", buf); + debug(3, "buf is allocated at 0x%" PRIxPTR ".", (uintptr_t)buf); pthread_cleanup_push(malloc_cleanup, &buf); ssize_t nread; ssize_t inbuf = 0; @@ -1133,7 +1134,7 @@ enum rtsp_read_request_response rtsp_read_request(rtsp_conn_info *conn, rtsp_mes reply = rtsp_read_request_response_error; // goto shutdown; } else { - debug(3, "buf is reallocated at 0x%" PRIxPTR ".", buf); + debug(3, "buf is reallocated at 0x%" PRIxPTR ".", (uintptr_t)buf); buflen = msg_size; } } @@ -1332,7 +1333,7 @@ int msg_write_response(rtsp_conn_info *conn, rtsp_message *resp) { return -4; } if (reply != p - pkt) { - debug(1, "msg_write_response error -- requested bytes: %d not fully written: %d.", p - pkt, + debug(1, "msg_write_response error -- requested bytes: %ld not fully written: %ld.", p - pkt, reply); return -5; } @@ -3390,8 +3391,8 @@ void handle_setup(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) { debug(2, "Connection %d: SETUP DACP-ID \"%s\" from %s to %s with UDP ports Control: " "%d, Timing: %d and Audio: %d.", - conn->connection_number, conn->dacp_id, &conn->client_ip_string, - &conn->self_ip_string, conn->local_control_port, conn->local_timing_port, + conn->connection_number, conn->dacp_id, (char *)&conn->client_ip_string, + (char *)&conn->self_ip_string, conn->local_control_port, conn->local_timing_port, conn->local_audio_port); } else { @@ -3500,8 +3501,7 @@ void handle_set_parameter_parameter(rtsp_conn_info *conn, rtsp_message *req, #endif } else { - debug(1, "Connection %d, unrecognised parameter: \"%s\" (%d)\n", conn->connection_number, cp, - strlen(cp)); + debug(1, "Connection %d, unrecognised parameter: \"%s\"\n", conn->connection_number, cp); } cp = next; } @@ -5018,7 +5018,7 @@ void rtsp_conversation_thread_cleanup_function(void *arg) { } void msg_cleanup_function(void *arg) { - debug(3, "msg_cleanup_function called 0x%" PRIxPTR ".", arg); + debug(3, "msg_cleanup_function called 0x%" PRIxPTR ".", (uintptr_t)arg); msg_free((rtsp_message **)arg); } @@ -5071,7 +5071,7 @@ static void *rtsp_conversation_thread_func(void *pconn) { int i; for (i = 0; i < nconns; i++) { if ((conns[i] != NULL) && (conns[i]->connection_number == 0)) { - debug(1, "conns[%d] at %" PRIxPTR " has a Connection Number of 0!", i, conns[i]); + debug(1, "conns[%d] has a Connection Number of 0!", i); } } debug_mutex_unlock(&conns_lock, 3); @@ -5194,7 +5194,7 @@ static void *rtsp_conversation_thread_func(void *pconn) { debug(1, "rtsp_read_request_response_bad_packet write response error %d: \"%s\".", errno, (char *)errorstring); } else if (lreply != (ssize_t)strlen(response_text)) { - debug(1, "rtsp_read_request_response_bad_packet write %d bytes requested but %d written.", + debug(1, "rtsp_read_request_response_bad_packet write %ld bytes requested but %d written.", strlen(response_text), reply); } } @@ -5399,7 +5399,7 @@ void *rtsp_listen_loop(__attribute((unused)) void *arg) { pthread_cleanup_push(malloc_cleanup, &conn); memset(conn, 0, sizeof(rtsp_conn_info)); conn->connection_number = RTSP_connection_index++; - debug(2, "Connection %d is at: 0x%" PRIxPTR ".", conn->connection_number, conn); + debug(2, "Connection %d is at: 0x%" PRIxPTR ".", conn->connection_number, (uintptr_t)conn); // this means that the OPTIONS string we send before getting an ANNOUNCE is for AirPlay 2 #ifdef CONFIG_AIRPLAY_2 diff --git a/shairport.c b/shairport.c index d3d8421a..e196d416 100644 --- a/shairport.c +++ b/shairport.c @@ -708,10 +708,10 @@ int parse_options(int argc, char **argv) { if (config_lookup_int(config.cfg, "general.port", &value)) { if ((value < 0) || (value > 65535)) #ifdef CONFIG_AIRPLAY_2 - die("Invalid port number \"%sd\". It should be between 0 and 65535, default is 7000", + die("Invalid port number \"%d\". It should be between 0 and 65535, default is 7000", value); #else - die("Invalid port number \"%sd\". It should be between 0 and 65535, default is 5000", + die("Invalid port number \"%d\". It should be between 0 and 65535, default is 5000", value); #endif else @@ -721,7 +721,7 @@ int parse_options(int argc, char **argv) { /* Get the udp port base setting. */ if (config_lookup_int(config.cfg, "general.udp_port_base", &value)) { if ((value < 0) || (value > 65535)) - die("Invalid port number \"%sd\". It should be between 0 and 65535, default is 6001", + die("Invalid port number \"%d\". It should be between 0 and 65535, default is 6001", value); else config.udp_port_base = value; @@ -731,7 +731,7 @@ int parse_options(int argc, char **argv) { * starting at the port base. Only three ports are needed. */ if (config_lookup_int(config.cfg, "general.udp_port_range", &value)) { if ((value < 3) || (value > 65535)) - die("Invalid port range \"%sd\". It should be between 3 and 65535, default is 10", + die("Invalid port range \"%d\". It should be between 3 and 65535, default is 10", value); else config.udp_port_range = value; @@ -896,7 +896,7 @@ int parse_options(int argc, char **argv) { if ((dvalue >= 0.0) && (dvalue <= 3.0)) config.diagnostic_drop_packet_fraction = dvalue; else - die("Invalid diagnostics drop_this_fraction_of_audio_packets setting \"%d\". It should " + die("Invalid diagnostics drop_this_fraction_of_audio_packets setting \"%f\". It should " "be " "between 0.0 and 1.0, " "inclusive.", @@ -1234,7 +1234,7 @@ int parse_options(int argc, char **argv) { } else if (value < 60) { warn("Invalid value \"%d\" for \"session_timeout\". It must be 0 (i.e. no timeout) or at " "least 60. " - "The default of %f will be used instead.", + "The default of %d will be used instead.", value, config.timeout); config.dont_check_timeout = 0; } else { @@ -2024,6 +2024,12 @@ void termHandler(__attribute__((unused)) int k) { void _display_config(const char *filename, const int linenumber, __attribute__((unused)) int argc, __attribute__((unused)) char **argv) { + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-zero-length" +#endif + _inform(filename, linenumber, ">> Display Config Start."); // see the man entry on popen @@ -2202,7 +2208,11 @@ void _display_config(const char *filename, const int linenumber, __attribute__(( } } _inform(filename, linenumber, ""); - _inform(filename, linenumber, ">> Display Config End."); + _inform(filename, linenumber, ">> Display Config End."); + + #if defined(__GNUC__) || defined(__clang__) + #pragma GCC diagnostic pop + #endif } #define display_config(argc, argv) _display_config(__FILE__, __LINE__, argc, argv) diff --git a/utilities/debug.h b/utilities/debug.h index 9ba21e95..e29e8066 100644 --- a/utilities/debug.h +++ b/utilities/debug.h @@ -51,13 +51,19 @@ EXTERNC void set_show_relative_time(int setting); EXTERNC int get_show_file_and_line(); EXTERNC void set_show_file_and_line(int setting); -EXTERNC void _die(const char *filename, const int linenumber, const char *format, ...); -EXTERNC void _warn(const char *filename, const int linenumber, const char *format, ...); -EXTERNC void _inform(const char *filename, const int linenumber, const char *format, ...); -EXTERNC void _debug(const char *filename, const int linenumber, int level, const char *format, ...); -EXTERNC void _debug_print_buffer(const char *thefilename, const int linenumber, int level, - void *buf, size_t buf_len); +#if defined(__GNUC__) || defined(__clang__) +#define PRINTF_LIKE(fmt, args) __attribute__((format(printf, fmt, args))) +#else +#define PRINTF_LIKE(fmt, args) +#endif +// Function declarations with printf-style format checking +EXTERNC void _die(const char *filename, const int linenumber, const char *format, ...) PRINTF_LIKE(3,4); +EXTERNC void _warn(const char *filename, const int linenumber, const char *format, ...) PRINTF_LIKE(3,4); +EXTERNC void _inform(const char *filename, const int linenumber, const char *format, ...) PRINTF_LIKE(3,4); +EXTERNC void _debug(const char *filename, const int linenumber, int level, const char *format, ...) PRINTF_LIKE(4,5); +EXTERNC void _debug_print_buffer(const char *thefilename, const int linenumber, int level, void *buf, + size_t buf_len); // not printf-style, no change needed #define die(...) _die(__FILE__, __LINE__, __VA_ARGS__) #define debug(...) _debug(__FILE__, __LINE__, __VA_ARGS__) #define warn(...) _warn(__FILE__, __LINE__, __VA_ARGS__) diff --git a/utilities/network_utilities.c b/utilities/network_utilities.c index 81c01693..63882e4b 100644 --- a/utilities/network_utilities.c +++ b/utilities/network_utilities.c @@ -38,7 +38,7 @@ int eintr_checked_accept(int sockfd, struct sockaddr *addr, char errorstring[1024]; strerror_r(errno, (char *)errorstring, sizeof(errorstring)); debug(1, - "error %d accept()ing a socketin ap2_event_receiver %d: \"%s\". Error %d is ignored.", + "error %d accept()ing a socketin ap2_event_receiver: \"%s\". (Note: error %d will be ignored.)", errno, errorstring, EINTR); }